aGrUM 2.3.2
a C++ library for (probabilistic) graphical models
gum::LinkedList< T > Class Template Reference

Chain list allocated using the SmallObjectAllocator. More...

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

Public Member Functions

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

Private Attributes

Link< T > * _firstLink_
 The first link of our list.

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 155 of file link.h.

Constructor & Destructor Documentation

◆ LinkedList()

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

Constructor.

Definition at line 113 of file link_tpl.h.

113 {
115 _firstLink_ = nullptr;
116 }
Chain list allocated using the SmallObjectAllocator.
Definition link.h:155
Link< T > * _firstLink_
The first link of our list.
Definition link.h:217
LinkedList()
Constructor.
Definition link_tpl.h:113

Referenced by ~LinkedList(), operator delete(), and operator new().

Here is the caller graph for this function:

◆ ~LinkedList()

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

Destructor.

Definition at line 120 of file link_tpl.h.

120 {
121 clear();
123 }
void clear()
Clears the list.
Definition link_tpl.h:146

References LinkedList(), and clear().

Here is the call graph for this function:

Member Function Documentation

◆ addLink()

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

Adds a link.

Definition at line 157 of file link_tpl.h.

157 {
160 }

References _firstLink_.

Referenced by gum::MultiDimFunctionGraphGenerator::generate().

Here is the caller graph for this function:

◆ clear()

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

Clears the list.

Definition at line 146 of file link_tpl.h.

146 {
148 Link< T >* nl = nullptr;
149 while (curLink) {
150 nl = curLink->nextLink();
151 delete curLink;
152 curLink = nl;
153 }
154 }

References _firstLink_, and gum::Link< T >::nextLink().

Referenced by ~LinkedList().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ list() [1/2]

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

Returns the first link in the chained list.

Definition at line 141 of file link_tpl.h.

141 {
142 return _firstLink_;
143 }

References _firstLink_.

◆ list() [2/2]

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

Returns the first link in the chained list.

Definition at line 136 of file link_tpl.h.

136 {
137 return _firstLink_;
138 }

References _firstLink_.

Referenced by gum::MultiDimFunctionGraphGenerator::generate().

Here is the caller graph for this function:

◆ operator delete()

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

Operator delete overload to use the SmallObjectAllocator.

Definition at line 131 of file link_tpl.h.

131 {
133 }
static SmallObjectAllocator & instance()
void deallocate(void *pDeallocatedObject, const size_t &objectSize)
Deallocates an object.

References LinkedList(), gum::SmallObjectAllocator::deallocate(), and gum::SmallObjectAllocator::instance().

Here is the call graph for this function:

◆ 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 126 of file link_tpl.h.

126 {
128 }
void * allocate(const size_t &objectSize)
Allocates a block.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
Definition types.h:74

References LinkedList(), gum::SmallObjectAllocator::allocate(), and gum::SmallObjectAllocator::instance().

Here is the call graph for this function:

◆ searchAndRemoveLink()

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

Removes a element from the list.

Definition at line 163 of file link_tpl.h.

163 {
165 Link< T >* prevLink = nullptr;
166 while (curLink && curLink->element() != elem) {
168 curLink = curLink->nextLink();
169 }
170 if (curLink) {
171 if (prevLink) prevLink->setNextLink(curLink->nextLink());
172 else _firstLink_ = curLink->nextLink();
173 delete curLink;
174 }
175 }

References _firstLink_.

Member Data Documentation

◆ _firstLink_

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

The first link of our list.

Definition at line 217 of file link.h.

Referenced by addLink(), clear(), list(), list(), and searchAndRemoveLink().


The documentation for this class was generated from the following files:
  • agrum/base/multidim/utils/FunctionGraphUtilities/link.h
  • agrum/base/multidim/utils/FunctionGraphUtilities/link_tpl.h