30 #ifndef GUM_SEQUENCE_H 31 #define GUM_SEQUENCE_H 33 #include <initializer_list> 35 #include <type_traits> 44 #ifndef DOXYGEN_SHOULD_SKIP_THIS 45 template <
typename Key,
typename Alloc,
bool >
46 class SequenceImplementation;
47 template <
typename Key,
typename Alloc >
49 template <
typename Key >
50 class SequenceIteratorSafe;
51 template <
typename Key >
52 using SequenceIterator = SequenceIteratorSafe< Key >;
53 template <
typename Key >
54 using SequenceConstIterator = SequenceIteratorSafe< Key >;
89 template <
typename Key,
typename Alloc,
bool Gen >
93 template <
typename K,
typename A,
bool >
150 template <
typename OtherAlloc >
249 template < typename OtherAlloc >
302 const Key& operator[](
Idx i) const;
314 template < typename OtherAlloc >
327 template < typename OtherAlloc >
351 bool empty() const noexcept;
361 bool exists(const Key& k) const;
371 void insert(const Key& k);
393 template < typename... Args >
405 void erase(const Key& k);
433 Idx pos(const Key& key) const;
467 const Key&
front() const;
474 const Key&
back() const;
503 std::vector< Key*, typename Alloc::template rebind< Key* >::other >
__v;
527 template < typename OtherAlloc >
538 #ifndef DOXYGEN_SHOULD_SKIP_THIS 560 template <
typename Key,
typename Alloc >
564 template <
typename K,
typename A,
bool >
567 friend class Sequence< Key, Alloc >;
577 using iterator = SequenceIterator< Key >;
617 template <
typename OtherAlloc >
715 template <
typename OtherAlloc >
772 template <
typename OtherAlloc >
786 template <
typename OtherAlloc >
811 bool empty()
const noexcept;
843 template <
typename... Args >
874 const Key&
atPos(Idx i)
const;
883 Idx
pos(Key key)
const;
900 void swap(Idx i, Idx j);
907 const Key&
front()
const;
914 const Key&
back()
const;
943 std::vector< Key, Alloc >
__v;
963 template <
typename OtherAlloc >
1021 template <
typename Key,
typename Alloc = std::allocator< Key > >
1060 Sequence(std::initializer_list< Key > list);
1079 template <
typename OtherAlloc >
1112 template < typename OtherAlloc >
1113 Sequence< Key, Alloc >& operator=(const
Sequence< Key, OtherAlloc >& aSeq);
1134 template < typename OtherAlloc >
1135 Set< Key, Alloc > diffSet(const
Sequence< Key, OtherAlloc >& seq) const;
1140 #ifndef DOXYGEN_SHOULD_SKIP_THIS 1144 template <
bool gen >
1145 struct SequenceIteratorGet {
1146 template <
typename Key >
1147 INLINE
static const Key& op_star(
const Key* x) {
1150 template <
typename Key >
1151 INLINE
static const Key* op_arrow(
const Key* x) {
1157 struct SequenceIteratorGet< true > {
1158 template <
typename Key >
1159 INLINE
static const Key& op_star(
const Key& x) {
1162 template <
typename Key >
1163 INLINE
static const Key* op_arrow(
const Key& x) {
1205 template <
typename Key >
1208 template <
typename K,
typename A,
bool >
1225 using Getter = SequenceIteratorGet< std::is_scalar< Key >::value >;
1241 template <
typename Alloc,
bool Gen >
1243 Idx
pos = 0) noexcept;
1264 template < typename Alloc >
1390 const Key& operator*() const;
1398 const Key* operator->() const;
1421 std::allocator< Key >,
1422 std::is_scalar< Key >::value >* __seq;
1426 void __setPos(Idx
pos) noexcept;
1429 void __setAtRend() noexcept;
1432 void __setAtEnd() noexcept;
1436 template < typename Key, typename Alloc >
1437 std::ostream& operator<<(
std::ostream& stream, const
Sequence< Key, Alloc >& s);
1442 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 1443 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 1444 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 1445 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 1451 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 1452 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 1453 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 1454 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 1461 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 1462 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 1463 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 1464 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 1470 #ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 1471 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 1472 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 1473 # ifndef GUM_NO_EXTERN_TEMPLATE_CLASS 1484 #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.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
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).
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
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.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
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.
Copyright 2005-2019 Pierre-Henri WUILLEMIN et Christophe GONZALES (LIP6) {prenom.nom}_at_lip6.fr.
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.