GenericListNode.cpp

From Giona

(Difference between revisions)
Line 25: Line 25:
GenericListNode::~GenericListNode()
GenericListNode::~GenericListNode()
{
{
-
if(this->next)
 
-
delete(this->next);
 
if(this->elem)
if(this->elem)
delete(this->elem);
delete(this->elem);

Revision as of 15:49, 20 June 2007

/*
 * GenericListNode.cpp
 * ===================
 * 
 * Generic List Node for a Linked List
 */

#include <iostream.h>
#include <stdio.h>
#include "GenericListNode.h"

/*
 * Constructor
 */
GenericListNode::GenericListNode()
{
	this->next = NULL;
	this->elem = NULL;
}

/*
 * Destructor
 */
GenericListNode::~GenericListNode()
{
	if(this->elem)
		delete(this->elem);
}

/*
 * Sets the element of the node
 */
void GenericListNode::setElem(genericListElemT elem)
{
	this->elem = elem;
}

/*
 * Returns the element of the node
 */
genericListElemT GenericListNode::getElem()
{
	return this->elem;
}

/*
 * Sets next node in the list
 */
void GenericListNode::setNext(GenericListNode *next)
{
	this->next = next;
}

/*
 * Returns next node in the list
 */
GenericListNode* GenericListNode::getNext()
{
	return this->next;
}
Personal tools