Web Analytics Made Easy - Statcounter
Skip to content

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#

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.

inline void SBCContainerListLink::deleteLinkFromList () 

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.

inline unsigned int SBCContainerListLink::getMemoryFootprint () const


Returns a pointer to the next link.

inline SBCContainerListLink < ValueType > * SBCContainerListLink::getNextLink () const


Returns a pointer to the previous link.

inline SBCContainerListLink < ValueType > * SBCContainerListLink::getPreviousLink () const


function getValue [1/2]#

Returns a reference to the value hold by the link.

inline ValueType & SBCContainerListLink::getValue () 


function getValue [2/2]#

Returns a reference to the value hold by the link.

inline ValueType const & SBCContainerListLink::getValue () const


Destructs the link.

inline virtual SBCContainerListLink::~SBCContainerListLink () 

This destructor does not do anything. In particular, it does not delete the next and previous link.


Public Static Functions Documentation#

function operator delete#

static inline void SBCContainerListLink::operator delete (
    void * p,
    std::size_t size
) 

function operator new#

static inline void * SBCContainerListLink::operator new (
    std::size_t size
) 

Protected Attributes Documentation#

SBCContainerListLink<ValueType>* nextLink;

SBCContainerListLink<ValueType>* previousLink;

variable value#

ValueType value;