Loading...
Searching...
No Matches
SBCContainerList< ValueType, LinkType > Class Template Reference

This template class describes an encapsulated doubly-linked list. More...

Public Member Functions

 SBCContainerList ()
 Constructs an empty list.
 
 SBCContainerList (const SBCContainerList &list)
 Copy constructor.
 
 SBCContainerList (SBCContainerList &&list)
 Move constructor.
 
SBCContainerListoperator= (const SBCContainerList &list)
 Copy assignment.
 
SBCContainerListoperator= (SBCContainerList &&list)
 Move assignment.
 
virtual ~SBCContainerList ()
 Destructs the list.
 
bool empty () const
 Returns true if and only if the list is empty.
 
void clear ()
 Clears the list.
 
iterator begin ()
 Returns an iterator that points to the beginning of the list.
 
const_iterator begin () const
 Returns an iterator that points to the beginning of the list.
 
iterator end ()
 Returns an iterator that points to the end of the list.
 
const_iterator end () const
 Returns an iterator that points to the end of the list.
 
reverse_iterator rbegin ()
 Returns a reverse iterator that points to the beginning of the reverse list.
 
const_reverse_iterator rbegin () const
 Returns a reverse iterator that points to the beginning of the reverse list.
 
reverse_iterator rend ()
 Returns a reverse iterator that points to the beginning of the reverse list.
 
const_reverse_iterator rend () const
 Returns a reverse iterator that points to the beginning of the reverse list.
 
void push_back (const ValueType &t)
 Adds t at the end of the list.
 
void push_front (const ValueType &t)
 Adds t at the beginning of the list.
 
void pop_back ()
 Removes the last element of the list.
 
void pop_front ()
 Removes the first element of the list.
 
unsigned int size () const
 Returns the size of the list.
 
void deleteLinkFromList (LinkType *link)
 Deletes the link link from the list.
 
bool hasLink (LinkType *link) const
 Returns true if and only if the list contains the link link.
 
LinkType * getBeginLink ()
 Returns a pointer to the first link in the list.
 
LinkType const * getBeginLink () const
 Returns a pointer to the first link in the list.
 
LinkType * getEndLink ()
 Returns a pointer to the last link in the list.
 
LinkType const * getEndLink () const
 Returns a pointer to the last link in the list.
 
unsigned int getMemoryFootprint () const
 Returns the memory footprint of the list.
 

Protected Attributes

LinkType * beginLink
 
LinkType * endLink
 

Detailed Description

template<class ValueType, class LinkType = SBCContainerListLink<ValueType>>
class SBCContainerList< ValueType, LinkType >
Template Parameters
ValueTypeThe type of values contained in the list
LinkTypeThe type of links contained in the list

This template class describes an encapsulated doubly-linked list:

SBList<SBAtom*> l;
// add atoms to the front of the list
for (unsigned int i = 0; i<10; i++)
l.push_front(new SBAtom(SBElement::Carbon));
// print atoms positions (version 1)
for (SBList<SBAtom*>::iterator i = l.begin(); i != l.end(); i++)
(*i)->getPosition().print();
// print atoms positions (version 2)
SB_FOR(SBAtom* atom, l)
atom->getPosition().print();
#define SB_FOR(VARIABLE, CONTAINER)
A macro to easily write for loops involving containers.
Definition: SBCContainerFor.hpp:83
@ Carbon
The type of the Carbon element.
Definition: SBMElement.hpp:48
This class describes an atom in a structural model.
Definition: SBMStructuralModelNodeAtom.hpp:34

Short name: SBList

See also
SBCContainerListLink
SB_FOR

Member Function Documentation

◆ size()

template<class ValueType , class LinkType = SBCContainerListLink<ValueType>>
unsigned int SBCContainerList< ValueType, LinkType >::size ( ) const
inline

This operation is linear in the number of elements in the list