mcrl2::utilities::indexed_set =============================================================================== Include file: .. code-block:: c++ #include "mcrl2/utilities/indexed_set.h .. cpp:class:: mcrl2::utilities::indexed_set A set that assigns each element an unique index. Public types ------------------------------------------------------------------------------- .. cpp:type:: mcrl2::utilities::indexed_set::const_iterator typedef for :cpp:type:`std::deque\< Key >::const_iterator` .. cpp:type:: mcrl2::utilities::indexed_set::const_reverse_iterator typedef for :cpp:type:`std::deque\< Key >::const_reverse_iterator` .. cpp:type:: mcrl2::utilities::indexed_set::difference_type typedef for :cpp:type:`std::ptrdiff_t` .. cpp:type:: mcrl2::utilities::indexed_set::hasher typedef for :cpp:type:`Hash` .. cpp:type:: mcrl2::utilities::indexed_set::iterator typedef for :cpp:type:`std::deque\< Key >::iterator` .. cpp:type:: mcrl2::utilities::indexed_set::key_equal typedef for :cpp:type:`Equals` .. cpp:type:: mcrl2::utilities::indexed_set::key_type typedef for :cpp:type:`Key` .. cpp:type:: mcrl2::utilities::indexed_set::pointer typedef for :cpp:type:`value_type *` .. cpp:type:: mcrl2::utilities::indexed_set::reference typedef for :cpp:type:`value_type &` .. cpp:type:: mcrl2::utilities::indexed_set::reverse_iterator typedef for :cpp:type:`std::deque\< Key >::reverse_iterator` .. cpp:type:: mcrl2::utilities::indexed_set::size_type typedef for :cpp:type:`std::size_t` .. cpp:type:: mcrl2::utilities::indexed_set::value_type typedef for :cpp:type:`std::pair\< const key_type, size_type >` Public attributes ------------------------------------------------------------------------------- .. cpp:member:: const typedef value_type * mcrl2::utilities::indexed_set::const_pointer .. cpp:member:: const typedef value_type & mcrl2::utilities::indexed_set::const_reference Private attributes ------------------------------------------------------------------------------- .. cpp:member:: Equals mcrl2::utilities::indexed_set::m_equals .. cpp:member:: Hash mcrl2::utilities::indexed_set::m_hasher .. cpp:member:: std::vector< std::size_t > mcrl2::utilities::indexed_set::m_hashtable .. cpp:member:: std::deque< Key, Allocator > mcrl2::utilities::indexed_set::m_keys public-static-attrib ------------------------------------------------------------------------------- .. cpp:member:: constexpr size_type mcrl2::utilities::indexed_set::npos Value returned when an element does not exist in the set. **Returns:** Value indicating non existing element, equal to std::numeric_limits::max(). Private member functions ------------------------------------------------------------------------------- .. cpp:function:: std::size_t put_in_hashtable(const Key &key, std::size_t n) Inserts the given (key, n) pair into the indexed set. .. cpp:function:: void resize_hashtable() Resizes the hash table to twice its current size. Public member functions ------------------------------------------------------------------------------- .. cpp:function:: const key_type& at(const size_type index) const Returns a reference to the mapped value. Returns an out_of_range exception if there is no element with the given key. **Parameters:** * **index** The position in the indexed set. **Returns:** The value at position index. .. cpp:function:: iterator begin() Forward iterator which runs through the elements from the lowest to the largest number. Complexity is constant per operation. .. cpp:function:: const_iterator begin() const Forward iterator which runs through the elements from the lowest to the largest number. Complexity is constant per operation. .. cpp:function:: const_iterator cbegin() const const_iterator going through the elements in the set numbered from zero upwards. .. cpp:function:: const_iterator cend() const End of the forward const_iterator. .. cpp:function:: void clear() Clears the indexed set by removing all its elements. It is not guaranteed that the memory is released too. .. cpp:function:: const_iterator crbegin() const Reverse const_iterator going through the elements from the highest to the lowest numbered element. .. cpp:function:: const_iterator crend() const End of the reverse const_iterator. .. cpp:function:: iterator end() End of the forward iterator. .. cpp:function:: const_iterator end() const End of the forward iterator. .. cpp:function:: const_iterator find(const key_type &key) const Provides an iterator to the stored key in the indexed set. **Parameters:** * **key** The key that is sought. **Returns:** An iterator to the key, otherwise end(). .. cpp:function:: size_type index(const key_type &key) const Returns a reference to the mapped value. Returns an invalid value, larger or equal than the size of the indexed set, if there is no element with the given key. .. cpp:function:: indexed_set() Constructor of an empty indexed set. Starts with a hashtable of size 128. .. cpp:function:: indexed_set(std::size_t initial_hashtable_size, const hasher &hash=hasher(), const key_equal &equals=key_equal()) Constructor of an empty index set. Starts with a hashtable of the indicated size. **Parameters:** * **initial_hashtable_size** The initial size of the hashtable. * **hash** The hash function. * **equals** The comparison function for its elements. .. cpp:function:: std::pair insert(const key_type &key) Insert a key in the indexed set and return its index. If the element was already in the set, the resulting bool is true, and the existing index is returned. Otherwise, the key is inserted in the set, and the next available index is assigned to it. **Parameters:** * **key** The key to be inserted in the set. **Returns:** The index of the key and a boolean indicating whether the element was actually inserted. .. cpp:function:: const key_type& operator[](const size_type index) const Operator that provides a const reference at the position indicated by index. **Parameters:** * **index** The position in the indexed set. **Returns:** The value at position index. .. cpp:function:: iterator rbegin() Reverse iterator going through the elements in the set from the largest to the smallest index. .. cpp:function:: iterator rend() End of the reverse iterator. .. cpp:function:: size_type size() const The number of elements in the indexed set. **Returns:** The number of elements in the indexed set.