Aleph-w 3.0
A C++ Library for Data Structures and Algorithms
Loading...
Searching...
No Matches
ah-dry.H File Reference

Container traversal and functional operation mixins. More...

#include "ahFunctional.H"
#include <utility>
#include <vector>
#include <ah-errors.H>
Include dependency graph for ah-dry.H:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  GenericTraverse< Container >
 Generic traversal of the container through its iterator. More...
 
class  LocateFunctions< Container, Type >
 Common sequential searching methods on containers. More...
 
struct  SpecialCtors< Container, T >
 Special constructors common to Aleph-w ( \(\aleph_\omega\)) containers. More...
 
class  FunctionalMethods< Container, T >
 Common methods to the Aleph-w ( \(\aleph_\omega\)) containers. More...
 
struct  GenericItems< Container, T >
 Generic list of items stored in a container. More...
 
class  EqualSequenceMethod< Container >
 Mixin providing equality comparison for sequence containers. More...
 
class  EqualToMethod< Container >
 Equality test for containers. More...
 
class  MapSequencesMethods< Container, Key, Data >
 Common methods to mapping containers. More...
 

Namespaces

namespace  Aleph
 Main namespace for Aleph-w library functions.
 

Typedefs

template<class Container , typename T >
using GenericKeys = GenericItems< Container, T >
 Alias to GenricItems functor.
 

Functions

template<class Container , class Operation >
bool traverse (const Container &c, Operation &op) noexcept(noexcept(c.traverse(op)))
 Invoke c.traverse(op) as a free function (lvalue operation).
 
template<class Container , class Operation >
bool traverse (const Container &c, Operation &&op) noexcept(noexcept(c.traverse(op)))
 Invoke c.traverse(op) as a free function (rvalue overload).
 

Detailed Description

Container traversal and functional operation mixins.

This file provides generic traversal classes and mixins that implement functional operations (for_each, exists, all, filter, map, etc.) for containers through their iterators. These follow the DRY principle.

Author
Leandro Rabindranath León

Definition in file ah-dry.H.

Typedef Documentation

◆ GenericKeys

template<class Container , typename T >
using GenericKeys = GenericItems<Container, T>

Alias to GenricItems functor.

Definition at line 1738 of file ah-dry.H.

Function Documentation

◆ traverse() [1/2]

template<class Container , class Operation >
bool traverse ( const Container c,
Operation &&  op 
)
noexcept

Invoke c.traverse(op) as a free function (rvalue overload).

Overload for temporary / rvalue callables such as lambda expressions. The operation op is passed (invoked) as a named lvalue to the member overload rather than being perfectly forwarded.

Template Parameters
ContainerAny type that provides a traverse(Operation&) member.
OperationCallable with signature bool(Item_Type &).
Parameters
[in]cContainer to traverse.
[in]opOperation passed (invoked) as a named lvalue to the member overload rather than being perfectly forwarded.
Returns
true if all elements were visited, false if traversal was stopped.
Exceptions
anythingthat op throws.

Definition at line 166 of file ah-dry.H.

◆ traverse() [2/2]

template<class Container , class Operation >
bool traverse ( const Container c,
Operation &  op 
)
noexcept

Invoke c.traverse(op) as a free function (lvalue operation).

Convenience wrapper so that traverse(container, op) can be used in generic code without depending on the container type.

Template Parameters
ContainerAny type that provides a traverse(Operation&) member.
OperationCallable with signature bool(Item_Type &).
Parameters
[in]cContainer to traverse.
[in]opOperation to apply to each element; return false to stop.
Returns
true if all elements were visited, false if traversal was stopped.
Exceptions
anythingthat op throws.

Definition at line 145 of file ah-dry.H.

Referenced by FunctionalMethods< Container, T >::exists().