2.6.0
Freundlich's C++ toolkit
Classes | Modules | Typedefs | Functions
fcppt.container

Description

Various containers and utility functions.

Classes

class  fcppt::container::dynamic_array< T, A >
 An array of dynamic size that does not initialize. More...
 
class  fcppt::container::get_or_insert_result< Reference >
 The result type of fcppt::container::get_or_insert_with_result. More...
 
class  fcppt::container::index_map< T, A >
 An index-based container that grows on demand. More...
 
class  fcppt::container::move_range< Container >
 A range that moves its elements. More...
 

Modules

 fcppt.container.bitfield
 A statically sized bitfield.
 
 fcppt.container.buffer
 A special buffer class for uninitialized memory.
 
 fcppt.container.grid
 A simple n-dimensional array.
 
 fcppt.container.raw_vector
 A container for POD types that can be initialized from a buffer.
 
 fcppt.container.tree
 A tree data structure.
 

Typedefs

template<typename Array >
using fcppt::container::array_size = fcppt::container::detail::array_size< Array >
 Gets the size of an array. More...
 
template<typename Container >
using fcppt::container::to_iterator_type = typename std::conditional< std::is_const< Container >::value, typename Container::const_iterator, typename Container::iterator >::type
 Gets the iterator type of a container. More...
 
template<typename Container >
using fcppt::container::to_mapped_type = typename std::conditional< std::is_const< Container >::value, typename Container::mapped_type const, typename Container::mapped_type >::type
 Gets the mapped type of an associative container. More...
 
template<typename Container >
using fcppt::container::to_pointer_type = typename std::conditional< std::is_const< Container >::value, typename Container::const_pointer, typename Container::pointer >::type
 Gets the pointer type of a container. More...
 
template<typename Container >
using fcppt::container::to_reference_type = typename std::conditional< std::is_const< Container >::value, typename Container::const_reference, typename Container::reference >::type
 Gets the reference type of a container. More...
 
template<typename Container >
using fcppt::container::to_value_type = typename std::conditional< std::is_const< Container >::value, typename Container::value_type const, typename Container::value_type >::type
 Gets the value type of a container. More...
 

Functions

template<typename Container >
fcppt::optional::reference< fcppt::container::to_value_type< Container >> fcppt::container::at_optional (Container &_container, typename Container::size_type const _index)
 Returns an element as an optional at a given position. More...
 
template<typename Container >
fcppt::container::to_pointer_type< Container > fcppt::container::data (Container &_container)
 Returns a pointer the beginning of a random access container. More...
 
template<typename Container >
fcppt::container::to_pointer_type< Container > fcppt::container::data_end (Container &_container)
 Returns a pointer one past the end of a random-access container> More...
 
template<typename Container , typename Key >
fcppt::optional::reference< fcppt::container::to_value_type< Container >> fcppt::container::find_opt (Container &_container, Key const &_key)
 Returns an element from a find operation or an empty optional. More...
 
template<typename Container , typename Key >
fcppt::optional::object< fcppt::container::to_iterator_type< Container >> fcppt::container::find_opt_iterator (Container &_container, Key const &_key)
 Returns an iterator from a find operation or an empty optional. More...
 
template<typename Container , typename Key >
fcppt::optional::object< fcppt::reference< fcppt::container::to_mapped_type< Container > >> fcppt::container::find_opt_mapped (Container &_container, Key const &_key)
 Returns an element from a find operation or an empty optional. More...
 
template<typename Container , typename Create >
Container::mapped_type & fcppt::container::get_or_insert (Container &_container, typename Container::key_type const &_key, Create const &_create)
 Gets from or inserts an element into a map. More...
 
template<typename Container , typename Create >
fcppt::container::get_or_insert_result< typename Container::mapped_type & > fcppt::container::get_or_insert_with_result (Container &_container, typename Container::key_type const &_key, Create const &_create)
 Gets from or inserts an element into a map and returns if it was inserted. More...
 
template<typename Container >
fcppt::container::move_range< typename std::remove_reference< Container >::type > fcppt::container::make_move_range (Container &&_container)
 Creates a move range from a container. More...
 
template<typename Container >
fcppt::optional::reference< fcppt::container::to_value_type< Container >> fcppt::container::maybe_back (Container &_container)
 Returns the back of a container as an optional. More...
 
template<typename Container >
fcppt::optional::reference< fcppt::container::to_value_type< Container >> fcppt::container::maybe_front (Container &_container)
 Returns the front of a container as an optional. More...
 
template<typename Container >
fcppt::container::detail::output< Container > fcppt::container::output (Container const &_container) noexcept
 Creates a class that has an output operator to print a container. More...
 
template<typename Container >
fcppt::optional::object< fcppt::container::to_value_type< Container >> fcppt::container::pop_back (Container &_container)
 Pops the back of a container as an optional. More...
 

Typedef Documentation

◆ array_size

template<typename Array >
using fcppt::container::array_size = typedef fcppt::container::detail::array_size< Array >

Gets the size of an array.

Derives from an integral constant that contains the size of Array.

Template Parameters
ArrayMust be a std::array

◆ to_iterator_type

template<typename Container >
using fcppt::container::to_iterator_type = typedef typename std::conditional< std::is_const< Container >::value, typename Container::const_iterator, typename Container::iterator >::type

Gets the iterator type of a container.

If Container is const, the result is Container::const_iterator. Otherwise, it is Container::iterator.

Template Parameters
ContainerA range type.

◆ to_mapped_type

template<typename Container >
using fcppt::container::to_mapped_type = typedef typename std::conditional< std::is_const< Container >::value, typename Container::mapped_type const, typename Container::mapped_type >::type

Gets the mapped type of an associative container.

If Container is const, the result is Container::mapped_type const. Otherwise, it is Container::mapped_type.

Template Parameters
ContainerAn associative container.

◆ to_pointer_type

template<typename Container >
using fcppt::container::to_pointer_type = typedef typename std::conditional< std::is_const< Container >::value, typename Container::const_pointer, typename Container::pointer >::type

Gets the pointer type of a container.

If Container is const, the result is Container::const_pointer. Otherwise, it is Container::pointer.

Template Parameters
ContainerA range type.

◆ to_reference_type

template<typename Container >
using fcppt::container::to_reference_type = typedef typename std::conditional< std::is_const< Container >::value, typename Container::const_reference, typename Container::reference >::type

Gets the reference type of a container.

If Container is const, the result is Container::const_reference. Otherwise, it is Container::reference.

Template Parameters
ContainerA range type.

◆ to_value_type

template<typename Container >
using fcppt::container::to_value_type = typedef typename std::conditional< std::is_const< Container >::value, typename Container::value_type const, typename Container::value_type >::type

Gets the value type of a container.

If Container is const, the result is Container::value_type const. Otherwise, it is Container::value_type.

Template Parameters
ContainerA range type.

Function Documentation

◆ at_optional()

template<typename Container >
fcppt::optional::reference< fcppt::container::to_value_type< Container >> fcppt::container::at_optional ( Container &  _container,
typename Container::size_type const  _index 
)

Returns an element as an optional at a given position.

If _index is in the range of _container, the element at _index is returned. Otherwise, the result is the empty optional.

Template Parameters
ContainerMust be a random-access container.

◆ data()

template<typename Container >
fcppt::container::to_pointer_type< Container> fcppt::container::data ( Container &  _container)

Returns a pointer the beginning of a random access container.

Returns a pointer the beginning of _container, or the null pointer if _container is empty.

Template Parameters
ContainerMust be a random-access container.

◆ data_end()

template<typename Container >
fcppt::container::to_pointer_type< Container> fcppt::container::data_end ( Container &  _container)

Returns a pointer one past the end of a random-access container>

Returns a pointer to one past the end of _container, or the null pointer if _container is empty.

Template Parameters
ContainerMust be a random-access container.

◆ find_opt()

template<typename Container , typename Key >
fcppt::optional::reference< fcppt::container::to_value_type< Container >> fcppt::container::find_opt ( Container &  _container,
Key const &  _key 
)
inline

Returns an element from a find operation or an empty optional.

Searches for _key in the associative container _container. If _key is found, the corresponding mapped type is returned. Otherwise, the empty optional is returned.

Template Parameters
ContainerMust be an associative container.
KeyMust be a key that can be searched for.

◆ find_opt_iterator()

template<typename Container , typename Key >
fcppt::optional::object< fcppt::container::to_iterator_type< Container >> fcppt::container::find_opt_iterator ( Container &  _container,
Key const &  _key 
)

Returns an iterator from a find operation or an empty optional.

Searches for _key in the associative container _container. If _key is found, its iterator is returned. Otherwise, the empty optional is returned.

Template Parameters
ContainerMust be an associative container.
KeyMust be a key that can be searched for.

◆ find_opt_mapped()

template<typename Container , typename Key >
fcppt::optional::object< fcppt::reference< fcppt::container::to_mapped_type< Container > >> fcppt::container::find_opt_mapped ( Container &  _container,
Key const &  _key 
)
inline

Returns an element from a find operation or an empty optional.

Searches for _key in the associative container _container. If _key is found, the corresponding mapped object is returned. Otherwise, the empty optional is returned.

Template Parameters
ContainerMust be an associative container.
KeyMust be a key that can be searched for.

◆ get_or_insert()

template<typename Container , typename Create >
Container::mapped_type& fcppt::container::get_or_insert ( Container &  _container,
typename Container::key_type const &  _key,
Create const &  _create 
)
inline

Gets from or inserts an element into a map.

Tries to find _key in _container. If the mapped object is found, it is returned. Otherwise, _create is called with _a key to create a new mapped object which is then inserted into _container and returned.

Template Parameters
ContainerAn associative container.
CreateA function of type Container::mapped_type (Container::key_type).

◆ get_or_insert_with_result()

template<typename Container , typename Create >
fcppt::container::get_or_insert_result< typename Container::mapped_type &> fcppt::container::get_or_insert_with_result ( Container &  _container,
typename Container::key_type const &  _key,
Create const &  _create 
)

Gets from or inserts an element into a map and returns if it was inserted.

Tries to find _key in _container. If the mapped object is found, it is returned and inserted is true. Otherwise, _create is called with _a key to create a new mapped object which is then inserted into _container and returned along with inserted as false.

Template Parameters
ContainerAn associative container>
CreateA function of type Container::mapped_type (Container::key_type).

◆ make_move_range()

template<typename Container >
fcppt::container::move_range< typename std::remove_reference< Container >::type> fcppt::container::make_move_range ( Container &&  _container)
inline

Creates a move range from a container.

Parameters
_containerMust be an rvalue reference to a container.
Template Parameters
ContainerA container type.

◆ maybe_back()

template<typename Container >
fcppt::optional::reference< fcppt::container::to_value_type< Container >> fcppt::container::maybe_back ( Container &  _container)

Returns the back of a container as an optional.

◆ maybe_front()

template<typename Container >
fcppt::optional::reference< fcppt::container::to_value_type< Container >> fcppt::container::maybe_front ( Container &  _container)

Returns the front of a container as an optional.

◆ output()

template<typename Container >
fcppt::container::detail::output< Container> fcppt::container::output ( Container const &  _container)
inlinenoexcept

Creates a class that has an output operator to print a container.

Template Parameters
ContainerMust be a container that has at least a forward iterator.

◆ pop_back()

template<typename Container >
fcppt::optional::object< fcppt::container::to_value_type< Container >> fcppt::container::pop_back ( Container &  _container)

Pops the back of a container as an optional.