# cLinkedList Class Reference
[Container classes]

`#include <cllist.h>`

Inheritance diagram for cLinkedList:

List of all members.

## Detailed Description

Use of this class is DISCOURAGED, it is provided for backward compatibility only.

Use std::deque or std::list instead.

A double-linked list of non-cObject items. cLinkedList has a cQueue-like interface.

Memory management of contained items is controlled by the configPointer() function. As default, pointers are treated as mere pointers, so items are never duplicated or deleted.

See also:
  Iterator

## Public Member Functions

Constructors, destructor, assignment.
| cLinkedList (const cLinkedList &llist)
| cLinkedList (const char *name=NULL)
virtual | ~cLinkedList ()
cLinkedList & | operator= (const cLinkedList &queue)
Redefined cObject member functions
virtual cPolymorphic * | dup () const
virtual std::string | info () const
virtual void | netPack (cCommBuffer *buffer)
virtual void | netUnpack (cCommBuffer *buffer)
Container functions.
void | config (VoidDelFunc _delfunc, VoidDupFunc _dupfunc, size_t _itemsize=0)
void | insert (void *item)
void | insertBefore (void *where, void *item)
void | insertAfter (void *where, void *item)
void * | head () const
void * | tail () const
void * | remove (void *item)
void * | pop ()
int | length () const
bool | empty () const
bool | contains (void *item) const
void | clear ()

## Classes

class | Iterator
| Walks along a cLinkedList object. More...

## Constructor & Destructor Documentation

cLinkedList::cLinkedList | ( | const cLinkedList & | llist | ) |

| Copy constructor. Contained items that are owned by the list will be duplicated using the function passed in configPointer() so that the new list will have its own copy of them. By default, there's no duplication function so only the pointers are copied.

cLinkedList::cLinkedList | ( | const char * | name = `NULL` | ) | `[explicit]`

| Constructor. It accepts the object name.

virtual cLinkedList::~cLinkedList | ( |  | ) | `[virtual]`

| Destructor calls clear().

## Member Function Documentation

void cLinkedList::clear | ( |  | ) |

| As a result, the container will be empty. Contained items will be deleted as configured by configPointer().

void cLinkedList::config | ( | VoidDelFunc | _delfunc,
|  | VoidDupFunc | _dupfunc,
|  | size_t | _itemsize = `0`
| ) |

Configures memory management for contained items.

delete func. | dupl.func. | itemsize | behavior
NULL | NULL | 0 | Pointer is treated as mere pointer - no memory management. Duplication copies the pointer, and deletion does nothing.
NULL | NULL | >0 size | Plain memory management. Duplication is done with operator new char[size]+memcpy(), and deletion is done via operator delete.
NULL or user's delete func. | user's dupfunc. | indifferent | Sophisticated memory management. Duplication is done by calling the user-supplied duplication function, which should do the allocation and the appropriate copying. Deletion is done by calling the user-supplied delete function, or the delete operator if it is not supplied.

bool cLinkedList::contains | ( | void * | item | ) | const`[inline]`

| Returns true if the list contains the given pointer.

virtual cPolymorphic* cLinkedList::dup | ( |  | ) | const`[inline, virtual]`

| Duplication and assignment work all right with cLinkedList. Contained items are treated as configured with configPointer(). By default, only pointers are copied. Reimplemented from cObject.

bool cLinkedList::empty | ( |  | ) | const`[inline]`

| Returns true if the list is empty.

void* cLinkedList::head | ( |  | ) | const`[inline]`

| Returns the first item in the list or NULL pointer if the list is empty.

virtual std::string cLinkedList::info | ( |  | ) | const`[virtual]`

| Produces a one-line description of object contents into the buffer passed as argument. See cObject for more details. Reimplemented from cPolymorphic.

void cLinkedList::insert | ( | void * | item | ) |

| Inserts the given object at the head of the list.

void cLinkedList::insertAfter | ( | void * | where,
|  | void * | item
| ) |

| Inserts exactly after the given item. If the item to be inserted after is not in the list, cRuntimeError is thrown.

void cLinkedList::insertBefore | ( | void * | where,
|  | void * | item
| ) |

| Inserts exactly before the given item. If the item to be inserted before is not in the list, cRuntimeError is thrown.

int cLinkedList::length | ( |  | ) | const`[inline]`

| Returns the number of items contained in the list.

virtual void cLinkedList::netPack | ( | cCommBuffer * | buffer | ) | `[virtual]`

| Serializes the object into a PVM or MPI send buffer. Used by the simulation kernel for parallel execution. See cObject for more details. Reimplemented from cObject.

virtual void cLinkedList::netUnpack | ( | cCommBuffer * | buffer | ) | `[virtual]`

| Deserializes the object from a PVM or MPI receive buffer Used by the simulation kernel for parallel execution. See cObject for more details. Reimplemented from cObject.

cLinkedList& cLinkedList::operator= | ( | const cLinkedList & | queue | ) |

| Assignment operator. The name member doesn't get copied; see cObject's operator=() for more details. Duplication and assignment work all right with cLinkedList. Contained items are treated as configured with configPointer(). By default, only pointers are copied.

void* cLinkedList::pop | ( |  | ) |

| Unlinks and returns the last item in the list. If the list is empty, cRuntimeError is thrown.

void* cLinkedList::remove | ( | void * | item | ) |

| Unlinks and returns the given item. If the item is not in the list, cRuntimeError is thrown.

void* cLinkedList::tail | ( |  | ) | const`[inline]`

| Returns the last item in the list or NULL pointer if the list is empty.

The documentation for this class was generated from the following file:

- cllist.h