Rudiments
Public Member Functions
linkedlist< datatype, linkedlistnodetype > Class Template Reference

Inherited by dictionarylist< char *, datatype >, dictionarylist< const char *, datatype >, and dictionarylist< int32_t, datatype >.

List of all members.

Public Member Functions

 linkedlist ()
virtual ~linkedlist ()
void append (datatype data)
void append (linkedlistnodetype *node)
bool insert (uint64_t index, datatype data)
bool insert (uint64_t index, linkedlistnodetype *node)
bool removeByIndex (uint64_t index)
bool removeByData (datatype data)
bool removeAllByData (datatype data)
bool removeNode (linkedlistnodetype *node)
bool setDataByIndex (uint64_t index, datatype data)
bool getDataByIndex (uint64_t index, datatype *data)
uint64_t getLength () const
linkedlistnodetype * getFirstNode ()
linkedlistnodetype * getLastNode ()
linkedlistnodetype * getNodeByIndex (uint64_t index)
linkedlistnodetype * getNodeByData (datatype data)
linkedlistnodetype * getNodeByData (linkedlistnodetype *startnode, datatype data)
void clear ()
void print () const

Detailed Description

template<class datatype, class linkedlistnodetype = linkedlistnode<datatype>>
class linkedlist< datatype, linkedlistnodetype >

The linkedlist class allows you to store arbitrary amounts of data in a doubly-linked list. Since the linkedlist class is template-based, you can store arbitrary types of data as well.

Each linkedlist is composed of a series of linkedlistnode's. Each linkedlistnode contains the data.


Constructor & Destructor Documentation

template<class datatype, class linkedlistnodetype = linkedlistnode<datatype>>
linkedlist< datatype, linkedlistnodetype >::linkedlist ( )

Creates an empty instance of the linkedlist class.

template<class datatype, class linkedlistnodetype = linkedlistnode<datatype>>
virtual linkedlist< datatype, linkedlistnodetype >::~linkedlist ( ) [virtual]

Deletes this instance of the linkedlist class and all of its linkedlistnodes. Note however, that the daata stored in each linkedlistnode is not deleted by this call.


Member Function Documentation

template<class datatype, class linkedlistnodetype = linkedlistnode<datatype>>
void linkedlist< datatype, linkedlistnodetype >::append ( datatype  data)

Creates a new linkedlistnode containing "data" and appends it to the linkedlist.

template<class datatype, class linkedlistnodetype = linkedlistnode<datatype>>
void linkedlist< datatype, linkedlistnodetype >::append ( linkedlistnodetype *  node)

Appends already created linkedlistnode "node" to the linkedlist.

template<class datatype, class linkedlistnodetype = linkedlistnode<datatype>>
void linkedlist< datatype, linkedlistnodetype >::clear ( )

Deletes all linkedlistnodes currently in the linkedlist. Note however, that the daata stored in each linkedlistnode is not deleted by this call.

template<class datatype, class linkedlistnodetype = linkedlistnode<datatype>>
bool linkedlist< datatype, linkedlistnodetype >::getDataByIndex ( uint64_t  index,
datatype *  data 
)

Returns the data contained in the linkedlistnode at "index".

Returns true on success and false on failure.

template<class datatype, class linkedlistnodetype = linkedlistnode<datatype>>
linkedlistnodetype* linkedlist< datatype, linkedlistnodetype >::getFirstNode ( )

Returns the first node in the linkedlist.

template<class datatype, class linkedlistnodetype = linkedlistnode<datatype>>
linkedlistnodetype* linkedlist< datatype, linkedlistnodetype >::getLastNode ( )

Returns the last node in the linkedlist.

template<class datatype, class linkedlistnodetype = linkedlistnode<datatype>>
uint64_t linkedlist< datatype, linkedlistnodetype >::getLength ( ) const

Returns the number of nodes in the linkedlist.

template<class datatype, class linkedlistnodetype = linkedlistnode<datatype>>
linkedlistnodetype* linkedlist< datatype, linkedlistnodetype >::getNodeByData ( linkedlistnodetype *  startnode,
datatype  data 
)

Returns a pointer to the firs linkedlistnode after "startnode" containing "data".

template<class datatype, class linkedlistnodetype = linkedlistnode<datatype>>
linkedlistnodetype* linkedlist< datatype, linkedlistnodetype >::getNodeByData ( datatype  data)

Returns a pointer to the first linkedlistnode containing "data".

template<class datatype, class linkedlistnodetype = linkedlistnode<datatype>>
linkedlistnodetype* linkedlist< datatype, linkedlistnodetype >::getNodeByIndex ( uint64_t  index)

Returns a pointer to the linkedlistnode at "index".

template<class datatype, class linkedlistnodetype = linkedlistnode<datatype>>
bool linkedlist< datatype, linkedlistnodetype >::insert ( uint64_t  index,
datatype  data 
)

Creates a new linkedlistnode containing "data" and inserts it into the linkedlist at "index".

Returns true on success and false on failure.

template<class datatype, class linkedlistnodetype = linkedlistnode<datatype>>
bool linkedlist< datatype, linkedlistnodetype >::insert ( uint64_t  index,
linkedlistnodetype *  node 
)

Inserts already created linkedlistnode "node" into the linkedlist at "index".

Returns true on success and false on failure.

template<class datatype, class linkedlistnodetype = linkedlistnode<datatype>>
void linkedlist< datatype, linkedlistnodetype >::print ( ) const

Prints out a representation of the linkedlist.

template<class datatype, class linkedlistnodetype = linkedlistnode<datatype>>
bool linkedlist< datatype, linkedlistnodetype >::removeAllByData ( datatype  data)

Deletes all linkedlistnodes containing "data".

Returns true on success and false on failure.

template<class datatype, class linkedlistnodetype = linkedlistnode<datatype>>
bool linkedlist< datatype, linkedlistnodetype >::removeByData ( datatype  data)

Deletes the first linkedlistnode containing "data".

Returns true on success and false on failure.

template<class datatype, class linkedlistnodetype = linkedlistnode<datatype>>
bool linkedlist< datatype, linkedlistnodetype >::removeByIndex ( uint64_t  index)

Deletes the linkedlistnode at "index".

Returns true on success and false on failure.

template<class datatype, class linkedlistnodetype = linkedlistnode<datatype>>
bool linkedlist< datatype, linkedlistnodetype >::removeNode ( linkedlistnodetype *  node)

Removed linkedlistnode "node" from the linkedlist.

Returns true on success and false on failure.

template<class datatype, class linkedlistnodetype = linkedlistnode<datatype>>
bool linkedlist< datatype, linkedlistnodetype >::setDataByIndex ( uint64_t  index,
datatype  data 
)

Sets the data contained in the linkedlistnode at "index" to "data".

Returns true on success and false on failure.