DoublyLinkedList.h #3

  • //
  • guest/
  • perforce_software/
  • p4api.net/
  • p4bridge/
  • DoublyLinkedList.h
  • View
  • Commits
  • Open Download .zip Download (1 KB)
#pragma once

//forward references
class DoublyLinkedList;
class ILockable;

class DoublyLinkedListItem
{
	friend class DoublyLinkedList;

private:
	DoublyLinkedListItem(void){};

public:
	DoublyLinkedListItem(DoublyLinkedList *list);
	DoublyLinkedListItem(DoublyLinkedList *list, int id);
	virtual ~DoublyLinkedListItem(void);
	
	// Id
	int  Id;

	DoublyLinkedListItem* Next() { return pNextItem;}
	DoublyLinkedListItem* Prev() { return pPrevItem;}

protected:
	// doubly linked list of objects of a given type
	DoublyLinkedListItem* pNextItem;
	DoublyLinkedListItem* pPrevItem;

	DoublyLinkedList *pList;
};

class DoublyLinkedList
{
private:
	DoublyLinkedList(void){};

public:
	DoublyLinkedList(ILockable* locker);
	virtual ~DoublyLinkedList(void);
	
	void Add(DoublyLinkedListItem* object);
	void Remove(DoublyLinkedListItem* object, int deleteObj = 1);

	void Remove(int Id);

	DoublyLinkedListItem* Find(int Id);
	const DoublyLinkedListItem* First() const { return pFirstItem;}

	int Count() { return itemCount; }
	//CRITICAL_SECTION CriticalSection; 

protected:
	// Maintain a list of items
	DoublyLinkedListItem* pFirstItem;
	DoublyLinkedListItem* pLastItem;

	int disposed;
	int itemCount;

	ILockable* Locker;
};
# Change User Description Committed
#5 19042 Liz Lam Rename/move file(s) to proper main branch.
#4 11220 Matt Attaway Update Workshop version with most recent 14.2 patch of p4api.net
#3 10191 Matt Attaway Bring Workshop version of p4api.net up-to-date with the 14.2 release.
#2 8964 Bill fix line endings
#1 8873 Matt Attaway Initial add of the P4API.NET source code