3.0.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

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

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 >
typedef fcppt::function< T () > fcppt::container::index_map< T, A >::insert_function

◆ internal_type

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

◆ reference

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

◆ size_type

template<typename T , typename A >
typedef internal_type::size_type fcppt::container::index_map< T, A >::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.