Association map

template<concepts::device TDev = clue::Device>
class AssociationMap

The AssociationMap class is a data structure that maps keys to values. It associates integer keys with integer values in ono-to-many or many-to-many associations.

Template Parameters:
concepts::device TDev = clue::Device

The device type to use for the allocation. Defaults to clue::Device.

Public Types

using key_type = int32_t
using mapped_type = int32_t
using value_type = std::pair<key_type, mapped_type>
using size_type = std::size_t
using iterator = mapped_type*
using const_iterator = const mapped_type*
using keys_container_type = device_buffer<TDev, key_type[]>
using mapped_container_type = device_buffer<TDev, mapped_type[]>

Public Functions

AssociationMap() = default

Construct an empty AssociationMap.

AssociationMap(size_type nelements, size_type nbins)

Construct an AssociationMap with a specific number of elements and bins.

Note

This constructor is only available for the CPU device

Parameters:
size_type nelements

The number of elements to allocate

size_type nbins

The number of bins to allocate

AssociationMap(size_type nelements, size_type nbins, const TDev &dev)

Construct an AssociationMap with a specific number of elements and bins.

Parameters:
size_type nelements

The number of elements to allocate

size_type nbins

The number of bins to allocate

const TDev &dev

The device to use for the allocation

template<concepts::queue TQueue>
AssociationMap(size_type nelements, size_type nbins, TQueue &queue)

Construct an AssociationMap with a specific number of elements and bins.

Parameters:
size_type nelements

The number of elements to allocate

size_type nbins

The number of bins to allocate

TQueue &queue

The queue to use for the allocation

auto size() const

Return the number of bins in the map.

Returns:

The number of bins in the map

auto extents() const

Return the extents of the internal buffers.

Returns:

A struct containing the number of keys and values in the map

iterator begin()

Return iterator to the beginning of the content buffer.

Returns:

An iterator to the beginning of the content buffer

const_iterator begin() const

Return const iterator to the beginning of the content buffer.

Returns:

A const iterator to the beginning of the content buffer

const_iterator cbegin() const

Return const iterator to the beginning of the content buffer.

Returns:

A const iterator to the beginning of the content buffer

iterator end()

Return iterator to the end of the content buffer.

Returns:

An iterator to the end of the content buffer

const_iterator end() const

Return const iterator to the end of the content buffer.

Returns:

A const iterator to the end of the content buffer

const_iterator cend() const

Return const iterator to the end of the content buffer.

Returns:

A const iterator to the end of the content buffer

iterator find(key_type key)
const_iterator find(key_type key) const
size_type count(key_type key) const

Count the number of elements with the given key.

Parameters:
key_type key

The key to count

Returns:

The number of elements associated to a given key

bool contains(key_type key) const

Check if the map contains elements with a given key.

Parameters:
key_type key

The key to check

Returns:

True if the map contains elements with the given key, false otherwise

iterator lower_bound(key_type key)

Get the iterator to the first element with a given key.

Parameters:
key_type key

The key to search for

Returns:

An iterator to the first element with the given key

const_iterator lower_bound(key_type key) const

Get the const iterator to the first element with a given key.

Parameters:
key_type key

The key to search for

Returns:

A const iterator to the first element with the given key

iterator upper_bound(key_type key)

Get the iterator to the first element with a key greater than the given key.

Parameters:
key_type key

The key to search for

Returns:

An iterator to the first element with a key greater than the given key

const_iterator upper_bound(key_type key) const

Get the const iterator to the first element with a key greater than the given key.

Parameters:
key_type key

The key to search for

Returns:

A const iterator to the first element with a key greater than the given key

std::pair<iterator, iterator> equal_range(key_type key)

Get the range of elements with a given key.

Parameters:
key_type key

The key to search for

Returns:

A pair of iterators representing the range of elements with the given key

std::pair<const_iterator, const_iterator> equal_range(key_type key) const

Get the const range of elements with a given key.

Parameters:
key_type key

The key to search for

Returns:

A pair of const iterators representing the range of elements with the given key

Containers extract() const

Get a const-reference to the underlying containers.

Returns:

A Containers object

const AssociationMapView &view() const

Get the constant view of the association map.

Returns:

A const reference to the AssociationMapView

AssociationMapView &view()

Get the view of the association map.

Returns:

A reference to the AssociationMapView

Friends

friend class internal::Tiles
struct Containers

Public Members

const keys_container_type &keys
const mapped_container_type &values
struct Extents

Public Members

size_type keys
size_type values