// $Id: collection.cc,v 1.4 2003/04/23 09:20:58 ta_muto Exp $

#include <collection.h>

wax::ICursor::~ICursor()
{
	if(next != NULL)	delete next;
}

wax::CCollection::~CCollection()
{
	if(reference == false) {
		if(head != NULL)	delete head;
	}
}

void wax::CCollection::insertAfter(ICursor* cursor, ICursor* item)
{
	item->setNext(cursor->getNext());
	cursor->setNext(item);
}

void wax::CCollection::addItem(ICursor* item)
{
	if(last == NULL) {
		head = item;
		last = item;
	} else {
		last->setNext(item);
		last = item;
	}
}

void wax::CCollection::removeAll()
{
	if(head != NULL)	delete head;
	head = NULL;
	last = NULL;
}
