By Robert S. Gray

Dr. Dobb's Journal March 1997

 ...
class DoublyLinkedList
{
public:
	DoublyLinkedList()
	{
		head = tail = 				    &sentinal;
	}
	// The next line will no longer work after realloc
	// byte copies this object!
	bool isEmpty() const { return head == &sentinal; }
	...
private:
	DoublyLinkedElement	sentinal;
	DoublyLinkedElement	*head, *tail;
	...
};
  ...

Example 2: Avoiding special-case comparisons.

Back to Article


Copyright © 1997, Dr. Dobb's Journal