27 #ifndef GUM_SEQUENCE_H 28 #define GUM_SEQUENCE_H 30 #include <initializer_list> 32 #include <type_traits> 41 #ifndef DOXYGEN_SHOULD_SKIP_THIS 42 template <
typename Key,
typename Alloc,
bool >
43 class SequenceImplementation;
44 template <
typename Key,
typename Alloc >
46 template <
typename Key >
47 class SequenceIteratorSafe;
48 template <
typename Key >
49 using SequenceIterator = SequenceIteratorSafe< Key >;
50 template <
typename Key >
51 using SequenceConstIterator = SequenceIteratorSafe< Key >;
86 template <
typename Key,
typename Alloc,
bool Gen >
90 template <
typename K,
typename A,
bool >
147 template <
typename OtherAlloc >
246 template < typename OtherAlloc >
299 const Key& operator[](
Idx i) const;
311 template < typename OtherAlloc >
324 template < typename OtherAlloc >
348 bool empty() const noexcept;
358 bool exists(const Key& k) const;
368 void insert(const Key& k);
390 template < typename... Args >
402 void erase(const Key& k);
430 Idx pos(const Key& key) const;
464 const Key&
front() const;
471 const Key&
back() const;
500 std::vector< Key*, typename Alloc::template rebind< Key* >::other >
__v;
524 template < typename OtherAlloc >
535 #ifndef DOXYGEN_SHOULD_SKIP_THIS 557 template <
typename Key,
typename Alloc >
561 template <
typename K,
typename A,
bool >
564 friend class Sequence< Key, Alloc >;
574 using iterator = SequenceIterator< Key >;
614 template <
typename OtherAlloc >
712 template <
typename OtherAlloc >
769 template <
typename OtherAlloc >
783 template <
typename OtherAlloc >
808 bool empty()
const noexcept;
840 template <
typename... Args >
871 const Key&
atPos(Idx i)
const;
880 Idx
pos(Key key)
const;
897 void swap(Idx i, Idx j);
904 const Key&
front()
const;
911 const Key&
back()
const;
940 std::vector< Key, Alloc >
__v;
960 template <
typename OtherAlloc >
1018 template <
typename Key,
typename Alloc = std::allocator< Key > >
1057 Sequence(std::initializer_list< Key > list);
1076 template <
typename OtherAlloc >
1109 template < typename OtherAlloc >
1110 Sequence< Key, Alloc >& operator=(const
Sequence< Key, OtherAlloc >& aSeq);
1131 template < typename OtherAlloc >
1132 Set< Key, Alloc > diffSet(const
Sequence< Key, OtherAlloc >& seq) const;
1137 #ifndef DOXYGEN_SHOULD_SKIP_THIS 1141 template <
bool gen >
1142 struct SequenceIteratorGet {
1143 template <
typename Key >
1144 INLINE
static const Key& op_star(
const Key* x) {
1147 template <
typename Key >
1148 INLINE
static const Key* op_arrow(
const Key* x) {
1154 struct SequenceIteratorGet< true > {
1155 template <
typename Key >
1156 INLINE
static const Key& op_star(
const Key& x) {
1159 template <
typename Key >
1160 INLINE
static const Key* op_arrow(
const Key& x) {
1202 template <
typename Key >
1205 template <
typename K,
typename A,
bool >
1222 using Getter = SequenceIteratorGet< std::is_scalar< Key >::value >;
1238 template <
typename Alloc,
bool Gen >
1240 Idx
pos = 0) noexcept;
1261 template < typename Alloc >
1387 const Key& operator*() const;
1395 const Key* operator->() const;
1418 std::allocator< Key >,
1419 std::is_scalar< Key >::value >* __seq;
1423 void __setPos(Idx
pos) noexcept;
1426 void __setAtRend() noexcept;
1429 void __setAtEnd() noexcept;
1433 template < typename Key, typename Alloc >
1434 std::ostream& operator<<(
std::ostream& stream, const
Sequence< Key, Alloc >& s);
1439 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 1440 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 1441 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 1442 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 1448 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 1449 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 1450 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 1451 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 1458 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 1459 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 1460 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 1461 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 1467 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 1468 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 1469 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 1470 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 1481 #endif // GUM_SEQUENCE_H bool operator!=(const SequenceImplementation< Key, OtherAlloc, Gen > &k) const
Returns true if the content of k is different from that of *this.
Safe iterators for Sequence.
SequenceIterator< gum::prm::PRMClassElement< double > * > iterator
Idx pos(const Key &key) const
Returns the position of the object passed in argument (if it exists).
iterator begin() const
Returns an unsafe begin iterator.
iterator_safe rbeginSafe() const
Returns a safe rbegin iterator.
SequenceIterator< gum::prm::PRMClassElement< double > * > const_iterator
void clear()
Clear the sequence.
const iterator_safe & rendSafe() const noexcept
Returns the safe rend iterator.
const iterator_safe & endSafe() const noexcept
Returns the safe end iterator.
NodeId value_type
Types for STL compliance.
A recipient for a pair of key value in a gum::HashTableList.
friend class SequenceImplementation
Friends to speed up access.
void __insert(HashTableBucket< Key, Idx > &&bucket)
Insert an element at the end of the sequence.
void resize(Size new_size)
Modifies the size of the internal structures of the sequence.
Size size() const noexcept
Returns the size of the sequence.
std::bidirectional_iterator_tag iterator_category
types for STL compliance
The generic class for storing (ordered) sequences of objects.
std::ptrdiff_t difference_type
std::ptrdiff_t difference_type
static constexpr Size default_size
The default number of slots in hashtables.
bool empty() const noexcept
Return true if empty.
std::string toString() const
Displays the content of the sequence.
const NodeId * const_pointer
HashTable< Key, Idx, Alloc > __h
Keep track of the position of the element in v (for fast retrieval).
gum is the global namespace for all aGrUM entities
SequenceIteratorSafe< Key > __rend_safe
Stores the rend iterator for fast access.
The class for generic Hash Tables.
The internal class for storing (ordered) sequences of objects.
iterator_safe beginSafe() const
Returns a safe begin iterator.
void __update_end() noexcept
A method to update the end iterator after changes in the sequence.
Representation of a setA Set is a structure that contains arbitrary elements.
Template implementation file of gum::Sequence, a class for storing (ordered) sequences of objects...
const Key & operator[](Idx i) const
Returns the element at position i (synonym for atPos).
SequenceImplementation< Key, Alloc, Gen > & operator=(const SequenceImplementation< Key, Alloc, Gen > &aSeq)
Copy operator.
SequenceImplementation< Key, Alloc, Gen > & operator>>(const Key &k)
Remove k in the sequence (synonym for erase).
SequenceImplementation< Key, Alloc, Gen > & operator<<(const Key &k)
Insert k at the end of the sequence (synonym for insert).
const NodeId & const_reference
bool exists(const Key &k) const
Check the existence of k in the sequence.
std::allocator< gum::prm::PRMClassElement< double > * > allocator_type
void erase(const Key &k)
Remove an element from the sequence.
void swap(Idx i, Idx j)
Swap index.
void emplace(Args &&... args)
Emplace a new element in the sequence.
void __copy(const SequenceImplementation< Key, OtherAlloc, Gen > &aSeq)
Clears the current sequence and fill it with copies the element of aSeq.
const Key & front() const
Returns the first element of the element.
const NodeId * const_pointer
Size Idx
Type for indexes.
const NodeId & const_reference
std::vector< Key *, typename Alloc::template rebind< Key *>::other > __v
The set of the elements stored into the sequence.
std::size_t Size
In aGrUM, hashed values are unsigned long int.
const iterator & rend() const noexcept
Returns the unsafe rend iterator.
SequenceIteratorGet< std::is_scalar< NodeId >::value > Getter
The Getter used by this iterator.
const iterator & end() const noexcept
Returns the unsafe end iterator.
~SequenceImplementation() noexcept
Class destructor.
iterator rbegin() const
Returns an unsafe rbegin iterator.
void setAtPos(Idx i, const Key &newKey)
Change the value.
SequenceIteratorSafe< Key > __end_safe
Stores the end iterator for fast access.
bool operator==(const SequenceImplementation< Key, OtherAlloc, Gen > &k) const
Returns true if the content of k equals that of *this.
Class hash tables iterators.
const Key & back() const
Returns the last element of the sequence.
const Key & atPos(Idx i) const
Returns the object at the pos i.
void insert(const Key &k)
Insert an element at the end of the sequence.