AIToolbox
A library that offers tools for AI problem solving.
AIToolbox::IndexSkipMap< IdsContainer, Container > Class Template Reference

This class is an iterable construct on a list of ids on a given container. More...

#include <AIToolbox/Utils/IndexMap.hpp>

Public Types

using IdsStorage = std::conditional_t< OwnsIds, const IdsContainer, const std::remove_pointer_t< IdsContainer > & >
 
using value_type = typename Container::value_type
 
using iterator = IndexSkipMapIterator< std::remove_reference_t< IdsStorage >, Container >
 
using const_iterator = IndexSkipMapIterator< std::remove_reference_t< IdsStorage >, const Container >
 

Public Member Functions

template<bool Tmp = OwnsIds, std::enable_if_t< Tmp, int > = 0>
 IndexSkipMap (IdsContainer ids, Container &items)
 Basic constructor for owning iterable. More...
 
template<bool Tmp = OwnsIds, std::enable_if_t<!Tmp, int > = 0>
 IndexSkipMap (IdsContainer ids, Container &items)
 Basic constructor for non-owning iterable. More...
 
auto begin ()
 This function returns an iterator to the beginning of this filtered range. More...
 
auto begin () const
 This function returns a const_iterator to the beginning of this filtered range. More...
 
auto cbegin () const
 This function returns a const_iterator to the beginning of this filtered range. More...
 
auto end ()
 This function returns an iterator to the end of this filtered range. More...
 
auto end () const
 This function returns a const_iterator to the end of this filtered range. More...
 
auto cend () const
 This function returns a const_iterator to the end of this filtered range. More...
 
auto size () const
 This function returns the size of the range covered. More...
 

Static Public Attributes

static constexpr bool OwnsIds = !std::is_pointer_v<IdsContainer>
 The type used to contain the ids in the iterable. More...
 

Detailed Description

template<typename IdsContainer, typename Container>
class AIToolbox::IndexSkipMap< IdsContainer, Container >

This class is an iterable construct on a list of ids on a given container.

This class allows to iterate over a given subset of ids on the input container as if they were laid out continuously in a single object.

Both ids and items must be stored in containers accessible via square-brakets and ids.

By default the iterable will copy the input ids and own them. If this is not desirable (maybe one wants to change the ids over time without being forced to copy them multiple times), the class accepts a pointer to an ids container, and it will automatically store a single reference to it, rather than doing a copy.

Template Parameters
IdsContainerThe type of the input ids in the constructor.
ContainerThe type of the container to be iterated on.

Member Typedef Documentation

◆ const_iterator

template<typename IdsContainer , typename Container >
using AIToolbox::IndexSkipMap< IdsContainer, Container >::const_iterator = IndexSkipMapIterator<std::remove_reference_t<IdsStorage>, const Container>

◆ IdsStorage

template<typename IdsContainer , typename Container >
using AIToolbox::IndexSkipMap< IdsContainer, Container >::IdsStorage = std::conditional_t<OwnsIds, const IdsContainer, const std::remove_pointer_t<IdsContainer> & >

◆ iterator

template<typename IdsContainer , typename Container >
using AIToolbox::IndexSkipMap< IdsContainer, Container >::iterator = IndexSkipMapIterator<std::remove_reference_t<IdsStorage>, Container>

◆ value_type

template<typename IdsContainer , typename Container >
using AIToolbox::IndexSkipMap< IdsContainer, Container >::value_type = typename Container::value_type

Constructor & Destructor Documentation

◆ IndexSkipMap() [1/2]

template<typename IdsContainer , typename Container >
template<bool Tmp = OwnsIds, std::enable_if_t< Tmp, int > = 0>
AIToolbox::IndexSkipMap< IdsContainer, Container >::IndexSkipMap ( IdsContainer  ids,
Container &  items 
)
inline

Basic constructor for owning iterable.

This constructor stores a copy of all the ids and a reference to the container over which to iterate.

This class and its iterators do NOT perform any bound checking on the size of the container and the input ids, neither at construction nor during operation.

This class and its iterators WILL be invalidated if the item container is destroyed.

Parameters
idsThe ids to iterate over.
itemsThe items container.

◆ IndexSkipMap() [2/2]

template<typename IdsContainer , typename Container >
template<bool Tmp = OwnsIds, std::enable_if_t<!Tmp, int > = 0>
AIToolbox::IndexSkipMap< IdsContainer, Container >::IndexSkipMap ( IdsContainer  ids,
Container &  items 
)
inline

Basic constructor for non-owning iterable.

This constructor stores the pointer to the ids and items over which to iterate.

This class and its iterators do NOT perform any bound checking on the size of the container and the input ids, neither at construction nor during operation.

This class and its iterators WILL be invalidated if the ids container or the item container are destroyed.

If the ids change, all previously generated iterators are invalidated.

Parameters
idsThe ids to iterate over.
itemsThe items container.

Member Function Documentation

◆ begin() [1/2]

template<typename IdsContainer , typename Container >
auto AIToolbox::IndexSkipMap< IdsContainer, Container >::begin ( )
inline

This function returns an iterator to the beginning of this filtered range.

◆ begin() [2/2]

template<typename IdsContainer , typename Container >
auto AIToolbox::IndexSkipMap< IdsContainer, Container >::begin ( ) const
inline

This function returns a const_iterator to the beginning of this filtered range.

◆ cbegin()

template<typename IdsContainer , typename Container >
auto AIToolbox::IndexSkipMap< IdsContainer, Container >::cbegin ( ) const
inline

This function returns a const_iterator to the beginning of this filtered range.

◆ cend()

template<typename IdsContainer , typename Container >
auto AIToolbox::IndexSkipMap< IdsContainer, Container >::cend ( ) const
inline

This function returns a const_iterator to the end of this filtered range.

◆ end() [1/2]

template<typename IdsContainer , typename Container >
auto AIToolbox::IndexSkipMap< IdsContainer, Container >::end ( )
inline

This function returns an iterator to the end of this filtered range.

◆ end() [2/2]

template<typename IdsContainer , typename Container >
auto AIToolbox::IndexSkipMap< IdsContainer, Container >::end ( ) const
inline

This function returns a const_iterator to the end of this filtered range.

◆ size()

template<typename IdsContainer , typename Container >
auto AIToolbox::IndexSkipMap< IdsContainer, Container >::size ( ) const
inline

This function returns the size of the range covered.

Member Data Documentation

◆ OwnsIds

template<typename IdsContainer , typename Container >
constexpr bool AIToolbox::IndexSkipMap< IdsContainer, Container >::OwnsIds = !std::is_pointer_v<IdsContainer>
staticconstexpr

The type used to contain the ids in the iterable.

This is a constant copy of the input ids if we own them, and otherwise a const reference if we don't (and thus they can change).


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