Template Class hashed_sparse_set

Class Documentation

template<typename value_type, typename hash_type = std::hash<value_type>, template<typename...> typename dense_type = std::vector, template<typename...> typename sparse_type = std::unordered_map>
class legion::core::hashed_sparse_set

Quick lookup contiguous map. The map is based on the concept of a sparse set and thus inherits it’s lookup complexity and contiguous nature.

Note

With default container parameters iterators may be invalidated upon resize. See reference of std::vector.

Note

Removing item might invalidate the iterator of the last item in the dense container.

Template Parameters
  • value_type: The type to be used as the value.

  • dense_type: Container to be used to store the values.

  • sparse_type: Container to be used to store the keys.

Public Types

using self_type = hashed_sparse_set<value_type, hash_type, dense_type, sparse_type>
using self_reference = self_type&
using self_const_reference = const self_type&
using value_reference = value_type&
using value_const_reference = const value_type&
using value_pointer = value_type*
using sparse_container = sparse_type<value_type, size_type, hash_type>
using dense_container = dense_type<value_type>
using iterator = typename dense_container::iterator
using const_iterator = typename dense_container::const_iterator
using reverse_iterator = typename dense_container::reverse_iterator
using const_reverse_iterator = typename dense_container::const_reverse_iterator

Public Functions

inline dense_container &dense()
inline const dense_container &dense() const
inline iterator begin()
inline const_iterator begin() const
inline const_iterator cbegin() const
inline iterator end()
inline const_iterator end() const
inline const_iterator cend() const
inline reverse_iterator rbegin()
inline const_reverse_iterator rbegin() const
inline const_reverse_iterator crbegin() const
inline reverse_iterator rend()
inline const_reverse_iterator rend() const
inline const_reverse_iterator crend() const
inline pair_range<reverse_iterator> reverse_range()
inline pair_range<const_reverse_iterator> reverse_range() const
inline size_type size() const noexcept

Returns the amount of items in the sparse_map.

Return

size_type Current amount of items contained in sparse_map.

inline size_type capacity() const noexcept

Returns the capacity of items the sparse_map could at least store without invalidating the iterators.

Return

size_type Current capacity of the dense container.

inline size_type max_size() const noexcept

Returns the maximum number of items the hashed_sparse_set could at most store without crashing.

Note

This value typically reflects the theoretical limit on the size of the container, at most std::numeric_limits<difference_type>::max(). At runtime, the size of the container may be limited to a value smaller than max_size() by the amount of RAM available.

Return

size_type

inline bool empty() const noexcept

Returns whether the sparse_map is empty.

Return

bool True if the sparse_map is empty, otherwise false.

inline void clear() noexcept

Clears sparse_map.

Note

Will not update capacity.

inline void reserve(size_type size)

Reserves space in dense container for more items.

Note

Will update capacity if resize happened.

Parameters
  • size: Amount of items to reserve space for (would be the new capacity).

inline size_type count(value_const_reference val) const

Returns the amount of items of a certain value.

Return

size_type Amount of items of the same value (either 0 or 1).

Note

Function is only available for compatibility reasons, it is advised to use contains instead. legion::core::sparse_map::contains

Parameters
  • val: Value to look for.

inline size_type count(value_type &&val) const

Returns the amount of items of a certain value.

Return

size_type Amount of items of the same value (either 0 or 1).

Note

Function is only available for compatibility reasons, it is advised to use contains instead. legion::core::sparse_map::contains

Parameters
  • val: Value to look for.

inline bool contains(value_const_reference val) const

Checks whether a certain value is contained in the sparse_map.

Return

bool True if the value was found, otherwise false.

Parameters
  • val: Value to check for.

inline bool contains(value_type &&val) const

Checks whether a certain value is contained in the sparse_map.

Return

bool True if the value was found, otherwise false.

Parameters
  • val: Value to check for.

inline bool contains(const hashed_sparse_set<value_type> &other) const

Checks if all items in hashed_sparse_set are inside this set as well.

Return

bool True if all items in other are also in this hashed_sparse_set, otherwise false.

Parameters

inline bool equals(self_const_reference other) const

Checks if all items are the same for both hashed_sparse_sets.

Return

bool True if both sets are the same size and contain the same items, otherwise false.

Parameters

inline bool operator==(self_const_reference other) const

Checks if all items are the same for both hashed_sparse_sets.

Return

bool True if both sets are the same size and contain the same items, otherwise false.

Parameters

inline iterator find(value_const_reference val)

Finds the iterator of a value using std::find.

Return

Iterator to the value if found, otherwise end.

Parameters
  • val: Value to find.

inline const_iterator find(value_const_reference val) const

Finds the iterator of a value using std::find.

Return

Iterator to the value if found, otherwise end.

Parameters
  • val: Value to find.

inline std::pair<iterator, bool> insert(value_const_reference val)

Inserts new item into hashed_sparse_set.

Return

std::pair<iterator, bool> Iterator at the location of the val and true if succeeded, end and false if it didn’t succeed.

Parameters
  • val: Value to insert.

inline std::pair<iterator, bool> insert(value_type &&val)

Inserts new item into hashed_sparse_set.

Return

std::pair<iterator, bool> Iterator at the location of the val and true if succeeded, end and false if it didn’t succeed.

Parameters
  • val: Value to insert.

template<typename ...Arguments>
inline std::pair<iterator, bool> emplace(Arguments&&... arguments)

Construct item in place.

Parameters
  • arguments: Arguments to pass to the item constructor.

inline value_reference operator[](size_type &&index)

Returns item from dense container.

Parameters
  • index: Index of item in dense container.

inline value_reference operator[](const size_type &index)

Returns item from dense container.

Parameters
  • index: Index of item in dense container.

inline value_const_reference operator[](size_type &&index) const

Returns item from dense container.

Parameters
  • index: Index of item in dense container.

inline value_const_reference operator[](const size_type &index) const

Returns item from dense container.

Parameters
  • index: Index of item in dense container.

inline value_reference at(size_type &&index)

Returns item from dense container.

Parameters
  • index: Index of item in dense container.

inline value_reference at(const size_type &index)

Returns item from dense container.

Parameters
  • index: Index of item in dense container.

inline value_const_reference at(size_type &&index) const

Returns item from dense container.

Parameters
  • index: Index of item in dense container.

inline value_const_reference at(const size_type &index) const

Returns item from dense container.

Parameters
  • index: Index of item in dense container.

inline size_type erase(value_const_reference val)

Erases item from sparse_map.

Parameters
  • val: Value that needs to be erased.