Class SBCContainerListLink#
template <class ValueType>
ClassList > SBCContainerListLink
This template class describes a doubly linked list. More...
#include <SBCContainerListLink.hpp>
Public Functions#
Type | Name |
---|---|
SBCContainerListLink (const ValueType & v, SBCContainerListLink< ValueType > * n=nullptr, SBCContainerListLink< ValueType > * p=nullptr) Constructs a link holding value v , with next linkn and previous linkp . |
|
void | deleteLinkFromList () Deletes a link from the list while preserving the list. |
unsigned int | getMemoryFootprint () const Returns the memory footprint of the link. |
SBCContainerListLink< ValueType > * | getNextLink () const Returns a pointer to the next link. |
SBCContainerListLink< ValueType > * | getPreviousLink () const Returns a pointer to the previous link. |
ValueType & | getValue () Returns a reference to the value hold by the link. |
ValueType const & | getValue () const Returns a reference to the value hold by the link. |
virtual | ~SBCContainerListLink () Destructs the link. |
Public Static Functions#
Type | Name |
---|---|
void | operator delete (void * p, std::size_t size) |
void * | operator new (std::size_t size) |
Protected Attributes#
Type | Name |
---|---|
SBCContainerListLink< ValueType > * | nextLink |
SBCContainerListLink< ValueType > * | previousLink |
ValueType | value |
Detailed Description#
Template parameters:
ValueType
The type of the value hold in the link
The class SBCContainerListLink is a template defining a link from a doubly-linked list. It may be used as is, to define a non-encapsulated doubly-linked list that may hold values of type ValueType
, or through SBCContainerList, which defines an encapsulated list. When using it alone, proper care must be taken to avoid memory leaks.
SBListLink<SBAtom*>* l = 0;
// add atoms to the front of the list
for (unsigned int i = 0; i<10; i++)
l = new SBListLink<SBAtom*>(new SBAtom(SBElement::Carbon), l);
// print atoms positions
for (SBListLink<SBAtom*>* i = l; i != 0; i = i->getNextLink())
i->getValue()->getPosition().print();
Short name: SBListLink
See also: SBCContainerList
Public Functions Documentation#
function SBCContainerListLink#
Constructs a link holding value v
, with next linkn
and previous linkp
.
inline SBCContainerListLink::SBCContainerListLink (
const ValueType & v,
SBCContainerListLink < ValueType > * n=nullptr,
SBCContainerListLink < ValueType > * p=nullptr
)
function deleteLinkFromList#
Deletes a link from the list while preserving the list.
This function deletes the link while preserving the list:
- if the link had a previous link, this previous link then points to the link's next link
- if the link had a next link, this next link then points to the link's previous link
function getMemoryFootprint#
Returns the memory footprint of the link.
function getNextLink#
Returns a pointer to the next link.
function getPreviousLink#
Returns a pointer to the previous link.
function getValue [1/2]#
Returns a reference to the value hold by the link.
function getValue [2/2]#
Returns a reference to the value hold by the link.
function ~SBCContainerListLink#
Destructs the link.
This destructor does not do anything. In particular, it does not delete the next and previous link.