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

The generic class for storing (ordered) sequences of objects. More...

#include <agrum/base/core/sequence.h>

Inheritance diagram for gum::Sequence< Key >:
Collaboration diagram for gum::Sequence< Key >:

Public Types

using Implementation = SequenceImplementation< Key, std::is_scalar< Key >::value >
 The gum::Sequence implementation.
using value_type = Key
 Types for STL compliance.
using reference = Key&
 Types for STL compliance.
using const_reference = const Key&
 Types for STL compliance.
using pointer = Key*
 Types for STL compliance.
using const_pointer = const Key*
 Types for STL compliance.
using size_type = std::size_t
 Types for STL compliance.
using difference_type = std::ptrdiff_t
 Types for STL compliance.
using iterator = SequenceIterator< Key >
 Types for STL compliance.
using const_iterator = SequenceIterator< Key >
 Types for STL compliance.
using iterator_safe = SequenceIteratorSafe< Key >
 Types for STL compliance.
using const_iterator_safe = SequenceIteratorSafe< Key >
 Types for STL compliance.

Public Member Functions

INLINE void emplace (Args &&... args)
Constructors / Destructors
 Sequence (Size size_param=HashTableConst::default_size)
 Default constructor.
 Sequence (std::initializer_list< Key > list)
 Initializer list constructor.
 Sequence (const Sequence< Key > &aSeq)
 Copy constructor.
 Sequence (Sequence< Key > &&aSeq)
 Move constructor.
 ~Sequence () noexcept
 Class destructor.
Operators
Sequence< Key > & operator= (const Sequence< Key > &aSeq)
 Copy operator.
Sequence< Key > & operator= (Sequence< Key > &&aSeq)
 Move operator.
Accessors / Modifiers
Set< Key > diffSet (const Sequence< Key > &seq) const
 Difference between two sequences as a Set<Key> = this \ seq.
Iterators
iterator_safe beginSafe () const
 Returns a safe begin iterator.
iterator_safe rbeginSafe () const
 Returns a safe rbegin iterator.
const iterator_safeendSafe () const noexcept
 Returns the safe end iterator.
const iterator_saferendSafe () const noexcept
 Returns the safe rend iterator.
iterator begin () const
 Returns an unsafe begin iterator.
iterator rbegin () const
 Returns an unsafe rbegin iterator.
const iteratorend () const noexcept
 Returns the unsafe end iterator.
const iteratorrend () const noexcept
 Returns the unsafe rend iterator.
Operators
SequenceImplementation< Key, Gen > & operator<< (const Key &k)
 Insert k at the end of the sequence (synonym for insert).
SequenceImplementation< Key, Gen > & operator<< (Key &&k)
 Insert k at the end of the sequence (synonym for insert).
SequenceImplementation< Key, Gen > & operator>> (const Key &k)
 Remove k in the sequence (synonym for erase).
const Key & operator[] (Idx i) const
 Returns the element at position i (synonym for atPos).
bool operator== (const SequenceImplementation< Key, Gen > &k) const
 Returns true if the content of k equals that of *this.
bool operator!= (const SequenceImplementation< Key, Gen > &k) const
 Returns true if the content of k is different from that of *this.
Accessors / Modifiers
void clear ()
 Clear the sequence.
Size size () const noexcept
 Returns the size of the sequence.
bool empty () const noexcept
 Return true if empty.
bool exists (const Key &k) const
 Check the existence of k in the sequence.
void insert (const Key &k)
 Insert an element at the end of the sequence.
void insert (Key &&k)
 Move an element at the end of the sequence.
void emplace (Args &&... args)
 Emplace a new element in the sequence.
void erase (const Key &k)
 Remove an element from the sequence.
void erase (const iterator_safe &k)
 Remove from the sequence the element pointed to by the iterator.
const Key & atPos (Idx i) const
 Returns the object at the pos i.
Idx pos (const Key &key) const
 Returns the position of the object passed in argument (if it exists).
void setAtPos (Idx i, const Key &newKey)
 Change the value.
void setAtPos (Idx i, Key &&newKey)
 Change the value.
void swap (Idx i, Idx j)
 Swap index.
const Key & front () const
 Returns the first element of the element.
const Key & back () const
 Returns the last element of the sequence.
std::string toString () const
 Displays the content of the sequence.
void resize (Size new_size)
 Modifies the size of the internal structures of the sequence.

Private Member Functions

void _update_end_ () noexcept
 A method to update the end iterator after changes in the sequence.
void _copy_ (const SequenceImplementation< Key, Gen > &aSeq)
 Clears the current sequence and fill it with copies the element of aSeq.
void _insert_ (HashTableBucket< Key, Idx > &&bucket)
 Insert an element at the end of the sequence.

Private Attributes

HashTable< Key, Idx_h_
 Keep track of the position of the element in v (for fast retrieval).
std::vector< Key * > _v_
 The set of the elements stored into the sequence.
SequenceIteratorSafe< Key > _end_safe_
 Stores the end iterator for fast access.
SequenceIteratorSafe< Key > _rend_safe_
 Stores the rend iterator for fast access.

Detailed Description

template<typename Key>
class gum::Sequence< Key >

The generic class for storing (ordered) sequences of objects.

A gum::Sequence<Key> is quite similar to a std::vector<Key> in that it stores an ordered set of elements. The main difference between these two data structures lies in the fact that, given a key, it is possible to retrieve from a gum::Sequence<Key> the index in the vector where the key lies in O(1). As a result, it is not possible to insert a given element twice in the sequence, that is, all the Keys must be different.

Usage example:
// creation of a sequence
Sequence<int> seq { 1, 2, 3, 4 };
// creation of safe iterators
SequenceIteratorSafe<int> iter1 = seq.beginSafe (); // points to 1
SequenceIteratorSafe<int> iter3 = std::move ( iter1 );
// creation of unsafe iterators
SequenceIterator<int> xiter1 = seq.begin (); // points to 1
SequenceIterator<int> xiter2 = xiter1;
SequenceIterator<int> xiter3 = std::move ( xiter1 );
// parsing the sequence
for ( auto iter = seq.begin (); iter != seq.end (); ++iter )
std::cout << *iter << std::endl;
for ( auto iter = seq.rbegin (); iter != seq.rend (); --iter )
std::cout << *iter << std::endl;
for ( auto iter = seq.begin (); iter != seq.end (); ++iter )
std::cout << iter->size () << std::endl;
const iterator & end() const noexcept
Returns the unsafe end iterator.
iterator_safe beginSafe() const
Returns a safe begin iterator.
iterator begin() const
Returns an unsafe begin iterator.
iterator rbegin() const
Returns an unsafe rbegin iterator.
const iterator & rend() const noexcept
Returns the unsafe rend iterator.
Safe iterators for Sequence.
Definition sequence.h:1134
The generic class for storing (ordered) sequences of objects.
Definition sequence.h:972
Sequence(Size size_param=HashTableConst::default_size)
Default constructor.
Template Parameters
KeyThe elements type stored in the sequence.

Definition at line 972 of file sequence.h.

Member Typedef Documentation

◆ const_iterator

template<typename Key>
using gum::Sequence< Key >::const_iterator = SequenceIterator< Key >

Types for STL compliance.

Definition at line 984 of file sequence.h.

◆ const_iterator_safe

template<typename Key>
using gum::Sequence< Key >::const_iterator_safe = SequenceIteratorSafe< Key >

Types for STL compliance.

Definition at line 986 of file sequence.h.

◆ const_pointer

template<typename Key>
using gum::Sequence< Key >::const_pointer = const Key*

Types for STL compliance.

Definition at line 980 of file sequence.h.

◆ const_reference

template<typename Key>
using gum::Sequence< Key >::const_reference = const Key&

Types for STL compliance.

Definition at line 978 of file sequence.h.

◆ difference_type

template<typename Key>
using gum::Sequence< Key >::difference_type = std::ptrdiff_t

Types for STL compliance.

Definition at line 982 of file sequence.h.

◆ Implementation

template<typename Key>
using gum::Sequence< Key >::Implementation = SequenceImplementation< Key, std::is_scalar< Key >::value >

The gum::Sequence implementation.

Definition at line 990 of file sequence.h.

◆ iterator

template<typename Key>
using gum::Sequence< Key >::iterator = SequenceIterator< Key >

Types for STL compliance.

Definition at line 983 of file sequence.h.

◆ iterator_safe

template<typename Key>
using gum::Sequence< Key >::iterator_safe = SequenceIteratorSafe< Key >

Types for STL compliance.

Definition at line 985 of file sequence.h.

◆ pointer

template<typename Key>
using gum::Sequence< Key >::pointer = Key*

Types for STL compliance.

Definition at line 979 of file sequence.h.

◆ reference

template<typename Key>
using gum::Sequence< Key >::reference = Key&

Types for STL compliance.

Definition at line 977 of file sequence.h.

◆ size_type

template<typename Key>
using gum::Sequence< Key >::size_type = std::size_t

Types for STL compliance.

Definition at line 981 of file sequence.h.

◆ value_type

template<typename Key>
using gum::Sequence< Key >::value_type = Key

Types for STL compliance.

Definition at line 976 of file sequence.h.

Constructor & Destructor Documentation

◆ Sequence() [1/4]

template<typename Key>
INLINE gum::Sequence< Key >::Sequence ( Size size_param = HashTableConst::default_size)

Default constructor.

Parameters
size_paramThe intial size of the gum::SequenceImplementation.

Definition at line 992 of file sequence_tpl.h.

References Sequence(), and gum::SequenceImplementation< Key, std::is_scalar< Key >::value >::SequenceImplementation().

Referenced by Sequence(), Sequence(), Sequence(), and ~Sequence().

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

◆ Sequence() [2/4]

template<typename Key>
INLINE gum::Sequence< Key >::Sequence ( std::initializer_list< Key > list)

Initializer list constructor.

Parameters
listThe initializer list.

Definition at line 999 of file sequence_tpl.h.

999 :
1001 // for debugging purposes
1003 }

References gum::SequenceImplementation< Key, std::is_scalar< Key >::value >::SequenceImplementation().

Here is the call graph for this function:

◆ Sequence() [3/4]

template<typename Key>
INLINE gum::Sequence< Key >::Sequence ( const Sequence< Key > & aSeq)

Copy constructor.

Parameters
aSeqThe sequence the elements of which will be copied.
Warning
The elements of the newly constructed sequence are copies of those in aSeq.

Definition at line 1007 of file sequence_tpl.h.

1007 :
1009 // for debugging purposes
1011 }

References Sequence(), gum::SequenceImplementation< Key, std::is_scalar< Key >::value >::SequenceImplementation(), and gum::SequenceImplementation< Key, std::is_scalar< Key >::value >::Sequence< Key >.

Here is the call graph for this function:

◆ Sequence() [4/4]

template<typename Key>
INLINE gum::Sequence< Key >::Sequence ( Sequence< Key > && aSeq)

Move constructor.

Parameters
aSeqThe gum::Sequence to move/

Definition at line 1015 of file sequence_tpl.h.

1015 :
1017 // for debugging purposes
1019 }

References Sequence(), gum::SequenceImplementation< Key, std::is_scalar< Key >::value >::SequenceImplementation(), and gum::SequenceImplementation< Key, std::is_scalar< Key >::value >::Sequence< Key >.

Here is the call graph for this function:

◆ ~Sequence()

template<typename Key>
INLINE gum::Sequence< Key >::~Sequence ( )
noexcept

Class destructor.

Definition at line 1023 of file sequence_tpl.h.

1023 {
1024 // for debugging purposes
1026 }

References Sequence().

Here is the call graph for this function:

Member Function Documentation

◆ _copy_()

void gum::SequenceImplementation< Key, Gen >::_copy_ ( const SequenceImplementation< Key, Gen > & aSeq)
privateinherited

Clears the current sequence and fill it with copies the element of aSeq.

Parameters
aSeqThe gum::SequenceImplementation to copy.

References SequenceImplementation(), and _copy_().

Referenced by _copy_().

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

◆ _insert_()

void gum::SequenceImplementation< Key, Gen >::_insert_ ( HashTableBucket< Key, Idx > && bucket)
privateinherited

Insert an element at the end of the sequence.

Parameters
bucketThe bucket holing the store to insert.

References gum::SequenceImplementation< Key, Gen >::SequenceImplementation(), SequenceImplementation(), gum::SequenceImplementation< Key, Gen >::~SequenceImplementation(), gum::SequenceImplementation< Key, Gen >::_copy_(), _end_safe_, _h_, gum::SequenceImplementation< Key, Gen >::_insert_(), _insert_(), _rend_safe_, gum::SequenceImplementation< Key, Gen >::_update_end_(), _v_, gum::SequenceImplementation< Key, Gen >::atPos(), gum::SequenceImplementation< Key, Gen >::back(), gum::SequenceImplementation< Key, Gen >::begin(), gum::SequenceImplementation< Key, Gen >::beginSafe(), gum::SequenceImplementation< Key, Gen >::clear(), gum::HashTableConst::default_size, gum::SequenceImplementation< Key, Gen >::emplace(), gum::SequenceImplementation< Key, Gen >::empty(), gum::SequenceImplementation< Key, Gen >::end(), gum::SequenceImplementation< Key, Gen >::endSafe(), gum::SequenceImplementation< Key, Gen >::erase(), gum::SequenceImplementation< Key, Gen >::exists(), gum::SequenceImplementation< Key, Gen >::front(), gum::SequenceImplementation< Key, Gen >::insert(), gum::SequenceImplementation< Key, Gen >::operator!=(), gum::SequenceImplementation< Key, Gen >::operator<<(), gum::SequenceImplementation< Key, Gen >::operator=(), gum::SequenceImplementation< Key, Gen >::operator==(), gum::SequenceImplementation< Key, Gen >::operator>>(), gum::SequenceImplementation< Key, Gen >::operator[](), gum::SequenceImplementation< Key, Gen >::pos(), gum::SequenceImplementation< Key, Gen >::rbegin(), gum::SequenceImplementation< Key, Gen >::rbeginSafe(), gum::SequenceImplementation< Key, Gen >::rend(), gum::SequenceImplementation< Key, Gen >::rendSafe(), gum::SequenceImplementation< Key, Gen >::resize(), SequenceIteratorSafe< Key >, gum::SequenceImplementation< Key, Gen >::setAtPos(), gum::SequenceImplementation< Key, Gen >::size(), gum::SequenceImplementation< Key, Gen >::swap(), and gum::SequenceImplementation< Key, Gen >::toString().

Referenced by _insert_().

Here is the caller graph for this function:

◆ _update_end_()

void gum::SequenceImplementation< Key, Gen >::_update_end_ ( )
privatenoexceptinherited

A method to update the end iterator after changes in the sequence.

References _update_end_().

Referenced by _update_end_(), and emplace().

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

◆ atPos()

const Key & gum::SequenceImplementation< Key, Gen >::atPos ( Idx i) const
inherited

Returns the object at the pos i.

Parameters
iThe position of the element to return.
Returns
Returns the object at the pos i.
Exceptions
NotFoundRaised if the element does not exist.

References atPos().

Referenced by atPos().

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

◆ back()

const Key & gum::SequenceImplementation< Key, Gen >::back ( ) const
inherited

Returns the last element of the sequence.

Returns
Returns the last element of the sequence.
Exceptions
NotFoundRaised if the sequence is empty.

References back().

Referenced by gum::prm::StructuredInference< GUM_SCALAR >::_removeBarrenNodes_(), and back().

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

◆ begin()

iterator gum::SequenceImplementation< Key, Gen >::begin ( ) const
inherited

Returns an unsafe begin iterator.

Returns
Returns an unsafe begin iterator.

References begin().

Referenced by gum::InfluenceDiagramGenerator< GUM_SCALAR >::_checkTemporalOrder_(), begin(), gum::InfluenceDiagram< GUM_SCALAR >::decisionOrderExists(), and gum::Sequence< Key >::diffSet().

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

◆ beginSafe()

iterator_safe gum::SequenceImplementation< Key, Gen >::beginSafe ( ) const
inherited

Returns a safe begin iterator.

Returns
Returns a safe begin iterator.

References beginSafe().

Referenced by beginSafe().

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

◆ clear()

void gum::SequenceImplementation< Key, Gen >::clear ( )
inherited

Clear the sequence.

References clear().

Referenced by clear().

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

◆ diffSet()

template<typename Key>
Set< Key > gum::Sequence< Key >::diffSet ( const Sequence< Key > & seq) const

Difference between two sequences as a Set<Key> = this \ seq.

Parameters
seqThe gum::Sequence to substract of this.
Returns
Returns the set difference : *this \ seq.

Definition at line 1044 of file sequence_tpl.h.

1044 {
1046
1047 for (iterator iter = this->begin(); iter != this->end(); ++iter) {
1048 if (!seq.exists(*iter)) res << *iter;
1049 }
1050
1051 return res;
1052 }
bool exists(const Key &k) const
Check the existence of k in the sequence.
SequenceIterator< Key > iterator
Types for STL compliance.
Definition sequence.h:983

References gum::SequenceImplementation< Key, std::is_scalar< Key >::value >::begin(), gum::SequenceImplementation< Key, std::is_scalar< Key >::value >::end(), gum::SequenceImplementation< Key, Gen >::exists(), and gum::SequenceImplementation< Key, std::is_scalar< Key >::value >::Sequence< Key >.

Here is the call graph for this function:

◆ emplace() [1/2]

void gum::SequenceImplementation< Key, Gen >::emplace ( Args &&... args)
inherited

Emplace a new element in the sequence.

The emplace is a method that allows to construct directly an element of type Key by passing to its constructor all the arguments it needs.

Template Parameters
ArgsThe arguments types passed to the constructor.
Parameters
argsThe arguments passed to the constructor.
Exceptions
DuplicateElementRaised if the sequence contains already k.

References emplace().

Referenced by emplace().

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

◆ emplace() [2/2]

INLINE void gum::SequenceImplementation< Key, Gen >::emplace ( Args &&... args)
inherited

Definition at line 388 of file sequence_tpl.h.

388 {
390 Key& new_key = const_cast< Key& >(_h_.insert(std::move(key), _h_.size()).first);
391 _v_.push_back(&new_key);
392 _update_end_();
393 }
The internal class for storing (ordered) sequences of objects.
Definition sequence.h:109
Size size() const noexcept
Returns the size of the sequence.
void insert(const Key &k)
Insert an element at the end of the sequence.

References _h_, _update_end_(), and _v_.

Here is the call graph for this function:

◆ empty()

bool gum::SequenceImplementation< Key, Gen >::empty ( ) const
noexceptinherited

Return true if empty.

Returns
Return true if empty.

References empty().

Referenced by empty().

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

◆ end()

const iterator & gum::SequenceImplementation< Key, Gen >::end ( ) const
noexceptinherited

Returns the unsafe end iterator.

Returns
Returns the unsafe end iterator.

References end().

Referenced by gum::InfluenceDiagramGenerator< GUM_SCALAR >::_checkTemporalOrder_(), gum::InfluenceDiagram< GUM_SCALAR >::decisionOrderExists(), gum::Sequence< Key >::diffSet(), and end().

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

◆ endSafe()

const iterator_safe & gum::SequenceImplementation< Key, Gen >::endSafe ( ) const
noexceptinherited

Returns the safe end iterator.

Returns
Returns the safe end iterator.

References endSafe().

Referenced by endSafe().

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

◆ erase() [1/2]

void gum::SequenceImplementation< Key, Gen >::erase ( const iterator_safe & k)
inherited

Remove from the sequence the element pointed to by the iterator.

If the element cannot be found, the function does nothing. In particular, it throws no exception. Complexity \(o(n)\) (need to change the position of at most the n elements)

Parameters
kThe iterator poiting to the element to remove.

References erase().

Here is the call graph for this function:

◆ erase() [2/2]

void gum::SequenceImplementation< Key, Gen >::erase ( const Key & k)
inherited

Remove an element from the sequence.

If the element cannot be found, the function does nothing. In particular, it throws no exception. Complexity \(o(n)\) (need to change the position of at most the n elements).

Parameters
kThe element to remove.

References erase().

Referenced by gum::prm::StructuredInference< GUM_SCALAR >::_removeBarrenNodes_(), erase(), and erase().

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

◆ exists()

bool gum::SequenceImplementation< Key, Gen >::exists ( const Key & k) const
inherited

Check the existence of k in the sequence.

The complexity is \(o(1)\).

Parameters
kThe key to check for existence.
Returns
Returns true if k is in the gum::SequenceImplementation.

References exists().

Referenced by gum::BarrenNodesFinder::barrenNodes(), and exists().

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

◆ front()

const Key & gum::SequenceImplementation< Key, Gen >::front ( ) const
inherited

Returns the first element of the element.

Returns
Returns the first element of the element.
Exceptions
NotFoundRaised if the sequence is empty.

References front().

Referenced by front().

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

◆ insert() [1/2]

void gum::SequenceImplementation< Key, Gen >::insert ( const Key & k)
inherited

Insert an element at the end of the sequence.

The complexity is \(o(1)\).

Parameters
kThe element to insert.
Exceptions
DuplicateElementRaised if the sequence contains already k.

References insert().

Referenced by gum::prm::StructuredInference< GUM_SCALAR >::_removeBarrenNodes_(), gum::BarrenNodesFinder::barrenNodes(), gum::InfluenceDiagram< GUM_SCALAR >::getChildrenDecision_(), insert(), and insert().

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

◆ insert() [2/2]

void gum::SequenceImplementation< Key, Gen >::insert ( Key && k)
inherited

Move an element at the end of the sequence.

The complexity is \(o(1)\).

Parameters
kThe element to insert.
Exceptions
DuplicateElementRaised if the sequence contains already k.

References insert().

Here is the call graph for this function:

◆ operator!=()

bool gum::SequenceImplementation< Key, Gen >::operator!= ( const SequenceImplementation< Key, Gen > & k) const
inherited

Returns true if the content of k is different from that of *this.

Note that two sequences are equal if and only if they contain the same variables (using Key::operator==) in the same order.

Parameters
kThe other gum::SequenceImplementation.

Returns true if both gum::SequenceImplementation are not equal.

References SequenceImplementation().

Here is the call graph for this function:

◆ operator<<() [1/2]

SequenceImplementation< Key, Gen > & gum::SequenceImplementation< Key, Gen >::operator<< ( const Key & k)
inherited

Insert k at the end of the sequence (synonym for insert).

Parameters
kThe key we wish to insert in the sequence.
Returns
Returns this gum::SequenceImplementation.
Exceptions
DuplicateElementRaised if the sequence contains already k.

References SequenceImplementation().

Here is the call graph for this function:

◆ operator<<() [2/2]

SequenceImplementation< Key, Gen > & gum::SequenceImplementation< Key, Gen >::operator<< ( Key && k)
inherited

Insert k at the end of the sequence (synonym for insert).

Parameters
kThe key we wish to insert in the sequence.
Returns
Returns this gum::SequenceImplementation.
Exceptions
DuplicateElementRaised if the sequence contains already k.

◆ operator=() [1/2]

template<typename Key>
INLINE Sequence< Key > & gum::Sequence< Key >::operator= ( const Sequence< Key > & aSeq)

Copy operator.

Parameters
aSeqThe sequence to copy.
Returns
Returns a ref to this.

Definition at line 1030 of file sequence_tpl.h.

1030 {
1032 return *this;
1033 }
SequenceImplementation< Key, Gen > & operator=(const SequenceImplementation< Key, Gen > &aSeq)
Copy operator.

References gum::SequenceImplementation< Key, Gen >::operator=(), and gum::SequenceImplementation< Key, std::is_scalar< Key >::value >::Sequence< Key >.

Here is the call graph for this function:

◆ operator=() [2/2]

template<typename Key>
INLINE Sequence< Key > & gum::Sequence< Key >::operator= ( Sequence< Key > && aSeq)

Move operator.

Parameters
aSeqThe sequence to move.
Returns
Returns a ref to this.

Definition at line 1037 of file sequence_tpl.h.

1037 {
1039 return *this;
1040 }

References gum::SequenceImplementation< Key, Gen >::operator=(), and gum::SequenceImplementation< Key, std::is_scalar< Key >::value >::Sequence< Key >.

Here is the call graph for this function:

◆ operator==()

bool gum::SequenceImplementation< Key, Gen >::operator== ( const SequenceImplementation< Key, Gen > & k) const
inherited

Returns true if the content of k equals that of *this.

Note that two sequences are equal if and only if they contain the same Keys (using Key::operator==) in the same order.

Parameters
kThe other gum::SequenceImplementation.

Returns true if both gum::SequenceImplementation are equal.

References SequenceImplementation().

Here is the call graph for this function:

◆ operator>>()

SequenceImplementation< Key, Gen > & gum::SequenceImplementation< Key, Gen >::operator>> ( const Key & k)
inherited

Remove k in the sequence (synonym for erase).

If the element cannot be found, the function does nothing. In particular, it throws no exception.

Parameters
kThe key we wish to remove.
Returns
Returns this gum::SequenceImplementation.

References SequenceImplementation().

Here is the call graph for this function:

◆ operator[]()

const Key & gum::SequenceImplementation< Key, Gen >::operator[] ( Idx i) const
inherited

Returns the element at position i (synonym for atPos).

Parameters
iThe position of the element to return.
Returns
Returns the element at position i.
Exceptions
OutOfBoundsRaised if the element does not exist.

◆ pos()

Idx gum::SequenceImplementation< Key, Gen >::pos ( const Key & key) const
inherited

Returns the position of the object passed in argument (if it exists).

Parameters
keyThe element for which the positon is returned.
Returns
Returns the position of the object passed in argument.
Exceptions
NotFoundRaised if the element does not exist.

References pos().

Referenced by gum::learning::IBNLearner::learnDag_(), and pos().

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

◆ rbegin()

iterator gum::SequenceImplementation< Key, Gen >::rbegin ( ) const
inherited

Returns an unsafe rbegin iterator.

Returns
Returns an unsafe rbegin iterator.

References rbegin().

Referenced by rbegin().

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

◆ rbeginSafe()

iterator_safe gum::SequenceImplementation< Key, Gen >::rbeginSafe ( ) const
inherited

Returns a safe rbegin iterator.

Returns
Returns a safe rbegin iterator.

References rbeginSafe().

Referenced by rbeginSafe().

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

◆ rend()

const iterator & gum::SequenceImplementation< Key, Gen >::rend ( ) const
noexceptinherited

Returns the unsafe rend iterator.

Returns
Returns the unsafe rend iterator.

References rend().

Referenced by rend().

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

◆ rendSafe()

const iterator_safe & gum::SequenceImplementation< Key, Gen >::rendSafe ( ) const
noexceptinherited

Returns the safe rend iterator.

Returns
Returns the safe rend iterator.

References rendSafe().

Referenced by rendSafe().

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

◆ resize()

void gum::SequenceImplementation< Key, Gen >::resize ( Size new_size)
inherited

Modifies the size of the internal structures of the sequence.

This function is provided for optimization issues. When you know you will have to insert elements into the sequence, it may be faster to use this function prior to the additions because it will change once and for all the sizes of all the internal containers. Note that if you provide a size that is smaller than the number of elements of the sequence, the function will not modify anything.

Parameters
new_sizeThe internal structure new size.

References resize().

Referenced by resize().

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

◆ setAtPos() [1/2]

void gum::SequenceImplementation< Key, Gen >::setAtPos ( Idx i,
const Key & newKey )
inherited

Change the value.

Parameters
iThe element's position.
newKeyThe element's new value.
Exceptions
NotFoundRaised if the element does not exist.
DuplicateElementRaised if newKey alreay exists.

References setAtPos().

Referenced by setAtPos(), and setAtPos().

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

◆ setAtPos() [2/2]

void gum::SequenceImplementation< Key, Gen >::setAtPos ( Idx i,
Key && newKey )
inherited

Change the value.

Parameters
iThe element's position.
newKeyThe element's new value.
Exceptions
NotFoundRaised if the element does not exist.
DuplicateElementRaised if newKey alreay exists.

References setAtPos().

Here is the call graph for this function:

◆ size()

Size gum::SequenceImplementation< Key, Gen >::size ( ) const
noexceptinherited

Returns the size of the sequence.

Returns
Returns the size of the sequence.

References size().

Referenced by gum::prm::StructuredInference< GUM_SCALAR >::_removeBarrenNodes_(), gum::BarrenNodesFinder::barrenNodes(), and size().

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

◆ swap()

void gum::SequenceImplementation< Key, Gen >::swap ( Idx i,
Idx j )
inherited

Swap index.

Parameters
iThe index of the first elt to swap.
jThe index of the other elt to swap.

References swap().

Referenced by swap().

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

◆ toString()

std::string gum::SequenceImplementation< Key, Gen >::toString ( ) const
inherited

Displays the content of the sequence.

Returns
The content of the sequence.

References toString().

Referenced by gum::ActionSet::operator<<, gum::ArgMaxSet< GUM_SCALAR_VAL, GUM_SCALAR_SEQ >::operator<<, and toString().

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

Member Data Documentation

◆ _end_safe_

SequenceIteratorSafe< Key > gum::SequenceImplementation< Key, Gen >::_end_safe_
privateinherited

Stores the end iterator for fast access.

Definition at line 498 of file sequence.h.

Referenced by _insert_().

◆ _h_

HashTable< Key, Idx > gum::SequenceImplementation< Key, Gen >::_h_
privateinherited

Keep track of the position of the element in v (for fast retrieval).

Definition at line 488 of file sequence.h.

Referenced by _insert_(), and emplace().

◆ _rend_safe_

SequenceIteratorSafe< Key > gum::SequenceImplementation< Key, Gen >::_rend_safe_
privateinherited

Stores the rend iterator for fast access.

Definition at line 501 of file sequence.h.

Referenced by _insert_().

◆ _v_

std::vector< Key* > gum::SequenceImplementation< Key, Gen >::_v_
privateinherited

The set of the elements stored into the sequence.

Definition at line 491 of file sequence.h.

Referenced by _insert_(), and emplace().


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