22 template<
typename Container,
typename Value>
void erase(Container& container,
const Value& value) {
23 container.erase(std::remove(container.begin(), container.end(), value), container.end());
33 container.erase(std::remove_if(container.begin(), container.end(),
predicate), container.end());
40 container.erase(std::unique(container.begin(), container.end()), container.end());
51 template<
typename Container,
typename Value>
decltype(std::declval<Container>().begin())
findContainer(Container& container,
const Value& value) {
52 return std::find(container.begin(), container.end(), value);
61 template<
typename Container,
typename Predicate>
decltype(std::declval<Container>().begin())
findIf(Container& container,
Predicate&&
predicate) {
62 return std::find_if(container.begin(), container.end(),
predicate);
71 template<
typename Container,
typename Predicate>
decltype(std::declval<Container>().begin())
findIfNot(Container& container,
Predicate&&
predicate) {
72 return std::find_if_not(container.begin(), container.end(),
predicate);
80 template<
typename Container>
void sort(Container& container) { std::sort(container.begin(), container.end()); }
87 template<
typename Container,
typename Compare>
void sort(Container& container,
Compare&& compare) {
88 std::sort(container.begin(), container.end(), compare);
95 std::transform(container.begin(), container.end(), container.begin(),
transformation);
98 template<
typename InContainer,
typename OutContainer,
typename Transformation>
103 template<
typename Container,
typename Transformation>
106 std::transform(container.begin(), container.end(), std::back_inserter(output),
transformation);
Definition Application.hpp:19
decltype(std::declval< Container >().begin()) findContainer(Container &container, const Value &value)
Finds the first item that is equal to value.
Definition Algorithm.hpp:51
auto range()
Returns an iterator that increases it's value from 0 to end by 1 for each step.
Definition Iterator.hpp:350
void transformInPlace(Container &container, Transformation &&transformation)
Definition Algorithm.hpp:94
decltype(std::declval< Container >().begin()) findIf(Container &container, Predicate &&predicate)
Finds the first item that the given predicate returns true.
Definition Algorithm.hpp:61
decltype(std::declval< Container >().begin()) findIfNot(Container &container, Predicate &&predicate)
Finds the first item that the given predicate returns false.
Definition Algorithm.hpp:71
std::vector< T, ScopedAllocatorAdaptor< StdAllocator< T, RawAllocator > > > Vector
Vector is a sequence container that encapsulates dynamic size arrays.
Definition Vector.hpp:17
void eraseIf(Container &container, Predicate &&predicate)
Removes all items that match the given predicate from the given container.
Definition Algorithm.hpp:32
void transformTo(const InContainer &inContainer, OutContainer &outContainer, Transformation &&transformation)
Definition Algorithm.hpp:99
void erase(Container &container, const Value &value)
Erases all items value from the given container.
Definition Algorithm.hpp:22
void eraseDuplicates(Container &container)
Removes all duplicates items from the given container.
Definition Algorithm.hpp:39
void sort(Container &container)
Sorts all items in the container.
Definition Algorithm.hpp:80
constexpr auto predicate(Callable &&callable) noexcept
Helper function to create a new predicate from a lambda.
Definition Predicate.hpp:390
Container toContainer(Range &range)
Definition Algorithm.hpp:112
constexpr size_t hash(const T &v)
Generates a hash for the provided type.
Definition Hash.hpp:25
A type that predicate types must extend to allow automatic operator overloading.
Definition Predicate.hpp:19