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

📄 collectionintf.h

📁 COM实现的源码 COM初学者用 大家多发些COM的文件  共同进步啊
💻 H
字号:
//	CollectionIntf.h Created by Posy at May, 2001
//	for interface of Collection

#ifndef _COLLECTIONINTF_H_
#define _COLLECTIONINTF_H_

#include <ObjectModel/PosyInterface.h>

#define COLPOS ULONG

BEGIN_INTERFACE_DECLARATION(ICollection, (SYSTEM_INTERFACE_NUMBER + 1))
	//	Functions for insertion, removal and basic information
	virtual LONG GetCount() const = 0;

	//	Functions for random access
	virtual COLPOS GetPosAt(LONG nIndex) const = 0;

	//	Functions for iteration
	virtual COLPOS GetHeadPos() const = 0;
	virtual COLPOS GetTailPos() const = 0;
	virtual BOOL GetNext(COLPOS &nPos, void** ppIntf, INN nInN = IN_IBase) const = 0;
	virtual BOOL GetPrev(COLPOS &nPos, void** ppIntf, INN nInN = IN_IBase) const = 0;
	virtual BOOL GetAtPos(COLPOS nPos, void** ppIntf, INN nInN = IN_IBase) const = 0;
	virtual BOOL SetAtPos(COLPOS nPos, IBase *pIntf) = 0;

	virtual BOOL InsertBeforePos(COLPOS &nPos, IBase *pIntf) = 0;
	virtual BOOL InsertAfterPos(COLPOS &nPos, IBase *pIntf) = 0;
	virtual BOOL RemoveAtPos(COLPOS nPos) = 0;

	//	Some useful macro functions
	virtual BOOL IsEmpty() const
	{
		if (GetCount())
			return FALSE;
		return TRUE;
	};
	virtual BOOL InsertAt(LONG nIndex, IBase *pIntf)
	{
		if (nIndex <= 0)
			return InsertHead(pIntf);
		else if (nIndex >= GetCount())
			return InsertTail(pIntf);
		else
		{
			COLPOS nPos = GetPosAt(nIndex);
			return InsertBeforePos(nPos, pIntf);
		}
		return FALSE;
	};
	virtual BOOL RemoveAt(LONG nIndex)
	{
		COLPOS nPos = GetPosAt(nIndex);
		if (nPos)
			return RemoveAtPos(nPos);
		return FALSE;
	};
	virtual BOOL GetAt(LONG nIndex, void** ppIntf, INN nInN = IN_IBase) const
	{
		COLPOS nPos = GetPosAt(nIndex);
		if (nPos)
			return GetAtPos(nPos, ppIntf, nInN);
		return FALSE;
	};
	virtual BOOL SetAt(LONG nIndex, IBase *pIntf)
	{
		COLPOS nPos = GetPosAt(nIndex);
		if (nPos)
			return SetAtPos(nPos, pIntf);
		return FALSE;
	};
	virtual BOOL InsertHead(IBase *pIntf)
	{
		COLPOS nPos = GetHeadPos();
		if (nPos || IsEmpty())
			return InsertBeforePos(nPos, pIntf);
		return FALSE;
	};
	virtual BOOL InsertTail(IBase *pIntf)
	{
		COLPOS nPos = GetTailPos();
		if (nPos || IsEmpty())
			return InsertAfterPos(nPos, pIntf);
		return FALSE;
	};
	virtual BOOL RemoveHead()
	{
		COLPOS nPos = GetHeadPos();
		if (nPos)
			return RemoveAtPos(nPos);
		return FALSE;
	};
	virtual BOOL RemoveTail()
	{
		COLPOS nPos = GetTailPos();
		if (nPos)
			return RemoveAtPos(nPos);
		return FALSE;
	};
	virtual BOOL GetHead(void** ppIntf, INN nInN = IN_IBase) const
	{
		COLPOS nPos = GetHeadPos();
		if (nPos)
			return GetAtPos(nPos, ppIntf, nInN);
		return FALSE;
	};
	virtual BOOL GetTail(void** ppIntf, INN nInN = IN_IBase) const
	{
		COLPOS nPos = GetTailPos();
		if (nPos)
			return GetAtPos(nPos, ppIntf, nInN);
		return FALSE;
	};
	virtual BOOL Empty(BOOL bDestroy = FALSE)
	{
		while (!IsEmpty())
		{
			if (bDestroy)
			{
				IBase *pItem = NULL;
				GetTail((void**)&pItem);
				if (pItem)
					pItem->DestroyInstance();
			}
			if (!RemoveTail())
				return FALSE;
		}
		return TRUE;
	};
END_INTERFACE_DECLARATION()

#endif	//_COLLECTIONINTF_H_

⌨️ 快捷键说明

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