aGrUM  0.14.2
gum::LinkedList< T > Class Template Reference

Chain list allocated using the SmallObjectAllocator. More...

#include <agrum/multidim/FunctionGraphUtilities/link.h>

Public Member Functions

Constructors and Destructors
 LinkedList ()
 Constructor. More...
 
 ~LinkedList ()
 Destructor. More...
 
void * operator new (size_t s)
 Operator new overload to use the SmallObjectAllocator. More...
 
void operator delete (void *p)
 Operator delete overload to use the SmallObjectAllocator. More...
 
Misceleanous methods
const Link< T > * list () const
 Returns the first link in the chained list. More...
 
Link< T > * list ()
 Returns the first link in the chained list. More...
 
void clear ()
 Clears the list. More...
 
void addLink (const T &elem)
 Adds a link. More...
 
void searchAndRemoveLink (const T &elem)
 Removes a element from the list. More...
 

Detailed Description

template<typename T>
class gum::LinkedList< T >

Chain list allocated using the SmallObjectAllocator.

Template Parameters
TThe type stored by the chain list.

Definition at line 131 of file link.h.

Constructor & Destructor Documentation

◆ LinkedList()

template<typename T >
INLINE gum::LinkedList< T >::LinkedList ( )

Constructor.

Definition at line 89 of file link_tpl.h.

89  {
90  GUM_CONSTRUCTOR(LinkedList);
91  __firstLink = nullptr;
92  }
LinkedList()
Constructor.
Definition: link_tpl.h:89
Link< T > * __firstLink
The first link of our list.
Definition: link.h:193

◆ ~LinkedList()

template<typename T >
INLINE gum::LinkedList< T >::~LinkedList ( )

Destructor.

Definition at line 96 of file link_tpl.h.

96  {
97  clear();
98  GUM_DESTRUCTOR(LinkedList);
99  }
void clear()
Clears the list.
Definition: link_tpl.h:122
LinkedList()
Constructor.
Definition: link_tpl.h:89

Member Function Documentation

◆ addLink()

template<typename T>
INLINE void gum::LinkedList< T >::addLink ( const T &  elem)

Adds a link.

Definition at line 133 of file link_tpl.h.

Referenced by gum::MultiDimFunctionGraphManager< bool, ExactTerminalNodePolicy >::__adjacentSwap(), and gum::MultiDimFunctionGraphGenerator::generate().

133  {
134  Link< T >* newLink = new Link< T >(elem, __firstLink);
135  __firstLink = newLink;
136  }
Link< T > * __firstLink
The first link of our list.
Definition: link.h:193
+ Here is the caller graph for this function:

◆ clear()

template<typename T >
void gum::LinkedList< T >::clear ( )

Clears the list.

Definition at line 122 of file link_tpl.h.

122  {
123  Link< T >* curLink = __firstLink;
124  Link< T >* nl = nullptr;
125  while (curLink) {
126  nl = curLink->nextLink();
127  delete curLink;
128  curLink = nl;
129  }
130  }
Link< T > * __firstLink
The first link of our list.
Definition: link.h:193

◆ list() [1/2]

template<typename T >
INLINE const Link< T > * gum::LinkedList< T >::list ( ) const

Returns the first link in the chained list.

Definition at line 112 of file link_tpl.h.

Referenced by gum::MultiDimFunctionGraphManager< bool, ExactTerminalNodePolicy >::__adjacentSwap(), and gum::MultiDimFunctionGraphGenerator::generate().

112  {
113  return __firstLink;
114  }
Link< T > * __firstLink
The first link of our list.
Definition: link.h:193
+ Here is the caller graph for this function:

◆ list() [2/2]

template<typename T >
INLINE Link< T > * gum::LinkedList< T >::list ( )

Returns the first link in the chained list.

Definition at line 117 of file link_tpl.h.

117  {
118  return __firstLink;
119  }
Link< T > * __firstLink
The first link of our list.
Definition: link.h:193

◆ operator delete()

template<typename T >
INLINE void gum::LinkedList< T >::operator delete ( void *  p)

Operator delete overload to use the SmallObjectAllocator.

Definition at line 107 of file link_tpl.h.

107  {
108  SmallObjectAllocator::instance().deallocate(p, sizeof(LinkedList< T >));
109  }
void deallocate(void *pDeallocatedObject, const size_t &objectSize)
Deallocates an object.
static SmallObjectAllocator & instance()

◆ operator new()

template<typename T >
INLINE void * gum::LinkedList< T >::operator new ( size_t  s)

Operator new overload to use the SmallObjectAllocator.

Definition at line 102 of file link_tpl.h.

102  {
104  }
void * allocate(const size_t &objectSize)
Allocates a block.
static SmallObjectAllocator & instance()
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition: types.h:45

◆ searchAndRemoveLink()

template<typename T>
INLINE void gum::LinkedList< T >::searchAndRemoveLink ( const T &  elem)

Removes a element from the list.

Definition at line 139 of file link_tpl.h.

Referenced by gum::MultiDimFunctionGraphManager< bool, ExactTerminalNodePolicy >::__adjacentSwap().

139  {
140  Link< T >* curLink = __firstLink;
141  Link< T >* prevLink = nullptr;
142  while (curLink && curLink->element() != elem) {
143  prevLink = curLink;
144  curLink = curLink->nextLink();
145  }
146  if (curLink) {
147  if (prevLink)
148  prevLink->setNextLink(curLink->nextLink());
149  else
150  __firstLink = curLink->nextLink();
151  delete curLink;
152  }
153  }
Link< T > * __firstLink
The first link of our list.
Definition: link.h:193
+ Here is the caller graph for this function:

Member Data Documentation

◆ __firstLink

template<typename T>
Link< T >* gum::LinkedList< T >::__firstLink
private

The first link of our list.

Definition at line 193 of file link.h.


The documentation for this class was generated from the following files: