XSTL
Loading...
Searching...
No Matches
xstd::association_map< T > Class Template Reference

#include <association_map.hpp>

Inheritance diagram for xstd::association_map< T >:

Classes

struct  containers
 
struct  Extents
 
struct  View
 

Public Types

using key_type = int32_t
 
using mapped_type = T
 
using value_type = T
 
using size_type = std::size_t
 
using iterator = value_type*
 
using const_iterator = const value_type*
 
using key_container_type = std::vector<key_type>
 
using mapped_container_type = std::vector<mapped_type>
 

Public Member Functions

 association_map (size_type values, size_type keys)
 Constructs an association map with a specified number of values and keys.
 
auto empty () const
 Checks if the association map is empty.
 
auto size () const
 Returns the number of values in the association map.
 
auto extents () const
 Returns the extents of the containers in the association map.
 
iterator begin ()
 Returns an iterator to the beginning of the values array.
 
const_iterator begin () const
 Returns a const iterator to the beginning of the values array.
 
const_iterator cbegin () const
 Returns a const iterator to the beginning of the values array.
 
iterator end ()
 Returns an iterator to the end of the values array.
 
const_iterator end () const
 
const_iterator cend () const
 Returns a const iterator to the end of the values array.
 
iterator find (key_type key)
 Returns an iterator to the first element with a specific key.
 
const_iterator find (key_type key) const
 Returns a const iterator to the first element with a specific key.
 
size_type count (key_type key) const
 Returns the number of values with a specific key.
 
bool contains (key_type key) const
 Checks if the association map contains values associated to a specific key.
 
iterator lower_bound (key_type key)
 Returns an iterator to the first element with a key not less than the specified key.
 
const_iterator lower_bound (key_type key) const
 Returns a const iterator to the first element with a key not less than the specified key.
 
iterator upper_bound (key_type key)
 Returns an iterator to the first element with a key greater than the specified key.
 
const_iterator upper_bound (key_type key) const
 Returns a const iterator to the first element with a key greater than the specified key.
 
std::pair< iterator, iterator > equal_range (key_type key)
 Returns a pair of iterators representing the range of values with a specific key.
 
std::pair< const_iterator, const_iterator > equal_range (key_type key) const
 Returns a pair of const iterators representing the range of values with a specific key.
 
void fill (std::span< key_type > keys, std::span< mapped_type > values)
 Fills the association map with keys and values from the provided spans.
 
View view ()
 Returns a view of the association map.
 

Friends

struct internal::map_interface< association_map< T > >
 

Detailed Description

template<typename T>
class xstd::association_map< T >

association_map is a map-like structure that associates keys with values. It is designed to efficiently store and retrieve values associated with integer keys.

Template Parameters
TThe type of the values stored in the association map.

Constructor & Destructor Documentation

◆ association_map()

template<typename T>
xstd::association_map< T >::association_map ( size_type values,
size_type keys )
inlineexplicit

Constructs an association map with a specified number of values and keys.

Parameters
valuesThe number of values to be stored in the association map.
keysThe number of bins (or keys) in the association map.

Member Function Documentation

◆ begin() [1/2]

template<typename T>
iterator xstd::association_map< T >::begin ( )

Returns an iterator to the beginning of the values array.

Returns
An iterator to the first element in the values array.

◆ begin() [2/2]

template<typename T>
const_iterator xstd::association_map< T >::begin ( ) const

Returns a const iterator to the beginning of the values array.

Returns
A const iterator to the first element in the values array.

◆ cbegin()

template<typename T>
const_iterator xstd::association_map< T >::cbegin ( ) const

Returns a const iterator to the beginning of the values array.

Returns
A const iterator to the first element in the values array.

◆ cend()

template<typename T>
const_iterator xstd::association_map< T >::cend ( ) const

Returns a const iterator to the end of the values array.

Returns
A const iterator to one past the last element in the values array.

◆ contains()

template<typename T>
bool xstd::association_map< T >::contains ( key_type key) const

Checks if the association map contains values associated to a specific key.

Parameters
keyThe key to check for.
Returns
True if the association map contains values for the specified key, false otherwise.

◆ count()

template<typename T>
size_type xstd::association_map< T >::count ( key_type key) const

Returns the number of values with a specific key.

Parameters
keyThe key to count.
Returns
The number of values with the specified key.

◆ empty()

template<typename T>
auto xstd::association_map< T >::empty ( ) const

Checks if the association map is empty.

Returns
True if the association map is empty, false otherwise.

◆ end()

template<typename T>
iterator xstd::association_map< T >::end ( )

Returns an iterator to the end of the values array.

Returns
An iterator to one past the last element in the values array.

◆ equal_range() [1/2]

template<typename T>
std::pair< iterator, iterator > xstd::association_map< T >::equal_range ( key_type key)

Returns a pair of iterators representing the range of values with a specific key.

Parameters
keyThe key to search for.
Returns
A pair of iterators representing the range of values with the specified key.

◆ equal_range() [2/2]

template<typename T>
std::pair< const_iterator, const_iterator > xstd::association_map< T >::equal_range ( key_type key) const

Returns a pair of const iterators representing the range of values with a specific key.

Parameters
keyThe key to search for.
Returns
A pair of const iterators representing the range of values with the specified key.

◆ extents()

template<typename T>
auto xstd::association_map< T >::extents ( ) const

Returns the extents of the containers in the association map.

Returns
An Extents object containing the number of keys and values.

◆ fill()

template<typename T>
void xstd::association_map< T >::fill ( std::span< key_type > keys,
std::span< mapped_type > values )

Fills the association map with keys and values from the provided spans.

Parameters
keysA span of keys to be associated with the values.
valuesA span of values to be associated with the keys.

◆ find() [1/2]

template<typename T>
iterator xstd::association_map< T >::find ( key_type key)

Returns an iterator to the first element with a specific key.

Parameters
keyThe key to search for.
Returns
An iterator to the first element with the specified key, or end() if not found.

◆ find() [2/2]

template<typename T>
const_iterator xstd::association_map< T >::find ( key_type key) const

Returns a const iterator to the first element with a specific key.

Parameters
keyThe key to search for.
Returns
A const iterator to the first element with the specified key, or end() if not found.

◆ lower_bound() [1/2]

template<typename T>
iterator xstd::association_map< T >::lower_bound ( key_type key)

Returns an iterator to the first element with a key not less than the specified key.

Parameters
keyThe key to search for.
Returns
An iterator to the first element with a key not less than the specified key.

◆ lower_bound() [2/2]

template<typename T>
const_iterator xstd::association_map< T >::lower_bound ( key_type key) const

Returns a const iterator to the first element with a key not less than the specified key.

Parameters
keyThe key to search for.
Returns
A const iterator to the first element with a key not less than the specified key.

◆ size()

template<typename T>
auto xstd::association_map< T >::size ( ) const

Returns the number of values in the association map.

Returns
The number of values in the association map.

◆ upper_bound() [1/2]

template<typename T>
iterator xstd::association_map< T >::upper_bound ( key_type key)

Returns an iterator to the first element with a key greater than the specified key.

Parameters
keyThe key to search for.
Returns
An iterator to the first element with a key greater than the specified key.

◆ upper_bound() [2/2]

template<typename T>
const_iterator xstd::association_map< T >::upper_bound ( key_type key) const

Returns a const iterator to the first element with a key greater than the specified key.

Parameters
keyThe key to search for.
Returns
A const iterator to the first element with a key greater than the specified key.

◆ view()

template<typename T>
View xstd::association_map< T >::view ( )

Returns a view of the association map.

Returns
A pointer to a View of the association map.

The documentation for this class was generated from the following file: