Loading...
Searching...
No Matches
SBCContainerListLink< ValueType > Class Template Reference

This template class describes a doubly linked list. More...

Public Member Functions

 SBCContainerListLink (const ValueType &v, SBCContainerListLink< ValueType > *n=0, SBCContainerListLink< ValueType > *p=0)
 Constructs a link holding value v, with next link n and previous link p.
 
virtual ~SBCContainerListLink ()
 Destructs the 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.
 
SBCContainerListLink< ValueType > * getNextLink () const
 Returns a pointer to the next link.
 
SBCContainerListLink< ValueType > * getPreviousLink () const
 Returns a pointer to the previous link.
 
void deleteLinkFromList ()
 Deletes a link from the list while preserving the list.
 
unsigned int getMemoryFootprint () const
 Returns the memory footprint of the link.
 

Heap management

ValueType value
 
SBCContainerListLink< ValueType > * nextLink
 
SBCContainerListLink< ValueType > * previousLink
 
static void * operator new (std::size_t size)
 
static void operator delete (void *p, std::size_t size)
 

Detailed Description

template<class ValueType>
class SBCContainerListLink< ValueType >
Template Parameters
ValueTypeThe 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();
SBMStructuralModelNodeAtom SBAtom
The short name of SBMStructuralModelNodeAtom.
Definition: SBMStructuralModelNodeAtom.hpp:666
@ Carbon
The type of the Carbon element.
Definition: SBMElement.hpp:48

Short name: SBListLink

See also
SBCContainerList

Constructor & Destructor Documentation

◆ ~SBCContainerListLink()

template<class ValueType >
virtual SBCContainerListLink< ValueType >::~SBCContainerListLink ( )
inlinevirtual

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

Member Function Documentation

◆ deleteLinkFromList()

template<class ValueType >
void SBCContainerListLink< ValueType >::deleteLinkFromList ( )
inline

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