Use of this class is DISCOURAGED, it is provided for backward compatibility only. More...
#include <clinkedlist.h>
Classes | |
class | Iterator |
Walks along a cLinkedList object. More... | |
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 cLinkedList * | dup () const |
virtual std::string | info () const |
virtual void | parsimPack (cCommBuffer *buffer) |
virtual void | parsimUnpack (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 | getLength () const |
bool | isEmpty () const |
int | length () const |
bool | empty () const |
bool | contains (void *item) const |
void | clear () |
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-cOwnedObject 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.
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 is no duplication function so only the pointers are copied.
cLinkedList::cLinkedList | ( | const char * | name = NULL |
) | [explicit] |
Constructor.
It accepts the object name.
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. |
virtual cLinkedList* 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.
virtual std::string cLinkedList::info | ( | ) | const [virtual] |
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.
cLinkedList& cLinkedList::operator= | ( | const cLinkedList & | queue | ) |
Assignment operator.
The name member is not copied; see cOwnedObject'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.
virtual void cLinkedList::parsimPack | ( | cCommBuffer * | buffer | ) | [virtual] |
Serializes the object into an MPI send buffer.
Used by the simulation kernel for parallel execution. See cObject for more details.
Reimplemented from cOwnedObject.
virtual void cLinkedList::parsimUnpack | ( | cCommBuffer * | buffer | ) | [virtual] |
Deserializes the object from an MPI receive buffer Used by the simulation kernel for parallel execution.
See cObject for more details.
Reimplemented from cOwnedObject.
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.