2.10.0
Freundlich's C++ toolkit
Classes | Typedefs | Enumerations | Functions
fcppt::algorithm Namespace Reference

General-purpose algorithms. More...

Classes

struct  loop_break_impl
 Customization point for ranges. More...
 
struct  map_impl
 
struct  value >>
 
struct  value >>
 
struct  value >>
 

Typedefs

template<typename Range >
using range_element_type = decltype(*std::declval< Range >().begin())
 The type of a range element. More...
 

Enumerations

enum  update_action { update_action::keep, update_action::remove }
 Update action for container iteration. More...
 

Functions

template<typename Range , typename Pred >
bool all_of (Range const &_range, Pred const &_pred)
 Checks if a given predicate is true for all elements of a range. More...
 
template<typename Range , typename T >
fcppt::optional::object< fcppt::container::to_iterator_type< std::remove_reference_t< Range > >> binary_search (Range &&_range, T const &_value)
 Finds an element by binary search. More...
 
template<typename Range , typename T >
bool contains (Range const &_range, T const &_value)
 Checks if a given value is inside a range. More...
 
template<typename Range , typename Pred >
bool contains_if (Range const &_range, Pred const &_pred)
 Checks if a given value is inside a range, using a predicate. More...
 
template<typename Range1 , typename Range2 >
bool equal (Range1 const &_range1, Range2 const &_range2)
 Compares two ranges for equality. More...
 
template<typename Range , typename T >
fcppt::iterator::range< fcppt::container::to_iterator_type< std::remove_reference_t< Range > >> equal_range (Range &&_range, T const &_value)
 Returns the equal range of a given range and a value. More...
 
template<typename Range , typename Function >
auto find_by_opt (Range &&_range, Function const &_function) -> decltype(_function(*_range.begin()))
 Optionally finds an element and transforms it. More...
 
template<typename Range , typename Comp >
fcppt::optional::object< fcppt::container::to_iterator_type< std::remove_reference_t< Range > >> find_if_opt (Range &&_range, Comp const &_comp)
 Like std::find_if but returns an empty optional on failure. More...
 
template<typename Range , typename T >
fcppt::optional::object< fcppt::container::to_iterator_type< std::remove_reference_t< Range > >> find_opt (Range &&_range, T const &_value)
 Like std::find but returns an empty optional on failure. More...
 
template<typename Range , typename State , typename Function >
State fold (Range &&_range, State _state, Function _function)
 Folds a range into a value. More...
 
template<typename Range , typename State , typename Function >
State fold_break (Range &&_range, State _state, Function _function)
 Folds a range into a value, can break out early. More...
 
template<typename TargetContainer , typename Function >
TargetContainer generate_n (std::size_t const _count, Function const &_function)
 Generates a container by calling a function a number of times. More...
 
template<typename Range , typename T >
fcppt::optional::object< typename Range::size_type > index_of (Range const &_range, T const &_value)
 Returns the index of the first element found in a sequence. More...
 
template<typename Range >
fcppt::type_traits::value_type< Range > join_strings (Range const &_range, fcppt::type_traits::value_type< Range > const &_delim)
 Joins a range of strings, using a delimiter. More...
 
template<typename Range , typename Body >
void loop (Range &&_range, Body const &_body)
 Iterates through a range. More...
 
template<typename Range , typename Body >
void loop_break (Range &&_range, Body const &_body)
 Iterates through a range with the ability to break out of the loop. More...
 
template<typename TargetContainer , typename SourceRange , typename Function >
TargetContainer map (SourceRange &&_source, Function const &_function)
 Transforms a range to another container by applying a function to every element. More...
 
template<typename TargetContainer , typename Range , typename Function >
TargetContainer map_concat (Range &&_range, Function const &_function)
 Maps a range to other sequences and joins them. More...
 
template<typename Map , typename UpdateAction >
void map_iteration (Map &_map, UpdateAction const &_update_action)
 Iterates over a map with the possibility of erasing elements. More...
 
template<typename Map , typename UpdateAction >
void map_iteration_second (Map &_map, UpdateAction const &_update_action)
 Iterates over a map with the possibility of erasing elements, passing second. More...
 
template<typename TargetContainer , typename Source , typename Function >
TargetContainer map_optional (Source &&_source, Function const &_function)
 Transforms a range to another container by applying a function to every element, only inserting the results that are not empty optionals. More...
 
template<typename Container >
bool remove (Container &_container, typename Container::const_reference _element)
 Removes all occurrences of a value from a container. More...
 
template<typename Container , typename Predicate >
bool remove_if (Container &_container, Predicate const &_predicate)
 Removes all elements from a container matching a predicate. More...
 
template<typename Count , typename Function >
void repeat (Count const _count, Function const &_function)
 Calls a function a number of times. More...
 
template<typename Container >
std::remove_reference_t< Container > reverse (Container &&_container)
 Reverses a container. More...
 
template<typename Sequence , typename UpdateAction >
void sequence_iteration (Sequence &_sequence, UpdateAction const &_update_action)
 Iterates over a sequence with the possibility of erasing elements. More...
 
template<typename String >
std::vector< String > split_string (String const &_string, fcppt::type_traits::value_type< String > const _delim)
 Splits a string, using a delimiter. More...
 
template<typename Container >
void unique (Container &_container)
 Removes duplicate elements from a container. More...
 
template<typename Container , typename BinaryPredicate >
void unique_if (Container &_container, BinaryPredicate const &_predicate)
 Removes duplicate elements from a container. Compares using a predicate. More...
 

Detailed Description

General-purpose algorithms.