4.6.0
Freundlich's C++ toolkit
|
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< Range > |
A range that moves its elements. More... | |
Topics | |
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 Range > | |
using | fcppt::container::size_result_type |
The size type of a range. | |
template<typename Container > | |
using | fcppt::container::to_iterator_type |
Gets the iterator type of a container. | |
template<typename Container > | |
using | fcppt::container::to_mapped_type |
Gets the mapped type of an associative container. | |
template<typename Container > | |
using | fcppt::container::to_pointer_type |
Gets the pointer type of a container. | |
template<typename Container > | |
using | fcppt::container::to_reference_type |
Gets the reference type of a container. | |
template<typename Container > | |
using | fcppt::container::to_value_type |
The value type of a container depending on its constness. | |
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. | |
template<typename Container > | |
fcppt::container::to_pointer_type< Container > | fcppt::container::data (Container &_container) |
Returns a pointer to the beginning of a random access container. | |
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> | |
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. | |
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. | |
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. | |
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. | |
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. | |
template<typename Container , typename Value > | |
bool | fcppt::container::insert (Container &_container, Value &&_value) |
Inserts into an associative container. | |
template<typename Container , typename... Args> | |
std::remove_cvref_t< Container > | fcppt::container::join (Container &&_first, Args &&..._args) |
Joins two containers. | |
template<typename Set , typename Map > | |
Set | fcppt::container::key_set (Map const &_map) |
Creates a set of keys from a map. | |
template<typename Container , typename... Args> | |
Container | fcppt::container::make (Args &&..._args) |
Creates a container from variadic arguments by moving. | |
template<typename Container > | |
fcppt::container::move_range< std::remove_reference_t< Container > > | fcppt::container::make_move_range (Container &&_container) |
Creates a move range from a container. | |
template<typename Result , typename Map > | |
Result | fcppt::container::map_values_copy (Map const &_map) |
Copies the mapped values of an associative container into a container. | |
template<typename Result , typename Map > | |
Result | fcppt::container::map_values_ref (Map &_map) |
Maps the mapped values of an associative container to a container of references. | |
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. | |
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. | |
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. | |
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. | |
template<typename Container > | |
fcppt::optional::object< fcppt::container::to_value_type< Container > > | fcppt::container::pop_front (Container &_container) |
Pops the front of a container as an optional. | |
template<typename Set > | |
Set | fcppt::container::set_difference (Set const &_a, Set const &_b) |
Returns the difference of two sets. | |
template<typename Set > | |
Set | fcppt::container::set_intersection (Set const &_a, Set const &_b) |
Returns the intersection of two sets. | |
template<typename Set > | |
Set | fcppt::container::set_union (Set const &_a, Set const &_b) |
Returns the union of two sets. | |
template<typename Range > | |
fcppt::container::size_result_type< Range > | fcppt::container::size (Range const &_range) |
The size of a range. | |
template<typename Container > | |
fcppt::container::uncons_result< Container > | fcppt::container::uncons (Container &_container) |
Splits a container into its head and tail. | |
using fcppt::container::size_result_type |
The size type of a range.
This type is always unsigned.
using fcppt::container::to_iterator_type |
Gets the iterator type of a container.
If Container is const
, the result is Container::const_iterator
. Otherwise, it is Container::iterator
.
Container | A range type. |
using fcppt::container::to_mapped_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
.
Container | An associative container. |
using fcppt::container::to_pointer_type |
Gets the pointer type of a container.
If Container is const
, the result is Container::const_pointer
. Otherwise, it is Container::pointer
.
Container | A range type. |
using fcppt::container::to_reference_type |
Gets the reference type of a container.
If Container is const
, the result is Container::const_reference
. Otherwise, it is Container::reference
.
Container | A range type. |
using fcppt::container::to_value_type |
The value type of a container depending on its constness.
If Container is const
, the result is Container::value_type const
. Otherwise, it is Container::value_type
.
Container | A range type. |
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.
Container | Must be a random-access container. |
fcppt::container::to_pointer_type< Container > fcppt::container::data | ( | Container & | _container | ) |
Returns a pointer to the beginning of a random access container.
Returns a pointer to the beginning of _container, or the null pointer if _container is empty.
Container | Must be a random-access 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.
Container | Must be a random-access container. |
|
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.
Container | Must be an associative container. |
Key | Must be a key that can be searched for. |
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.
Container | Must be an associative container. |
Key | Must be a key that can be searched for. |
|
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.
Container | Must be an associative container. |
Key | Must be a key that can be searched for. |
|
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.
Container | An associative container. |
Create | A function of type Container::mapped_type (Container::key_type) . |
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.
Container | An associative container> |
Create | A function of type Container::mapped_type (Container::key_type) . |
|
nodiscard |
Inserts into an associative container.
Container | An associative container. |
Value | The container's value_type. |
|
inline |
Joins two containers.
Joins containers _first and all containers from _args, by inserting the containers from _args into _first.
_first | The left container. |
_args | The other containers, which will be inserted into the left container. |
Container | A container class that supports insert of iterator ranges. |
|
inline |
Creates a set of keys from a map.
Inserts every key from _map into the resulting set.
Map | A map-like container. |
Set | A set-like container. |
|
inline |
Creates a container from variadic arguments by moving.
|
inline |
Creates a move range from a container.
_container | Must be an rvalue reference to a container. |
Container | A container type. |
Result fcppt::container::map_values_copy | ( | Map const & | _map | ) |
Copies the mapped values of an associative container into a container.
Result | A sequence container of Map::mapped_type . |
Map | An associative container. |
Result fcppt::container::map_values_ref | ( | Map & | _map | ) |
Maps the mapped values of an associative container to a container of references.
Result | A sequence container of fcppt::reference<Map::mapped_type> or fcppt::reference<Map::mapped_type const> . |
Map | An associative 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.
fcppt::optional::reference< fcppt::container::to_value_type< Container > > fcppt::container::maybe_front | ( | Container & | _container | ) |
Returns the front of a container as an optional.
|
inlinenoexcept |
Creates a class that has an output operator to print a container.
Container | Must be a container that has at least a forward iterator. |
fcppt::optional::object< fcppt::container::to_value_type< Container > > fcppt::container::pop_back | ( | Container & | _container | ) |
Pops the back of a container as an optional.
fcppt::optional::object< fcppt::container::to_value_type< Container > > fcppt::container::pop_front | ( | Container & | _container | ) |
Pops the front of a container as an optional.
Set fcppt::container::set_difference | ( | Set const & | _a, |
Set const & | _b ) |
Returns the difference of two sets.
Set | Must be an associative container |
Set fcppt::container::set_intersection | ( | Set const & | _a, |
Set const & | _b ) |
Returns the intersection of two sets.
Set | Must be an associative container |
Set fcppt::container::set_union | ( | Set const & | _a, |
Set const & | _b ) |
Returns the union of two sets.
Set | Must be an associative container |
|
inline |
The size of a range.
Uses size()
if possible, otherwise calculates the distance from begin to end.
Range | Must be a range that either has begin/end or size and size_type. |
|
nodiscard |
Splits a container into its head and tail.