Return to Snippet

Revision: 9031
at October 17, 2008 22:57 by itsok2kry


Updated Code
#include "LinkedNode.h"
#include "LinkedList.h"

// linked node functions

//constructor
template < class T >
LinkedNode< T >::LinkedNode( LinkedList< T > plist, LinkedNode< T > pNode, T * val )
{
	// set our values, our associated list, and our previous node
	value = *val;
	list = plist;
	previousNode = pNode;

	previousNode->setNextNode( this );
}

// return the next node
template < class T >
LinkedNode< T > * LinkedNode< T >::next( void )
{
	return nextNode;
}

// return previous node
template < class T >
LinkedNode< T > * LinkedNode< T >::previous( void )
{
	return previousNode;
}

//return our value
template < class T >
T LinkedNode< T >::getValue( void )
{
	return &value;
}

// set our next node (this is called by the next node to be set up)
template < class T >
void LinkedNode< T >::setNextNode( LinkedNode< T > next )
{
	nextNode = &next;
}

Revision: 9030
at October 17, 2008 19:20 by itsok2kry


Updated Code
class LinkedList;

template < class T >
class LinkedNode
{
	private:
		T value; // our generic value
		LinkedList * list; // the linked list we're part of
		LinkedNode< T > * previousNode; // the previous node
		LinkedNode< T > * nextNode; // the next node

	public:
		LinkedNode( LinkedList plist, LinkedNode< T > pNode, T * val ); // constructor
		LinkedNode< T > * next( void ); // return the next node
		LinkedNode< T > * previous( void ); // return the previous node
		T getValue( void ); // return the value we're holding
		void setNextNode( LinkedNode< T > next );

};

//constructor
template < class T >
LinkedNode< T >::LinkedNode( LinkedList plist, LinkedNode< T > pNode, T * val )
{
	// set our values, our associated list, and our previous node
	value = *val;
	list = plist;
	previousNode = pNode;

	previousNode->setNextNode( this );
}

// return the next node
template < class T >
LinkedNode< T > * LinkedNode< T >::next( void )
{
	return nextNode;
}

// return previous node
template < class T >
LinkedNode< T > * LinkedNode< T >::previous( void )
{
	return previousNode;
}

//return our value
template < class T >
T LinkedNode< T >::getValue( void )
{
	return &value;
}

// set our next node (this is called by the next node to be set up)
template < class T >
void LinkedNode< T >::setNextNode( LinkedNode< T > next )
{
	nextNode = &next;
}

Revision: 9029
at October 17, 2008 17:37 by itsok2kry


Updated Code
class LinkedList;

template < class T >
class LinkedNode
{
	private:
		T value; // our generic value
		LinkedList< T > * list; // the linked list we're part of
		LinkedNode< T > * previousNode; // the previous node
		LinkedNode< T > * nextNode; // the next node

	public:
		LinkedNode( &LinkedList list, &LinkedNode< T > previousNode, T val ); // constructor
		LinkedNode< T > * next( void ); // return the next node
		LinkedNode< T > * previous( void ); // return the previous node
		T * value( void ); // return the value we're holding
		void setNextNode( &LinkedNode< T > next );

};

//constructor
template < class T >
LinkedNode< T >::LinkedNode( &LinkedList list, &LinkedNode< T > previousNode, T * val )
{
	// set our values, our associated list, and our previous node
	this->value = *val;
	this->list = list;
	this->previousNode = previousNode;

	this->previousNode->setNextNode( this );
}

// return the next node
template < class T >
LinkedNode< T > * LinkedNode< T >::next( void )
{
	return this->nextNode;
}

// return previous node
template < class T >
LinkedNode< T > * LinkedNode< T >::previous( void )
{
	return this->previousNode;
}

//return our value
T * LinkedNode::value( void )
{
	return &this->value;
}

// set our next node (this is called by the next node to be set up)
void LinkedNode::setNextNode( &LinkedNode< T > next )
{
	this->nextNode = next;
}

Revision: 9028
at October 17, 2008 16:38 by itsok2kry


Initial Code
class LinkedList;

template < class T >
class LinkedNode
{
	private:
		T value; // our generic value
		LinkedList< T > * list; // the linked list we're part of
		LinkedNode< T > * previousNode; // the previous node
		LinkedNode< T > * nextNode; // the next node

	public:
		LinkedNode( &LinkedList list, &LinkedNode< T > previousNode, T val ); // constructor
		LinkedNode< T > * next( void ); // return the next node
		LinkedNode< T > * previous( void ); // return the previous node
		T * value( void ); // return the value we're holding
		void setNextNode( &LinkedNode< T > next );

};

//constructor
template < class T >
LinkedNode< T >::LinkedNode( &LinkedList list, &LinkedNode< T > previousNode, T * val )
{
	// set our values, our associated list, and our previous node
	this->value = *val;
	this->list = list;
	this->previousNode = previousNode;

	this->previousNode->setNextNode( this );
}

// return the next node
template < class T >
LinkedNode< T > * LinkedNode::next( void )
{
	return this->nextNode;
}

// return previous node
template < class T >
LinkedNode< T > * LinkedNode::previous( void )
{
	return this->previousNode;
}

//return our value
T * LinkedNode::value( void )
{
	return &this->value;
}

// set our next node (this is called by the next node to be set up)
void LinkedNode::setNextNode( &LinkedNode< T > next )
{
	this->nextNode = next;
}

Initial URL

                                

Initial Description
Not working.

Initial Title
Linked List (LinkedNode.cpp)

Initial Tags

                                

Initial Language
C++