Rudiments
Public Member Functions | List of all members
linkedlist< valuetype > Class Template Reference

Inherits listcollection< valuetype >.

Public Member Functions

 linkedlist ()
 
 linkedlist (linkedlist< valuetype > &a)
 
 linkedlist (nodecollection< valuetype > &a)
 
linkedlist< valuetype > & operator= (linkedlist< valuetype > &a)
 
linkedlist< valuetype > & operator= (nodecollection< valuetype > &a)
 
 ~linkedlist ()
 
void prepend (valuetype value)
 
void prepend (listnode< valuetype > *node)
 
void append (valuetype value)
 
void append (listnode< valuetype > *node)
 
void insertBefore (listnode< valuetype > *node, valuetype value)
 
void insertBefore (listnode< valuetype > *node, listnode< valuetype > *newnode)
 
void insertAfter (listnode< valuetype > *node, valuetype value)
 
void insertAfter (listnode< valuetype > *node, listnode< valuetype > *newnode)
 
void moveBefore (listnode< valuetype > *node, listnode< valuetype > *nodetomove)
 
void moveAfter (listnode< valuetype > *node, listnode< valuetype > *nodetomove)
 
void detach (listnode< valuetype > *node)
 
bool remove (valuetype value)
 
bool removeAll (valuetype value)
 
bool remove (listnode< valuetype > *node)
 
uint64_t getCount ()
 
listnode< valuetype > * getFirst ()
 
listnode< valuetype > * getLast ()
 
listnode< valuetype > * getPrevious (listnode< valuetype > *node)
 
listnode< valuetype > * getNext (listnode< valuetype > *node)
 
listnode< valuetype > * find (valuetype value)
 
listnode< valuetype > * find (listnode< valuetype > *startnode, valuetype value)
 
void sortInexpensively ()
 
void sortQuickly ()
 
bool clear ()
 
- Public Member Functions inherited from listcollection< valuetype >
 listcollection ()
 
 listcollection (nodecollection< valuetype > &n)
 
virtual const char * getType ()
 
virtual void prepend (valuetype *values, uint64_t count)
 
virtual void append (valuetype *values, uint64_t count)
 
virtual void insertBefore (listnode< valuetype > *node, valuetype *values, uint64_t count)
 
virtual void insertAfter (listnode< valuetype > *node, valuetype *values, uint64_t count)
 
virtual ssize_t write ()
 
virtual ssize_t write (output *out)
 
virtual ssize_t writeJson ()
 
virtual ssize_t writeJson (bool indent)
 
virtual ssize_t writeJson (output *out)
 
virtual ssize_t writeJson (output *out, bool indent)
 
- Public Member Functions inherited from collection
 collection ()
 
 collection (collection &c)
 
collectionoperator= (collection &c)
 
virtual ~collection ()
 
comparatorgetComparator ()
 
void setComparator (comparator *newcomp)
 
virtual bool isReadOnly ()
 
virtual bool isBlockBased ()
 
virtual uint64_t getBlockSize ()
 
virtual bool isSequentialAccess ()
 
virtual void setManageValues (bool manage)
 
virtual bool getManageValues ()
 
virtual void setManageArrayValues (bool manage)
 
virtual bool getManageArrayValues ()
 
virtual void setManageKeys (bool manage)
 
virtual bool getManageKeys ()
 
virtual void setManageArrayKeys (bool manage)
 
virtual bool getManageArrayKeys ()
 
- Public Member Functions inherited from object
virtual ~object ()
 

Detailed Description

template<class valuetype>
class linkedlist< valuetype >

The linkedlist class allows you to store an arbitrary number of values in a doubly-linked list. Since the linkedlist class is template-based, you can store arbitrary types of values.

Each linkedlist is composed of a series of linkedlistnodes. Each linkedlistnode contains a value.

Constructor & Destructor Documentation

◆ linkedlist() [1/3]

template<class valuetype >
linkedlist< valuetype >::linkedlist
inline

Creates an empty instance of the linkedlist class.

◆ linkedlist() [2/3]

template<class valuetype >
linkedlist< valuetype >::linkedlist ( linkedlist< valuetype > &  a)
inline

Creates an instance of the linkedlist class that is a copy of "a".

◆ linkedlist() [3/3]

template<class valuetype >
linkedlist< valuetype >::linkedlist ( nodecollection< valuetype > &  a)
inline

Creates an instance of the linkedlist class that is a copy of "a".

◆ ~linkedlist()

template<class valuetype >
linkedlist< valuetype >::~linkedlist
inline

Deletes this instance of the linkedlist class and all of its linkedlistnodes.

The value stored in each linkedlistnode is only deleted if setManageValues(true) or setManageArrayValues(true) has been called.

Member Function Documentation

◆ append() [1/2]

template<class valuetype >
void linkedlist< valuetype >::append ( listnode< valuetype > *  node)
inlinevirtual

Appends already created linkedlistnode "node" to the linkedlist.

Implements listcollection< valuetype >.

◆ append() [2/2]

template<class valuetype >
void linkedlist< valuetype >::append ( valuetype  value)
inlinevirtual

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

Implements listcollection< valuetype >.

◆ clear()

template<class valuetype >
bool linkedlist< valuetype >::clear
inlinevirtual

Deletes all linkedlistnodes currently in the linkedlist.

The value stored in each linkedlistnode is only deleted if setManageValues(true) or setManageArrayValues(true) has been called.

Always returns true.

Implements collection.

◆ detach()

template<class valuetype >
void linkedlist< valuetype >::detach ( listnode< valuetype > *  node)
inlinevirtual

Detaches "node" from the list.

Implements listcollection< valuetype >.

◆ find() [1/2]

template<class valuetype >
listnode< valuetype > * linkedlist< valuetype >::find ( listnode< valuetype > *  startnode,
valuetype  value 
)
inlinevirtual

Returns a pointer to the first linkedlistnode after "startnode" containing "value" or NULL if "value" was not found.

Implements listcollection< valuetype >.

◆ find() [2/2]

template<class valuetype >
listnode< valuetype > * linkedlist< valuetype >::find ( valuetype  value)
inlinevirtual

Returns a pointer to the first linkedlistnode containing "value" or NULL if "value" was not found.

Implements listcollection< valuetype >.

◆ getCount()

template<class valuetype >
uint64_t linkedlist< valuetype >::getCount
inlinevirtual

Returns the number of nodes in the linkedlist.

Implements collection.

◆ getFirst()

template<class valuetype >
listnode< valuetype > * linkedlist< valuetype >::getFirst
inlinevirtual

Returns the first node in the linkedlist.

Implements listcollection< valuetype >.

◆ getLast()

template<class valuetype >
listnode< valuetype > * linkedlist< valuetype >::getLast
inline

Returns the last node in the linkedlist.

◆ getNext()

template<class valuetype >
listnode< valuetype > * linkedlist< valuetype >::getNext ( listnode< valuetype > *  node)
inlinevirtual

Returns the node after "node" or NULL if this node is the last node in the list. "node" is presumed to be in the list.

Implements listcollection< valuetype >.

◆ getPrevious()

template<class valuetype >
listnode< valuetype > * linkedlist< valuetype >::getPrevious ( listnode< valuetype > *  node)
inline

Returns the node prior to "node" or NULL if this node is the first node in the list. "node" is presumed to be in the list.

◆ insertAfter() [1/2]

template<class valuetype >
void linkedlist< valuetype >::insertAfter ( listnode< valuetype > *  node,
listnode< valuetype > *  newnode 
)
inlinevirtual

Inserts already created linkedlistnode "newnode" into the linkedlist after "node".

Implements listcollection< valuetype >.

◆ insertAfter() [2/2]

template<class valuetype >
void linkedlist< valuetype >::insertAfter ( listnode< valuetype > *  node,
valuetype  value 
)
inlinevirtual

Creates a new linkedlistnode containing "value" and inserts it into the linkedlist after "node".

Implements listcollection< valuetype >.

◆ insertBefore() [1/2]

template<class valuetype >
void linkedlist< valuetype >::insertBefore ( listnode< valuetype > *  node,
listnode< valuetype > *  newnode 
)
inlinevirtual

Inserts already created linkedlistnode "newnode" into the linkedlist before "node".

Implements listcollection< valuetype >.

◆ insertBefore() [2/2]

template<class valuetype >
void linkedlist< valuetype >::insertBefore ( listnode< valuetype > *  node,
valuetype  value 
)
inlinevirtual

Creates a new linkedlistnode containing "value" and inserts it into the linkedlist before "node".

Implements listcollection< valuetype >.

◆ moveAfter()

template<class valuetype >
void linkedlist< valuetype >::moveAfter ( listnode< valuetype > *  node,
listnode< valuetype > *  nodetomove 
)
inlinevirtual

Moves node "nodetomove" to the position after "node" in the linkedlist.

Implements listcollection< valuetype >.

◆ moveBefore()

template<class valuetype >
void linkedlist< valuetype >::moveBefore ( listnode< valuetype > *  node,
listnode< valuetype > *  nodetomove 
)
inlinevirtual

Moves node "nodetomove" to the position before "node" in the linkedlist.

Implements listcollection< valuetype >.

◆ operator=() [1/2]

template<class valuetype >
linkedlist< valuetype > & linkedlist< valuetype >::operator= ( linkedlist< valuetype > &  a)
inline

Makes this instance of the linkedlist class identical to "a".

◆ operator=() [2/2]

template<class valuetype >
linkedlist< valuetype > & linkedlist< valuetype >::operator= ( nodecollection< valuetype > &  a)
inline

Makes this instance of the linkedlist class identical to "a".

◆ prepend() [1/2]

template<class valuetype >
void linkedlist< valuetype >::prepend ( listnode< valuetype > *  node)
inlinevirtual

Prepends already created linkedlistnode "node" to the linkedlist.

Implements listcollection< valuetype >.

◆ prepend() [2/2]

template<class valuetype >
void linkedlist< valuetype >::prepend ( valuetype  value)
inlinevirtual

Creates a new linkedlistnode containing "value" and prepends it to the linkedlist.

Implements listcollection< valuetype >.

◆ remove() [1/2]

template<class valuetype >
bool linkedlist< valuetype >::remove ( listnode< valuetype > *  node)
inlinevirtual

Removes linkedlistnode "node" from the linkedlist.

The value stored in the linkedlistnode is only deleted if setManageValues(true) or setManageArrayValues(true) has been called.

Note that this operation does not require a search and is far less expensive than the remove(value) operation and removeAll().

Returns true on success and false on failure.

Implements listcollection< valuetype >.

◆ remove() [2/2]

template<class valuetype >
bool linkedlist< valuetype >::remove ( valuetype  value)
inlinevirtual

Deletes the first linkedlistnode containing "value".

The value stored in the linkedlistnode is only deleted if setManageValues(true) or setManageArrayValues(true) has been called.

Note that this operation requires a search and is expensive in both execution time and code size.

Returns true on success and false on failure.

Implements listcollection< valuetype >.

◆ removeAll()

template<class valuetype >
bool linkedlist< valuetype >::removeAll ( valuetype  value)
inlinevirtual

Deletes all linkedlistnodes containing "value".

The value stored in each linkedlistnode is only deleted if setManageValues(true) or setManageArrayValues(true) has been called.

Note that this operation requires a search and is expensive in both execution time and code size.

Returns true on success and false on failure.

Implements listcollection< valuetype >.

◆ sortInexpensively()

template<class valuetype >
void linkedlist< valuetype >::sortInexpensively
inlinevirtual

Sorts the listcollection.

This sort is potentially much slower than sortQuickly() but uses no additional memory.

The order that the items are sorted into depends on the comparator that is being used, and how that comparator is configured. The default comparator, in its default configuration causes the list to be sorted in ascending order.

See collection::setComparator() and the comparator class for more detail.

Implements listcollection< valuetype >.

◆ sortQuickly()

template<class valuetype >
void linkedlist< valuetype >::sortQuickly
inlinevirtual

Sorts the listcollection.

This sort is potentially much faster than sortInexpensively() but uses additional memory in proportion to the size of the list.

The order that the items are sorted into depends on the comparator that is being used, and how that comparator is configured. The default comparator, in its default configuration causes the list to be sorted in ascending order.

See collection::setComparator() and the comparator class for more detail.

Implements listcollection< valuetype >.