⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ngsortableoblist.h

📁 ResOrg 图形化管理Vc项目的资源ID的工具的源代码。 ResOrg - Manage and Renumber Resource Symbol IDs Introduction The
💻 H
字号:
#ifndef __NGSortableObList_H__

#define __NGSortableObList_H__

// NGSortableObList.h
/////////////////////////////////////////////////////////////////////

class NGLIB_EXT_CLASS	CNGSortableObList : public CObList
{
public:
	CNGSortableObList(int nBlockSize = 10) : CObList(nBlockSize) { }

	void Sort(int(*CompareFunc)(CObject* pFirstObj, CObject*pSecondObj));
	void Sort(POSITION posStart, int iElements, int (*CompareFunc)(CObject* pFirstObj, CObject* pSecondObj));
};


template< class TYPE >
class CNGTypedSortableObList : public CNGSortableObList
{
public:
// Construction
	CNGTypedSortableObList(int nBlockSize = 10) : CNGSortableObList(nBlockSize) { }

	// peek at head or tail
	TYPE& GetHead()
		{ return (TYPE&)CNGSortableObList::GetHead(); }

	TYPE GetHead() const
		{ return (TYPE)CNGSortableObList::GetHead(); }

	TYPE& GetTail()
		{ return (TYPE&)CNGSortableObList::GetTail(); }

	TYPE GetTail() const
		{ return (TYPE)CNGSortableObList::GetTail(); }

	// get head or tail (and remove it) - don't call on empty list!
	TYPE RemoveHead()
		{ return (TYPE)CNGSortableObList::RemoveHead(); }
	TYPE RemoveTail()
		{ return (TYPE)CNGSortableObList::RemoveTail(); }

	// add before head or after tail
	POSITION AddHead(TYPE newElement)
		{ return CNGSortableObList::AddHead( static_cast<CObject*>(newElement) ); }

	POSITION AddTail(TYPE newElement)
		{ return CNGSortableObList::AddTail( static_cast<CObject*>(newElement) ); }

	// add another list of elements before head or after tail
	void AddHead(CNGTypedSortableObList< TYPE >* pNewList)
		{ CNGSortableObList::AddHead(pNewList); }

	void AddTail(CNGTypedSortableObList< TYPE >* pNewList)
		{ CNGSortableObList::AddTail(pNewList); }

	// iteration
	TYPE& GetNext(POSITION& rPosition)
		{ return (TYPE&)CNGSortableObList::GetNext(rPosition); }

	TYPE GetNext(POSITION& rPosition) const
		{ return (TYPE)CNGSortableObList::GetNext(rPosition); }

	TYPE& GetPrev(POSITION& rPosition)
		{ return (TYPE&)CNGSortableObList::GetPrev(rPosition); }

	TYPE GetPrev(POSITION& rPosition) const
		{ return (TYPE)CNGSortableObList::GetPrev(rPosition); }

	// getting/modifying an element at a given position
	TYPE& GetAt(POSITION position)
		{ return (TYPE&)CNGSortableObList::GetAt(position); }

	TYPE GetAt(POSITION position) const
		{ return (TYPE)CNGSortableObList::GetAt(position); }

	void SetAt(POSITION pos, TYPE newElement)
		{ CNGSortableObList::SetAt(pos, static_cast<TYPE>(newElement) ); }

	void Sort( int(*CompareFunc)(TYPE pFirstObj, TYPE pSecondObj) )
		{ CNGSortableObList::Sort((int(*)(CObject*,CObject*))CompareFunc); }

	void Sort( POSITION posStart, int iElements, int(*CompareFunc)(TYPE pFirstObj, TYPE pSecondObj) )
		{ CNGSortableObList::Sort(posStart, iElements, (int(*)(CObject*,CObject*))CompareFunc); }
};


#endif __NGSortableObList_H__

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -