Luna::UnorderedSet
An container that contains a set of unique objects using closed-addressing hashing algorithm.
template <typename _Kty, typename _Hash, typename _KeyEqual, typename _Alloc>
class Luna::UnorderedSet
Remark
See remarks of HashMap for details.
Member functions
-
Constructs an empty set.
-
UnorderedSet(const allocator_type &alloc)
Constructs an empty set with an custom allocator.
-
UnorderedSet(const UnorderedSet &rhs)
Constructs a set by coping elements from another set.
-
UnorderedSet(const UnorderedSet &rhs, const allocator_type &alloc)
Constructs a set with an custom allocator and with elements copied from another set.
-
UnorderedSet(UnorderedSet &&rhs)
Constructs a set by moving elements from another set.
-
UnorderedSet(UnorderedSet &&rhs, const allocator_type &alloc)
Constructs a set with an custom allocator and with elements moved from another set.
-
UnorderedSet & operator=(const UnorderedSet &rhs)
Replaces elements of the set by coping elements from another set.
-
UnorderedSet & operator=(UnorderedSet &&rhs)
Replaces elements of the set by moving elements from another set.
-
Gets one iterator to the first element of the set.
-
Gets one constant iterator to the first element of the set.
-
Gets one constant iterator to the first element of the set.
-
Gets one iterator to the one past last element of the set.
-
Gets one constant iterator to the one past last element of the set.
-
Gets one constant iterator to the one past last element of the set.
-
Gets an iterator to the first element of the bucket with specified index.
-
const_local_iterator begin(usize n) const
Gets an constant iterator to the first element of the bucket with specified index.
-
const_local_iterator cbegin(usize n) const
Gets a constant iterator to the first element of the bucket with specified index.
-
Gets an iterator to the one-past-last element of the bucket with specified index.
-
const_local_iterator end(usize n) const
Gets a constant iterator to the one-past-last element of the bucket with specified index.
-
const_local_iterator cend(usize n) const
Gets a constant iterator to the one-past-last element of the bucket with specified index.
-
Checks whether this set is empty, that is, the size of this set is
0
. -
Gets the size of the set, that is, the number of elements in the set.
-
Gets the capacity of the set, that is, the number of elements the hash table can hold before expanding the hash table.
-
Gets the number of buckets of the set.
-
usize bucket_size(usize n) const
Gets the number of elements of the specified bucket.
-
usize bucket(const key_type &key) const
Gets the index of the bucket that stores the specified key.
-
Gets the load factor of the set, which can be computed by
(f32)size() / (f32)bucket_count()
. -
Gets the maximum load factor allowed for the set.
-
Sets the maximum load factor allowed for the set.
-
Removes all elements in the set.
-
Gets the hash function used by this set.
-
Gets the equality comparison function used by this set.
-
void rehash(usize new_buckets_count)
Changes the bucket count and rehashes all elements to insert them to the new buckets.
-
Expands the bucket buffer so that it can store at least
new_cap
elements without enpanding the bucket buffer again. -
iterator find(const key_type &key)
Finds the specified element in the set.
-
const_iterator find(const key_type &key) const
Finds the specified element in the set.
-
usize count(const key_type &key) const
Gets the number of elements whose key is equal to the specified key.
-
Pair< iterator, iterator > equal_range(const key_type &key)
Gets one pair of iterators specifying one range of elements whose keys are equal to the specified key.
-
Pair< const_iterator, const_iterator > equal_range(const key_type &key) const
Gets one pair of iterators specifying one range of elements whose keys are equal to the specified key.
-
bool contains(const key_type &key) const
Checks whether at least one element with the specified key exists.
-
Pair< iterator, bool > insert(const value_type &value)
Inserts the specified value to the set. The key is extracted from the value.
-
Pair< iterator, bool > insert(value_type &&value)
Inserts the specified value to the set. The key is extracted from the value.
-
insert_return_type insert(node_type &&node)
Inserts one node to the set.
-
Pair< iterator, bool > insert_or_assign(const key_type &key, _M &&value)
Assigns the value to the element with the specified key, or inserts the value pair to the set if such element is not found. The key is extracted from the value.
-
Pair< iterator, bool > insert_or_assign(key_type &&key, _M &&value)
Assigns the value to the element with the specified key, or inserts the value pair to the set if such element is not found. The key is extracted from the value.
-
Pair< iterator, bool > emplace(_Args &&... args)
Constructs one element directly in the set using the provided arguments.
-
iterator erase(const_iterator pos)
Removes one element from the set.
-
usize erase(const key_type &key)
Removes elements with the specified key from the set.
-
Swaps elements of this set with the specified set.
-
node_type extract(const_iterator pos)
Extracts one node from the set, so that it can be inserted to another set without any element copy or move operation.
-
allocator_type get_allocator() const
Gets the allocator used by this set.