잠시 쉴겸 해서 만들어 보았다. 시스템 메모리를 사용안하고 파일기반으로 데이터 처리를 하고 싶을때 사용하면 된다. 물론 속도가 많이 느리겠지만 앞으로 최적의 속도를 위해서 꾸준히 업데이트 해야 겠다.
Meomry Map File을 사용하기 때문에 win32환경에서 작동된다.
인터페이스는 CArray와 동일하게 만들었다. 아직 속도검사는 하지 않았다. 심심할때 메모리기반 배열과 비교를 해봐야 겠다.
아래는 예제이다.
01: // FileArraySample.cpp : Defines the entry point for the console application. 02: // 03: 04: #include "stdafx.h" 05: #include "FileArray.h" 06: 07: int _tmain(int argc, _TCHAR* argv[]) 08: { 09: TFileArray<UINT> IntArray; 10: 11: 12: IntArray.Open(_T("d:\\aaa.tmp")); 13: IntArray.RemoveAll(); 14: 15: for (UINT i=0;i<10;++i) 16: IntArray.Add(i); 17: 18: for (UINT i=0;i<IntArray.GetSize();++i) 19: printf("%u \n", IntArray[i]); 20: 21: for (UINT i=0;i<IntArray.GetSize();++i) 22: { 23: UINT v=i+1000; 24: IntArray.SetAt(i,v); 25: } 26: 27: for (UINT i=0;i<10;++i) 28: { 29: UINT v=i+10000; 30: IntArray.Add(v); 31: } 32: 33: for (UINT i=0;i<IntArray.GetSize();++i) 34: printf("%u \n", IntArray[i]); 35: 36: IntArray.Close(); 37: 38: return 0; 39: } 40:
소스 :

Posted by chungki

2010/02/25 01:38 2010/02/25 01:38
, ,
Response
A trackback , No Comment
RSS :
http://www.chungki.net/tc/rss/response/297

SmartPointer

template 
class SmartP
{

	class CReference
	{

	public:

		CReference() : m_RefCount(0) {}
		virtual ~CReference() {m_RefCount=0;}

		void	IncRef() {m_RefCount++;}
		bool	DecRef()
		{
			if ((--m_RefCount)==0)
				return true;

			return false;
		}

		void	Release() {delete this;}

	private:

		u32	m_RefCount;
	};

public:

	typedef _T*				pointertype;
	typedef const _T*		const_interfacetype;
	typedef CReference*		referencetype;

public:

	pointertype		m_Pointer;
	referencetype	m_Reference;

public:

	SmartP();
	SmartP(IN pointertype _Interface);
	SmartP(IN const SmartP<_T>& _SmartI);
	virtual ~SmartP();

public:

	const pointertype	GetPointer() const {return m_Pointer;}
	const referencetype	GetReference() const {return m_Reference;}

private:

	void __Create(IN pointertype _Pointer);
	void __Destroy();

public:

	SmartP<_T> operator =(IN pointertype _Pointer);
	SmartP<_T> operator =(IN const SmartP<_T>& _SmartP);

	bool  operator ==(IN const SmartP<_T>& _SmartP);
	bool  operator ==(IN const pointertype _Pointer);
	bool  operator !=(IN const SmartP<_T>& _SmartP);
	bool  operator !=(IN const pointertype _Pointer);

	pointertype		operator ->() {return m_Pointer;}
	const_interfacetype	operator ->() const {return m_Pointer;}

	operator pointertype()				{return m_Pointer;}
	operator const_interfacetype() const	{return m_Pointer;}

};

Posted by chungki

2008/10/25 23:24 2008/10/25 23:24
,
Response
No Trackback , 2 Comments
RSS :
http://www.chungki.net/tc/rss/response/264


블로그 이미지

Nice !!!!!!!!

- chungki

Notices

Archives

Authors

  1. chungki

Calendar

«   2012/05   »
    1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31    

Site Stats

Total hits:
73374
Today:
5
Yesterday:
20