| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496 |
- // This is a part of the Microsoft Foundation Classes C++ library.
- // Copyright (C) 1992-1998 Microsoft Corporation
- // All rights reserved.
- //
- // This source code is only intended as a supplement to the
- // Microsoft Foundation Classes Reference and related
- // electronic documentation provided with the library.
- // See these sources for detailed information regarding the
- // Microsoft Foundation Classes product.
- #ifndef __AFXCOLL_H__
- #define __AFXCOLL_H__
- #ifndef __AFX_H__
- #include <afx.h>
- #endif
- #ifdef _AFX_MINREBUILD
- #pragma component(minrebuild, off)
- #endif
- #ifndef _AFX_FULLTYPEINFO
- #pragma component(mintypeinfo, on)
- #endif
- #ifdef _AFX_PACKING
- #pragma pack(push, _AFX_PACKING)
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // Classes declared in this file
- //CObject
- // Arrays
- class CByteArray; // array of BYTE
- class CWordArray; // array of WORD
- class CDWordArray; // array of DWORD
- class CUIntArray; // array of UINT
- class CPtrArray; // array of void*
- class CObArray; // array of CObject*
- // Lists
- class CPtrList; // list of void*
- class CObList; // list of CObject*
- // Maps (aka Dictionaries)
- class CMapWordToOb; // map from WORD to CObject*
- class CMapWordToPtr; // map from WORD to void*
- class CMapPtrToWord; // map from void* to WORD
- class CMapPtrToPtr; // map from void* to void*
- // Special String variants
- class CStringArray; // array of CStrings
- class CStringList; // list of CStrings
- class CMapStringToPtr; // map from CString to void*
- class CMapStringToOb; // map from CString to CObject*
- class CMapStringToString; // map from CString to CString
- /////////////////////////////////////////////////////////////////////////////
- #undef AFX_DATA
- #define AFX_DATA AFX_CORE_DATA
- ////////////////////////////////////////////////////////////////////////////
- class CByteArray : public CObject
- {
- DECLARE_SERIAL(CByteArray)
- public:
- // Construction
- CByteArray();
- // Attributes
- int GetSize() const;
- int GetUpperBound() const;
- void SetSize(int nNewSize, int nGrowBy = -1);
- // Operations
- // Clean up
- void FreeExtra();
- void RemoveAll();
- // Accessing elements
- BYTE GetAt(int nIndex) const;
- void SetAt(int nIndex, BYTE newElement);
- BYTE& ElementAt(int nIndex);
- // Direct Access to the element data (may return NULL)
- const BYTE* GetData() const;
- BYTE* GetData();
- // Potentially growing the array
- void SetAtGrow(int nIndex, BYTE newElement);
- int Add(BYTE newElement);
- int Append(const CByteArray& src);
- void Copy(const CByteArray& src);
- // overloaded operator helpers
- BYTE operator[](int nIndex) const;
- BYTE& operator[](int nIndex);
- // Operations that move elements around
- void InsertAt(int nIndex, BYTE newElement, int nCount = 1);
- void RemoveAt(int nIndex, int nCount = 1);
- void InsertAt(int nStartIndex, CByteArray* pNewArray);
- // Implementation
- protected:
- BYTE* m_pData; // the actual array of data
- int m_nSize; // # of elements (upperBound - 1)
- int m_nMaxSize; // max allocated
- int m_nGrowBy; // grow amount
- public:
- ~CByteArray();
- void Serialize(CArchive&);
- #ifdef _DEBUG
- void Dump(CDumpContext&) const;
- void AssertValid() const;
- #endif
- protected:
- // local typedefs for class templates
- typedef BYTE BASE_TYPE;
- typedef BYTE BASE_ARG_TYPE;
- };
- ////////////////////////////////////////////////////////////////////////////
- class CWordArray : public CObject
- {
- DECLARE_SERIAL(CWordArray)
- public:
- // Construction
- CWordArray();
- // Attributes
- int GetSize() const;
- int GetUpperBound() const;
- void SetSize(int nNewSize, int nGrowBy = -1);
- // Operations
- // Clean up
- void FreeExtra();
- void RemoveAll();
- // Accessing elements
- WORD GetAt(int nIndex) const;
- void SetAt(int nIndex, WORD newElement);
- WORD& ElementAt(int nIndex);
- // Direct Access to the element data (may return NULL)
- const WORD* GetData() const;
- WORD* GetData();
- // Potentially growing the array
- void SetAtGrow(int nIndex, WORD newElement);
- int Add(WORD newElement);
- int Append(const CWordArray& src);
- void Copy(const CWordArray& src);
- // overloaded operator helpers
- WORD operator[](int nIndex) const;
- WORD& operator[](int nIndex);
- // Operations that move elements around
- void InsertAt(int nIndex, WORD newElement, int nCount = 1);
- void RemoveAt(int nIndex, int nCount = 1);
- void InsertAt(int nStartIndex, CWordArray* pNewArray);
- // Implementation
- protected:
- WORD* m_pData; // the actual array of data
- int m_nSize; // # of elements (upperBound - 1)
- int m_nMaxSize; // max allocated
- int m_nGrowBy; // grow amount
- public:
- ~CWordArray();
- void Serialize(CArchive&);
- #ifdef _DEBUG
- void Dump(CDumpContext&) const;
- void AssertValid() const;
- #endif
- protected:
- // local typedefs for class templates
- typedef WORD BASE_TYPE;
- typedef WORD BASE_ARG_TYPE;
- };
- ////////////////////////////////////////////////////////////////////////////
- class CDWordArray : public CObject
- {
- DECLARE_SERIAL(CDWordArray)
- public:
- // Construction
- CDWordArray();
- // Attributes
- int GetSize() const;
- int GetUpperBound() const;
- void SetSize(int nNewSize, int nGrowBy = -1);
- // Operations
- // Clean up
- void FreeExtra();
- void RemoveAll();
- // Accessing elements
- DWORD GetAt(int nIndex) const;
- void SetAt(int nIndex, DWORD newElement);
- DWORD& ElementAt(int nIndex);
- // Direct Access to the element data (may return NULL)
- const DWORD* GetData() const;
- DWORD* GetData();
- // Potentially growing the array
- void SetAtGrow(int nIndex, DWORD newElement);
- int Add(DWORD newElement);
- int Append(const CDWordArray& src);
- void Copy(const CDWordArray& src);
- // overloaded operator helpers
- DWORD operator[](int nIndex) const;
- DWORD& operator[](int nIndex);
- // Operations that move elements around
- void InsertAt(int nIndex, DWORD newElement, int nCount = 1);
- void RemoveAt(int nIndex, int nCount = 1);
- void InsertAt(int nStartIndex, CDWordArray* pNewArray);
- // Implementation
- protected:
- DWORD* m_pData; // the actual array of data
- int m_nSize; // # of elements (upperBound - 1)
- int m_nMaxSize; // max allocated
- int m_nGrowBy; // grow amount
- public:
- ~CDWordArray();
- void Serialize(CArchive&);
- #ifdef _DEBUG
- void Dump(CDumpContext&) const;
- void AssertValid() const;
- #endif
- protected:
- // local typedefs for class templates
- typedef DWORD BASE_TYPE;
- typedef DWORD BASE_ARG_TYPE;
- };
- ////////////////////////////////////////////////////////////////////////////
- class CUIntArray : public CObject
- {
- DECLARE_DYNAMIC(CUIntArray)
- public:
- // Construction
- CUIntArray();
- // Attributes
- int GetSize() const;
- int GetUpperBound() const;
- void SetSize(int nNewSize, int nGrowBy = -1);
- // Operations
- // Clean up
- void FreeExtra();
- void RemoveAll();
- // Accessing elements
- UINT GetAt(int nIndex) const;
- void SetAt(int nIndex, UINT newElement);
- UINT& ElementAt(int nIndex);
- // Direct Access to the element data (may return NULL)
- const UINT* GetData() const;
- UINT* GetData();
- // Potentially growing the array
- void SetAtGrow(int nIndex, UINT newElement);
- int Add(UINT newElement);
- int Append(const CUIntArray& src);
- void Copy(const CUIntArray& src);
- // overloaded operator helpers
- UINT operator[](int nIndex) const;
- UINT& operator[](int nIndex);
- // Operations that move elements around
- void InsertAt(int nIndex, UINT newElement, int nCount = 1);
- void RemoveAt(int nIndex, int nCount = 1);
- void InsertAt(int nStartIndex, CUIntArray* pNewArray);
- // Implementation
- protected:
- UINT* m_pData; // the actual array of data
- int m_nSize; // # of elements (upperBound - 1)
- int m_nMaxSize; // max allocated
- int m_nGrowBy; // grow amount
- public:
- ~CUIntArray();
- #ifdef _DEBUG
- void Dump(CDumpContext&) const;
- void AssertValid() const;
- #endif
- protected:
- // local typedefs for class templates
- typedef UINT BASE_TYPE;
- typedef UINT BASE_ARG_TYPE;
- };
- ////////////////////////////////////////////////////////////////////////////
- class CPtrArray : public CObject
- {
- DECLARE_DYNAMIC(CPtrArray)
- public:
- // Construction
- CPtrArray();
- // Attributes
- int GetSize() const;
- int GetUpperBound() const;
- void SetSize(int nNewSize, int nGrowBy = -1);
- // Operations
- // Clean up
- void FreeExtra();
- void RemoveAll();
- // Accessing elements
- void* GetAt(int nIndex) const;
- void SetAt(int nIndex, void* newElement);
- void*& ElementAt(int nIndex);
- // Direct Access to the element data (may return NULL)
- const void** GetData() const;
- void** GetData();
- // Potentially growing the array
- void SetAtGrow(int nIndex, void* newElement);
- int Add(void* newElement);
- int Append(const CPtrArray& src);
- void Copy(const CPtrArray& src);
- // overloaded operator helpers
- void* operator[](int nIndex) const;
- void*& operator[](int nIndex);
- // Operations that move elements around
- void InsertAt(int nIndex, void* newElement, int nCount = 1);
- void RemoveAt(int nIndex, int nCount = 1);
- void InsertAt(int nStartIndex, CPtrArray* pNewArray);
- // Implementation
- protected:
- void** m_pData; // the actual array of data
- int m_nSize; // # of elements (upperBound - 1)
- int m_nMaxSize; // max allocated
- int m_nGrowBy; // grow amount
- public:
- ~CPtrArray();
- #ifdef _DEBUG
- void Dump(CDumpContext&) const;
- void AssertValid() const;
- #endif
- protected:
- // local typedefs for class templates
- typedef void* BASE_TYPE;
- typedef void* BASE_ARG_TYPE;
- };
- ////////////////////////////////////////////////////////////////////////////
- class CObArray : public CObject
- {
- DECLARE_SERIAL(CObArray)
- public:
- // Construction
- CObArray();
- // Attributes
- int GetSize() const;
- int GetUpperBound() const;
- void SetSize(int nNewSize, int nGrowBy = -1);
- // Operations
- // Clean up
- void FreeExtra();
- void RemoveAll();
- // Accessing elements
- CObject* GetAt(int nIndex) const;
- void SetAt(int nIndex, CObject* newElement);
- CObject*& ElementAt(int nIndex);
- // Direct Access to the element data (may return NULL)
- const CObject** GetData() const;
- CObject** GetData();
- // Potentially growing the array
- void SetAtGrow(int nIndex, CObject* newElement);
- int Add(CObject* newElement);
- int Append(const CObArray& src);
- void Copy(const CObArray& src);
- // overloaded operator helpers
- CObject* operator[](int nIndex) const;
- CObject*& operator[](int nIndex);
- // Operations that move elements around
- void InsertAt(int nIndex, CObject* newElement, int nCount = 1);
- void RemoveAt(int nIndex, int nCount = 1);
- void InsertAt(int nStartIndex, CObArray* pNewArray);
- // Implementation
- protected:
- CObject** m_pData; // the actual array of data
- int m_nSize; // # of elements (upperBound - 1)
- int m_nMaxSize; // max allocated
- int m_nGrowBy; // grow amount
- public:
- ~CObArray();
- void Serialize(CArchive&);
- #ifdef _DEBUG
- void Dump(CDumpContext&) const;
- void AssertValid() const;
- #endif
- protected:
- // local typedefs for class templates
- typedef CObject* BASE_TYPE;
- typedef CObject* BASE_ARG_TYPE;
- };
- ////////////////////////////////////////////////////////////////////////////
- class CStringArray : public CObject
- {
- DECLARE_SERIAL(CStringArray)
- public:
- // Construction
- CStringArray();
- // Attributes
- int GetSize() const;
- int GetUpperBound() const;
- void SetSize(int nNewSize, int nGrowBy = -1);
- // Operations
- // Clean up
- void FreeExtra();
- void RemoveAll();
- // Accessing elements
- CString GetAt(int nIndex) const;
- void SetAt(int nIndex, LPCTSTR newElement);
- void SetAt(int nIndex, const CString& newElement);
- CString& ElementAt(int nIndex);
- // Direct Access to the element data (may return NULL)
- const CString* GetData() const;
- CString* GetData();
- // Potentially growing the array
- void SetAtGrow(int nIndex, LPCTSTR newElement);
- void SetAtGrow(int nIndex, const CString& newElement);
- int Add(LPCTSTR newElement);
- int Add(const CString& newElement);
- int Append(const CStringArray& src);
- void Copy(const CStringArray& src);
- // overloaded operator helpers
- CString operator[](int nIndex) const;
- CString& operator[](int nIndex);
- // Operations that move elements around
- void InsertAt(int nIndex, LPCTSTR newElement, int nCount = 1);
- void InsertAt(int nIndex, const CString& newElement, int nCount = 1);
- void RemoveAt(int nIndex, int nCount = 1);
- void InsertAt(int nStartIndex, CStringArray* pNewArray);
- // Implementation
- protected:
- CString* m_pData; // the actual array of data
- int m_nSize; // # of elements (upperBound - 1)
- int m_nMaxSize; // max allocated
- int m_nGrowBy; // grow amount
- void InsertEmpty(int nIndex, int nCount);
- public:
- ~CStringArray();
- void Serialize(CArchive&);
- #ifdef _DEBUG
- void Dump(CDumpContext&) const;
- void AssertValid() const;
- #endif
- protected:
- // local typedefs for class templates
- typedef CString BASE_TYPE;
- typedef LPCTSTR BASE_ARG_TYPE;
- };
- /////////////////////////////////////////////////////////////////////////////
- class CPtrList : public CObject
- {
- DECLARE_DYNAMIC(CPtrList)
- protected:
- struct CNode
- {
- CNode* pNext;
- CNode* pPrev;
- void* data;
- };
- public:
- // Construction
- CPtrList(int nBlockSize = 10);
- // Attributes (head and tail)
- // count of elements
- int GetCount() const;
- BOOL IsEmpty() const;
- // peek at head or tail
- void*& GetHead();
- void* GetHead() const;
- void*& GetTail();
- void* GetTail() const;
- // Operations
- // get head or tail (and remove it) - don't call on empty list!
- void* RemoveHead();
- void* RemoveTail();
- // add before head or after tail
- POSITION AddHead(void* newElement);
- POSITION AddTail(void* newElement);
- // add another list of elements before head or after tail
- void AddHead(CPtrList* pNewList);
- void AddTail(CPtrList* pNewList);
- // remove all elements
- void RemoveAll();
- // iteration
- POSITION GetHeadPosition() const;
- POSITION GetTailPosition() const;
- void*& GetNext(POSITION& rPosition); // return *Position++
- void* GetNext(POSITION& rPosition) const; // return *Position++
- void*& GetPrev(POSITION& rPosition); // return *Position--
- void* GetPrev(POSITION& rPosition) const; // return *Position--
- // getting/modifying an element at a given position
- void*& GetAt(POSITION position);
- void* GetAt(POSITION position) const;
- void SetAt(POSITION pos, void* newElement);
- void RemoveAt(POSITION position);
- // inserting before or after a given position
- POSITION InsertBefore(POSITION position, void* newElement);
- POSITION InsertAfter(POSITION position, void* newElement);
- // helper functions (note: O(n) speed)
- POSITION Find(void* searchValue, POSITION startAfter = NULL) const;
- // defaults to starting at the HEAD
- // return NULL if not found
- POSITION FindIndex(int nIndex) const;
- // get the 'nIndex'th element (may return NULL)
- // Implementation
- protected:
- CNode* m_pNodeHead;
- CNode* m_pNodeTail;
- int m_nCount;
- CNode* m_pNodeFree;
- struct CPlex* m_pBlocks;
- int m_nBlockSize;
- CNode* NewNode(CNode*, CNode*);
- void FreeNode(CNode*);
- public:
- ~CPtrList();
- #ifdef _DEBUG
- void Dump(CDumpContext&) const;
- void AssertValid() const;
- #endif
- // local typedefs for class templates
- typedef void* BASE_TYPE;
- typedef void* BASE_ARG_TYPE;
- };
- /////////////////////////////////////////////////////////////////////////////
- class CObList : public CObject
- {
- DECLARE_SERIAL(CObList)
- protected:
- struct CNode
- {
- CNode* pNext;
- CNode* pPrev;
- CObject* data;
- };
- public:
- // Construction
- CObList(int nBlockSize = 10);
- // Attributes (head and tail)
- // count of elements
- int GetCount() const;
- BOOL IsEmpty() const;
- // peek at head or tail
- CObject*& GetHead();
- CObject* GetHead() const;
- CObject*& GetTail();
- CObject* GetTail() const;
- // Operations
- // get head or tail (and remove it) - don't call on empty list!
- CObject* RemoveHead();
- CObject* RemoveTail();
- // add before head or after tail
- POSITION AddHead(CObject* newElement);
- POSITION AddTail(CObject* newElement);
- // add another list of elements before head or after tail
- void AddHead(CObList* pNewList);
- void AddTail(CObList* pNewList);
- // remove all elements
- void RemoveAll();
- // iteration
- POSITION GetHeadPosition() const;
- POSITION GetTailPosition() const;
- CObject*& GetNext(POSITION& rPosition); // return *Position++
- CObject* GetNext(POSITION& rPosition) const; // return *Position++
- CObject*& GetPrev(POSITION& rPosition); // return *Position--
- CObject* GetPrev(POSITION& rPosition) const; // return *Position--
- // getting/modifying an element at a given position
- CObject*& GetAt(POSITION position);
- CObject* GetAt(POSITION position) const;
- void SetAt(POSITION pos, CObject* newElement);
- void RemoveAt(POSITION position);
- // inserting before or after a given position
- POSITION InsertBefore(POSITION position, CObject* newElement);
- POSITION InsertAfter(POSITION position, CObject* newElement);
- // helper functions (note: O(n) speed)
- POSITION Find(CObject* searchValue, POSITION startAfter = NULL) const;
- // defaults to starting at the HEAD
- // return NULL if not found
- POSITION FindIndex(int nIndex) const;
- // get the 'nIndex'th element (may return NULL)
- // Implementation
- protected:
- CNode* m_pNodeHead;
- CNode* m_pNodeTail;
- int m_nCount;
- CNode* m_pNodeFree;
- struct CPlex* m_pBlocks;
- int m_nBlockSize;
- CNode* NewNode(CNode*, CNode*);
- void FreeNode(CNode*);
- public:
- ~CObList();
- void Serialize(CArchive&);
- #ifdef _DEBUG
- void Dump(CDumpContext&) const;
- void AssertValid() const;
- #endif
- // local typedefs for class templates
- typedef CObject* BASE_TYPE;
- typedef CObject* BASE_ARG_TYPE;
- };
- /////////////////////////////////////////////////////////////////////////////
- class CStringList : public CObject
- {
- DECLARE_SERIAL(CStringList)
- protected:
- struct CNode
- {
- CNode* pNext;
- CNode* pPrev;
- CString data;
- };
- public:
- // Construction
- CStringList(int nBlockSize = 10);
- // Attributes (head and tail)
- // count of elements
- int GetCount() const;
- BOOL IsEmpty() const;
- // peek at head or tail
- CString& GetHead();
- CString GetHead() const;
- CString& GetTail();
- CString GetTail() const;
- // Operations
- // get head or tail (and remove it) - don't call on empty list!
- CString RemoveHead();
- CString RemoveTail();
- // add before head or after tail
- POSITION AddHead(LPCTSTR newElement);
- POSITION AddTail(LPCTSTR newElement);
- POSITION AddHead(const CString& newElement);
- POSITION AddTail(const CString& newElement);
- // add another list of elements before head or after tail
- void AddHead(CStringList* pNewList);
- void AddTail(CStringList* pNewList);
- // remove all elements
- void RemoveAll();
- // iteration
- POSITION GetHeadPosition() const;
- POSITION GetTailPosition() const;
- CString& GetNext(POSITION& rPosition); // return *Position++
- CString GetNext(POSITION& rPosition) const; // return *Position++
- CString& GetPrev(POSITION& rPosition); // return *Position--
- CString GetPrev(POSITION& rPosition) const; // return *Position--
- // getting/modifying an element at a given position
- CString& GetAt(POSITION position);
- CString GetAt(POSITION position) const;
- void SetAt(POSITION pos, LPCTSTR newElement);
- void SetAt(POSITION pos, const CString& newElement);
- void RemoveAt(POSITION position);
- // inserting before or after a given position
- POSITION InsertBefore(POSITION position, LPCTSTR newElement);
- POSITION InsertAfter(POSITION position, LPCTSTR newElement);
- POSITION InsertBefore(POSITION position, const CString& newElement);
- POSITION InsertAfter(POSITION position, const CString& newElement);
- // helper functions (note: O(n) speed)
- POSITION Find(LPCTSTR searchValue, POSITION startAfter = NULL) const;
- // defaults to starting at the HEAD
- // return NULL if not found
- POSITION FindIndex(int nIndex) const;
- // get the 'nIndex'th element (may return NULL)
- // Implementation
- protected:
- CNode* m_pNodeHead;
- CNode* m_pNodeTail;
- int m_nCount;
- CNode* m_pNodeFree;
- struct CPlex* m_pBlocks;
- int m_nBlockSize;
- CNode* NewNode(CNode*, CNode*);
- void FreeNode(CNode*);
- public:
- ~CStringList();
- void Serialize(CArchive&);
- #ifdef _DEBUG
- void Dump(CDumpContext&) const;
- void AssertValid() const;
- #endif
- // local typedefs for class templates
- typedef CString BASE_TYPE;
- typedef LPCTSTR BASE_ARG_TYPE;
- };
- /////////////////////////////////////////////////////////////////////////////
- class CMapWordToPtr : public CObject
- {
- DECLARE_DYNAMIC(CMapWordToPtr)
- protected:
- // Association
- struct CAssoc
- {
- CAssoc* pNext;
- WORD key;
- void* value;
- };
- public:
- // Construction
- CMapWordToPtr(int nBlockSize = 10);
- // Attributes
- // number of elements
- int GetCount() const;
- BOOL IsEmpty() const;
- // Lookup
- BOOL Lookup(WORD key, void*& rValue) const;
- // Operations
- // Lookup and add if not there
- void*& operator[](WORD key);
- // add a new (key, value) pair
- void SetAt(WORD key, void* newValue);
- // removing existing (key, ?) pair
- BOOL RemoveKey(WORD key);
- void RemoveAll();
- // iterating all (key, value) pairs
- POSITION GetStartPosition() const;
- void GetNextAssoc(POSITION& rNextPosition, WORD& rKey, void*& rValue) const;
- // advanced features for derived classes
- UINT GetHashTableSize() const;
- void InitHashTable(UINT hashSize, BOOL bAllocNow = TRUE);
- // Overridables: special non-virtual (see map implementation for details)
- // Routine used to user-provided hash keys
- UINT HashKey(WORD key) const;
- // Implementation
- protected:
- CAssoc** m_pHashTable;
- UINT m_nHashTableSize;
- int m_nCount;
- CAssoc* m_pFreeList;
- struct CPlex* m_pBlocks;
- int m_nBlockSize;
- CAssoc* NewAssoc();
- void FreeAssoc(CAssoc*);
- CAssoc* GetAssocAt(WORD, UINT&) const;
- public:
- ~CMapWordToPtr();
- #ifdef _DEBUG
- void Dump(CDumpContext&) const;
- void AssertValid() const;
- #endif
- protected:
- // local typedefs for CTypedPtrMap class template
- typedef WORD BASE_KEY;
- typedef WORD BASE_ARG_KEY;
- typedef void* BASE_VALUE;
- typedef void* BASE_ARG_VALUE;
- };
- /////////////////////////////////////////////////////////////////////////////
- class CMapPtrToWord : public CObject
- {
- DECLARE_DYNAMIC(CMapPtrToWord)
- protected:
- // Association
- struct CAssoc
- {
- CAssoc* pNext;
- void* key;
- WORD value;
- };
- public:
- // Construction
- CMapPtrToWord(int nBlockSize = 10);
- // Attributes
- // number of elements
- int GetCount() const;
- BOOL IsEmpty() const;
- // Lookup
- BOOL Lookup(void* key, WORD& rValue) const;
- // Operations
- // Lookup and add if not there
- WORD& operator[](void* key);
- // add a new (key, value) pair
- void SetAt(void* key, WORD newValue);
- // removing existing (key, ?) pair
- BOOL RemoveKey(void* key);
- void RemoveAll();
- // iterating all (key, value) pairs
- POSITION GetStartPosition() const;
- void GetNextAssoc(POSITION& rNextPosition, void*& rKey, WORD& rValue) const;
- // advanced features for derived classes
- UINT GetHashTableSize() const;
- void InitHashTable(UINT hashSize, BOOL bAllocNow = TRUE);
- // Overridables: special non-virtual (see map implementation for details)
- // Routine used to user-provided hash keys
- UINT HashKey(void* key) const;
- // Implementation
- protected:
- CAssoc** m_pHashTable;
- UINT m_nHashTableSize;
- int m_nCount;
- CAssoc* m_pFreeList;
- struct CPlex* m_pBlocks;
- int m_nBlockSize;
- CAssoc* NewAssoc();
- void FreeAssoc(CAssoc*);
- CAssoc* GetAssocAt(void*, UINT&) const;
- public:
- ~CMapPtrToWord();
- #ifdef _DEBUG
- void Dump(CDumpContext&) const;
- void AssertValid() const;
- #endif
- protected:
- // local typedefs for CTypedPtrMap class template
- typedef void* BASE_KEY;
- typedef void* BASE_ARG_KEY;
- typedef WORD BASE_VALUE;
- typedef WORD BASE_ARG_VALUE;
- };
- /////////////////////////////////////////////////////////////////////////////
- class CMapPtrToPtr : public CObject
- {
- DECLARE_DYNAMIC(CMapPtrToPtr)
- protected:
- // Association
- struct CAssoc
- {
- CAssoc* pNext;
- void* key;
- void* value;
- };
- public:
- // Construction
- CMapPtrToPtr(int nBlockSize = 10);
- // Attributes
- // number of elements
- int GetCount() const;
- BOOL IsEmpty() const;
- // Lookup
- BOOL Lookup(void* key, void*& rValue) const;
- // Operations
- // Lookup and add if not there
- void*& operator[](void* key);
- // add a new (key, value) pair
- void SetAt(void* key, void* newValue);
- // removing existing (key, ?) pair
- BOOL RemoveKey(void* key);
- void RemoveAll();
- // iterating all (key, value) pairs
- POSITION GetStartPosition() const;
- void GetNextAssoc(POSITION& rNextPosition, void*& rKey, void*& rValue) const;
- // advanced features for derived classes
- UINT GetHashTableSize() const;
- void InitHashTable(UINT hashSize, BOOL bAllocNow = TRUE);
- // Overridables: special non-virtual (see map implementation for details)
- // Routine used to user-provided hash keys
- UINT HashKey(void* key) const;
- // Implementation
- protected:
- CAssoc** m_pHashTable;
- UINT m_nHashTableSize;
- int m_nCount;
- CAssoc* m_pFreeList;
- struct CPlex* m_pBlocks;
- int m_nBlockSize;
- CAssoc* NewAssoc();
- void FreeAssoc(CAssoc*);
- CAssoc* GetAssocAt(void*, UINT&) const;
- public:
- ~CMapPtrToPtr();
- #ifdef _DEBUG
- void Dump(CDumpContext&) const;
- void AssertValid() const;
- #endif
- void* GetValueAt(void* key) const;
- protected:
- // local typedefs for CTypedPtrMap class template
- typedef void* BASE_KEY;
- typedef void* BASE_ARG_KEY;
- typedef void* BASE_VALUE;
- typedef void* BASE_ARG_VALUE;
- };
- /////////////////////////////////////////////////////////////////////////////
- class CMapWordToOb : public CObject
- {
- DECLARE_SERIAL(CMapWordToOb)
- protected:
- // Association
- struct CAssoc
- {
- CAssoc* pNext;
- WORD key;
- CObject* value;
- };
- public:
- // Construction
- CMapWordToOb(int nBlockSize = 10);
- // Attributes
- // number of elements
- int GetCount() const;
- BOOL IsEmpty() const;
- // Lookup
- BOOL Lookup(WORD key, CObject*& rValue) const;
- // Operations
- // Lookup and add if not there
- CObject*& operator[](WORD key);
- // add a new (key, value) pair
- void SetAt(WORD key, CObject* newValue);
- // removing existing (key, ?) pair
- BOOL RemoveKey(WORD key);
- void RemoveAll();
- // iterating all (key, value) pairs
- POSITION GetStartPosition() const;
- void GetNextAssoc(POSITION& rNextPosition, WORD& rKey, CObject*& rValue) const;
- // advanced features for derived classes
- UINT GetHashTableSize() const;
- void InitHashTable(UINT hashSize, BOOL bAllocNow = TRUE);
- // Overridables: special non-virtual (see map implementation for details)
- // Routine used to user-provided hash keys
- UINT HashKey(WORD key) const;
- // Implementation
- protected:
- CAssoc** m_pHashTable;
- UINT m_nHashTableSize;
- int m_nCount;
- CAssoc* m_pFreeList;
- struct CPlex* m_pBlocks;
- int m_nBlockSize;
- CAssoc* NewAssoc();
- void FreeAssoc(CAssoc*);
- CAssoc* GetAssocAt(WORD, UINT&) const;
- public:
- ~CMapWordToOb();
- void Serialize(CArchive&);
- #ifdef _DEBUG
- void Dump(CDumpContext&) const;
- void AssertValid() const;
- #endif
- protected:
- // local typedefs for CTypedPtrMap class template
- typedef WORD BASE_KEY;
- typedef WORD BASE_ARG_KEY;
- typedef CObject* BASE_VALUE;
- typedef CObject* BASE_ARG_VALUE;
- };
- /////////////////////////////////////////////////////////////////////////////
- class CMapStringToPtr : public CObject
- {
- DECLARE_DYNAMIC(CMapStringToPtr)
- protected:
- // Association
- struct CAssoc
- {
- CAssoc* pNext;
- UINT nHashValue; // needed for efficient iteration
- CString key;
- void* value;
- };
- public:
- // Construction
- CMapStringToPtr(int nBlockSize = 10);
- // Attributes
- // number of elements
- int GetCount() const;
- BOOL IsEmpty() const;
- // Lookup
- BOOL Lookup(LPCTSTR key, void*& rValue) const;
- BOOL LookupKey(LPCTSTR key, LPCTSTR& rKey) const;
- // Operations
- // Lookup and add if not there
- void*& operator[](LPCTSTR key);
- // add a new (key, value) pair
- void SetAt(LPCTSTR key, void* newValue);
- // removing existing (key, ?) pair
- BOOL RemoveKey(LPCTSTR key);
- void RemoveAll();
- // iterating all (key, value) pairs
- POSITION GetStartPosition() const;
- void GetNextAssoc(POSITION& rNextPosition, CString& rKey, void*& rValue) const;
- // advanced features for derived classes
- UINT GetHashTableSize() const;
- void InitHashTable(UINT hashSize, BOOL bAllocNow = TRUE);
- // Overridables: special non-virtual (see map implementation for details)
- // Routine used to user-provided hash keys
- UINT HashKey(LPCTSTR key) const;
- // Implementation
- protected:
- CAssoc** m_pHashTable;
- UINT m_nHashTableSize;
- int m_nCount;
- CAssoc* m_pFreeList;
- struct CPlex* m_pBlocks;
- int m_nBlockSize;
- CAssoc* NewAssoc();
- void FreeAssoc(CAssoc*);
- CAssoc* GetAssocAt(LPCTSTR, UINT&) const;
- public:
- ~CMapStringToPtr();
- #ifdef _DEBUG
- void Dump(CDumpContext&) const;
- void AssertValid() const;
- #endif
- protected:
- // local typedefs for CTypedPtrMap class template
- typedef CString BASE_KEY;
- typedef LPCTSTR BASE_ARG_KEY;
- typedef void* BASE_VALUE;
- typedef void* BASE_ARG_VALUE;
- };
- /////////////////////////////////////////////////////////////////////////////
- class CMapStringToOb : public CObject
- {
- DECLARE_SERIAL(CMapStringToOb)
- protected:
- // Association
- struct CAssoc
- {
- CAssoc* pNext;
- UINT nHashValue; // needed for efficient iteration
- CString key;
- CObject* value;
- };
- public:
- // Construction
- CMapStringToOb(int nBlockSize = 10);
- // Attributes
- // number of elements
- int GetCount() const;
- BOOL IsEmpty() const;
- // Lookup
- BOOL Lookup(LPCTSTR key, CObject*& rValue) const;
- BOOL LookupKey(LPCTSTR key, LPCTSTR& rKey) const;
- // Operations
- // Lookup and add if not there
- CObject*& operator[](LPCTSTR key);
- // add a new (key, value) pair
- void SetAt(LPCTSTR key, CObject* newValue);
- // removing existing (key, ?) pair
- BOOL RemoveKey(LPCTSTR key);
- void RemoveAll();
- // iterating all (key, value) pairs
- POSITION GetStartPosition() const;
- void GetNextAssoc(POSITION& rNextPosition, CString& rKey, CObject*& rValue) const;
- // advanced features for derived classes
- UINT GetHashTableSize() const;
- void InitHashTable(UINT hashSize, BOOL bAllocNow = TRUE);
- // Overridables: special non-virtual (see map implementation for details)
- // Routine used to user-provided hash keys
- UINT HashKey(LPCTSTR key) const;
- // Implementation
- protected:
- CAssoc** m_pHashTable;
- UINT m_nHashTableSize;
- int m_nCount;
- CAssoc* m_pFreeList;
- struct CPlex* m_pBlocks;
- int m_nBlockSize;
- CAssoc* NewAssoc();
- void FreeAssoc(CAssoc*);
- CAssoc* GetAssocAt(LPCTSTR, UINT&) const;
- public:
- ~CMapStringToOb();
- void Serialize(CArchive&);
- #ifdef _DEBUG
- void Dump(CDumpContext&) const;
- void AssertValid() const;
- #endif
- protected:
- // local typedefs for CTypedPtrMap class template
- typedef CString BASE_KEY;
- typedef LPCTSTR BASE_ARG_KEY;
- typedef CObject* BASE_VALUE;
- typedef CObject* BASE_ARG_VALUE;
- };
- /////////////////////////////////////////////////////////////////////////////
- class CMapStringToString : public CObject
- {
- DECLARE_SERIAL(CMapStringToString)
- protected:
- // Association
- struct CAssoc
- {
- CAssoc* pNext;
- UINT nHashValue; // needed for efficient iteration
- CString key;
- CString value;
- };
- public:
- // Construction
- CMapStringToString(int nBlockSize = 10);
- // Attributes
- // number of elements
- int GetCount() const;
- BOOL IsEmpty() const;
- // Lookup
- BOOL Lookup(LPCTSTR key, CString& rValue) const;
- BOOL LookupKey(LPCTSTR key, LPCTSTR& rKey) const;
- // Operations
- // Lookup and add if not there
- CString& operator[](LPCTSTR key);
- // add a new (key, value) pair
- void SetAt(LPCTSTR key, LPCTSTR newValue);
- // removing existing (key, ?) pair
- BOOL RemoveKey(LPCTSTR key);
- void RemoveAll();
- // iterating all (key, value) pairs
- POSITION GetStartPosition() const;
- void GetNextAssoc(POSITION& rNextPosition, CString& rKey, CString& rValue) const;
- // advanced features for derived classes
- UINT GetHashTableSize() const;
- void InitHashTable(UINT hashSize, BOOL bAllocNow = TRUE);
- // Overridables: special non-virtual (see map implementation for details)
- // Routine used to user-provided hash keys
- UINT HashKey(LPCTSTR key) const;
- // Implementation
- protected:
- CAssoc** m_pHashTable;
- UINT m_nHashTableSize;
- int m_nCount;
- CAssoc* m_pFreeList;
- struct CPlex* m_pBlocks;
- int m_nBlockSize;
- CAssoc* NewAssoc();
- void FreeAssoc(CAssoc*);
- CAssoc* GetAssocAt(LPCTSTR, UINT&) const;
- public:
- ~CMapStringToString();
- void Serialize(CArchive&);
- #ifdef _DEBUG
- void Dump(CDumpContext&) const;
- void AssertValid() const;
- #endif
- protected:
- // local typedefs for CTypedPtrMap class template
- typedef CString BASE_KEY;
- typedef LPCTSTR BASE_ARG_KEY;
- typedef CString BASE_VALUE;
- typedef LPCTSTR BASE_ARG_VALUE;
- };
- #ifdef _AFX_PACKING
- #pragma pack(pop)
- #endif
- #ifndef __AFXSTATE_H__
- #include <afxstat_.h> // for MFC private state structures
- #endif
- /////////////////////////////////////////////////////////////////////////////
- // Inline function declarations
- #ifdef _AFX_ENABLE_INLINES
- #define _AFXCOLL_INLINE AFX_INLINE
- #include <afxcoll.inl>
- #endif
- #undef AFX_DATA
- #define AFX_DATA
- #ifdef _AFX_MINREBUILD
- #pragma component(minrebuild, on)
- #endif
- #ifndef _AFX_FULLTYPEINFO
- #pragma component(mintypeinfo, off)
- #endif
- #endif //!__AFXCOLL_H__
- /////////////////////////////////////////////////////////////////////////////
|