4.1.0
Freundlich's C++ toolkit
Public Types | Public Member Functions
fcppt::container::index_map< T, A > Class Template Reference

Detailed Description

template<typename T, typename A>
class fcppt::container::index_map< T, A >

An index-based container that grows on demand.

This container is a wrapper around a vector that grows on demand. If the container is accessed with an out-of-bounds index, it inserts a new element first. This is most useful with fcppt::optional::object.

Template Parameters
TThe element type.
AThe allocator type.

Public Types

using internal_type = std::vector< T, A >
 
using size_type = typename internal_type::size_type
 
using reference = typename internal_type::reference
 
using insert_function = fcppt::function< T()>
 

Public Member Functions

 index_map ()
 
reference get (size_type index, insert_function insert)
 Returns the element at an index or inserts new ones using a function. More...
 
reference operator[] (size_type index)
 Returns the element at an index or inserts new default-constructed one. More...
 
internal_type const & impl () const
 

Member Typedef Documentation

◆ insert_function

template<typename T , typename A >
using fcppt::container::index_map< T, A >::insert_function = fcppt::function<T()>

◆ internal_type

template<typename T , typename A >
using fcppt::container::index_map< T, A >::internal_type = std::vector<T, A>

◆ reference

template<typename T , typename A >
using fcppt::container::index_map< T, A >::reference = typename internal_type::reference

◆ size_type

template<typename T , typename A >
using fcppt::container::index_map< T, A >::size_type = typename internal_type::size_type

Constructor & Destructor Documentation

◆ index_map()

template<typename T , typename A >
fcppt::container::index_map< T, A >::index_map ( )

Member Function Documentation

◆ get()

template<typename T , typename A >
reference fcppt::container::index_map< T, A >::get ( size_type  index,
insert_function  insert 
)

Returns the element at an index or inserts new ones using a function.

Returns the element at index. If there is no such element, the result of insert() is inserted. Note that insert might be called multiple times.

◆ impl()

template<typename T , typename A >
internal_type const & fcppt::container::index_map< T, A >::impl ( ) const

◆ operator[]()

template<typename T , typename A >
reference fcppt::container::index_map< T, A >::operator[] ( size_type  index)

Returns the element at an index or inserts new default-constructed one.

Returns the element at index. If there is no such element, T() is inserted.