Audacity  2.2.2
Classes | Public Types | Public Member Functions | List of all members
IteratorRange< Iterator > Struct Template Reference

#include <MemoryX.h>

Inheritance diagram for IteratorRange< Iterator >:

Classes

struct  identity
 

Public Types

using iterator = Iterator
 
using reverse_iterator = std::reverse_iterator< Iterator >
 

Public Member Functions

 IteratorRange (const Iterator &a, const Iterator &b)
 
 IteratorRange (Iterator &&a, Iterator &&b)
 
IteratorRange< reverse_iteratorreversal () const
 
Iterator begin () const
 
Iterator end () const
 
reverse_iterator rbegin () const
 
reverse_iterator rend () const
 
bool empty () const
 
 operator bool () const
 
size_t size () const
 
template<typename T >
iterator find (const T &t) const
 
template<typename T >
long index (const T &t) const
 
template<typename T >
bool contains (const T &t) const
 
template<typename F >
iterator find_if (const F &f) const
 
template<typename F >
long index_if (const F &f) const
 
template<typename F >
bool all_of (const F &f) const
 
template<typename F >
bool any_of (const F &f) const
 
template<typename F >
bool none_of (const F &f) const
 
template<typename R , typename Binary = std::plus< R >, typename Unary = identity< decltype( *std::declval<Iterator>() ) >>
accumulate (R init, Binary binary_op={}, Unary unary_op={}) const
 
template<typename R , typename Binary = std::plus< R >, typename R2 , typename C >
accumulate (R init, Binary binary_op, R2(C::*pmf)() const ) const
 
template<typename Unary = identity< decltype( *std::declval<Iterator>() ) >, typename R = decltype( std::declval<Unary>()( *std::declval<Iterator>() ) )>
min (Unary unary_op={}) const
 
template<typename R2 , typename C , typename R = R2>
min (R2(C::*pmf)() const ) const
 
template<typename Unary = identity< decltype( *std::declval<Iterator>() ) >, typename R = decltype( std::declval<Unary>()( *std::declval<Iterator>() ) )>
max (Unary unary_op={}) const
 
template<typename R2 , typename C , typename R = R2>
max (R2(C::*pmf)() const ) const
 
template<typename Unary = identity< decltype( *std::declval<Iterator>() ) >, typename R = decltype( std::declval<Unary>()( *std::declval<Iterator>() ) )>
sum (Unary unary_op={}) const
 
template<typename R2 , typename C , typename R = R2>
sum (R2(C::*pmf)() const ) const
 

Detailed Description

template<typename Iterator>
struct IteratorRange< Iterator >

Definition at line 505 of file MemoryX.h.

Member Typedef Documentation

template<typename Iterator>
using IteratorRange< Iterator >::iterator = Iterator

Definition at line 506 of file MemoryX.h.

template<typename Iterator>
using IteratorRange< Iterator >::reverse_iterator = std::reverse_iterator<Iterator>

Definition at line 507 of file MemoryX.h.

Constructor & Destructor Documentation

template<typename Iterator>
IteratorRange< Iterator >::IteratorRange ( const Iterator &  a,
const Iterator &  b 
)
inline

Definition at line 509 of file MemoryX.h.

510  : std::pair<Iterator, Iterator> ( a, b ) {}
template<typename Iterator>
IteratorRange< Iterator >::IteratorRange ( Iterator &&  a,
Iterator &&  b 
)
inline

Definition at line 512 of file MemoryX.h.

513  : std::pair<Iterator, Iterator> ( std::move(a), std::move(b) ) {}

Member Function Documentation

template<typename Iterator>
template<typename R , typename Binary = std::plus< R >, typename Unary = identity< decltype( *std::declval<Iterator>() ) >>
R IteratorRange< Iterator >::accumulate ( init,
Binary  binary_op = {},
Unary  unary_op = {} 
) const
inline

Definition at line 578 of file MemoryX.h.

Referenced by IteratorRange< Iterator >::accumulate().

580  {},
581  Unary unary_op = {}
582  ) const
583  {
584  R result = init;
585  for (auto&& v : *this)
586  result = binary_op(result, unary_op(v));
587  return result;
588  }
template<typename Iterator>
template<typename R , typename Binary = std::plus< R >, typename R2 , typename C >
R IteratorRange< Iterator >::accumulate ( init,
Binary  binary_op,
R2(C::*)() const  pmf 
) const
inline

Definition at line 597 of file MemoryX.h.

References IteratorRange< Iterator >::accumulate().

602  {
603  return this->accumulate( init, binary_op, std::mem_fun( pmf ) );
604  }
R accumulate(R init, Binary binary_op={}, Unary unary_op={}) const
Definition: MemoryX.h:578
template<typename Iterator>
template<typename F >
bool IteratorRange< Iterator >::all_of ( const F &  f) const
inline

Definition at line 554 of file MemoryX.h.

References IteratorRange< Iterator >::any_of().

555  {
556  auto notF =
557  [&](typename std::iterator_traits<Iterator>::reference v)
558  { return !f(v); };
559  return !this->any_of( notF );
560  }
bool any_of(const F &f) const
Definition: MemoryX.h:562
template<typename Iterator>
template<typename F >
bool IteratorRange< Iterator >::any_of ( const F &  f) const
inline

Definition at line 562 of file MemoryX.h.

References IteratorRange< Iterator >::end(), and IteratorRange< Iterator >::find_if().

Referenced by IteratorRange< Iterator >::all_of(), and IteratorRange< Iterator >::none_of().

563  { return this->end() != this->find_if(f); }
iterator find_if(const F &f) const
Definition: MemoryX.h:542
Iterator end() const
Definition: MemoryX.h:519
template<typename Iterator>
Iterator IteratorRange< Iterator >::begin ( ) const
inline
template<typename Iterator>
template<typename T >
bool IteratorRange< Iterator >::contains ( const T &  t) const
inline

Definition at line 539 of file MemoryX.h.

References IteratorRange< Iterator >::end(), and IteratorRange< Iterator >::find().

540  { return this->end() != this->find(t); }
iterator find(const T &t) const
Definition: MemoryX.h:528
Iterator end() const
Definition: MemoryX.h:519
template<typename Iterator>
bool IteratorRange< Iterator >::empty ( ) const
inline

Definition at line 524 of file MemoryX.h.

References IteratorRange< Iterator >::begin(), and IteratorRange< Iterator >::end().

Referenced by IteratorRange< Iterator >::operator bool().

524 { return this->begin() == this->end(); }
Iterator begin() const
Definition: MemoryX.h:518
Iterator end() const
Definition: MemoryX.h:519
template<typename Iterator>
Iterator IteratorRange< Iterator >::end ( ) const
inline
template<typename Iterator>
template<typename T >
iterator IteratorRange< Iterator >::find ( const T &  t) const
inline

Definition at line 528 of file MemoryX.h.

References IteratorRange< Iterator >::begin(), and IteratorRange< Iterator >::end().

Referenced by IteratorRange< Iterator >::contains(), and IteratorRange< Iterator >::index().

529  { return std::find(this->begin(), this->end(), t); }
Iterator begin() const
Definition: MemoryX.h:518
Iterator end() const
Definition: MemoryX.h:519
template<typename Iterator>
template<typename F >
iterator IteratorRange< Iterator >::find_if ( const F &  f) const
inline

Definition at line 542 of file MemoryX.h.

References IteratorRange< Iterator >::begin(), and IteratorRange< Iterator >::end().

Referenced by IteratorRange< Iterator >::any_of(), and IteratorRange< Iterator >::index_if().

543  { return std::find_if(this->begin(), this->end(), f); }
Iterator begin() const
Definition: MemoryX.h:518
Iterator end() const
Definition: MemoryX.h:519
template<typename Iterator>
template<typename T >
long IteratorRange< Iterator >::index ( const T &  t) const
inline

Definition at line 531 of file MemoryX.h.

References IteratorRange< Iterator >::begin(), IteratorRange< Iterator >::end(), and IteratorRange< Iterator >::find().

532  {
533  auto iter = this->find(t);
534  if (iter == this->end())
535  return -1;
536  return std::distance(this->begin(), iter);
537  }
iterator find(const T &t) const
Definition: MemoryX.h:528
Iterator begin() const
Definition: MemoryX.h:518
Iterator end() const
Definition: MemoryX.h:519
template<typename Iterator>
template<typename F >
long IteratorRange< Iterator >::index_if ( const F &  f) const
inline

Definition at line 545 of file MemoryX.h.

References IteratorRange< Iterator >::begin(), IteratorRange< Iterator >::end(), and IteratorRange< Iterator >::find_if().

546  {
547  auto iter = this->find_if(f);
548  if (iter == this->end())
549  return -1;
550  return std::distance(this->begin(), iter);
551  }
iterator find_if(const F &f) const
Definition: MemoryX.h:542
Iterator begin() const
Definition: MemoryX.h:518
Iterator end() const
Definition: MemoryX.h:519
template<typename Iterator>
template<typename Unary = identity< decltype( *std::declval<Iterator>() ) >, typename R = decltype( std::declval<Unary>()( *std::declval<Iterator>() ) )>
R IteratorRange< Iterator >::max ( Unary  unary_op = {}) const
inline

Definition at line 633 of file MemoryX.h.

Referenced by IteratorRange< Iterator >::max().

633  {} ) const
634  {
635  return this->accumulate(
636  -std::numeric_limits< R >::max(),
637  // std::numeric_limits< R >::lowest(), // TODO C++11
638  (const R&(*)(const R&, const R&)) std::max,
639  unary_op
640  );
641  }
R accumulate(R init, Binary binary_op={}, Unary unary_op={}) const
Definition: MemoryX.h:578
template<typename Iterator>
template<typename R2 , typename C , typename R = R2>
R IteratorRange< Iterator >::max ( R2(C::*)() const  pmf) const
inline

Definition at line 647 of file MemoryX.h.

References IteratorRange< Iterator >::max().

648  {
649  return this->max( std::mem_fun( pmf ) );
650  }
R max(Unary unary_op={}) const
Definition: MemoryX.h:633
template<typename Iterator>
template<typename Unary = identity< decltype( *std::declval<Iterator>() ) >, typename R = decltype( std::declval<Unary>()( *std::declval<Iterator>() ) )>
R IteratorRange< Iterator >::min ( Unary  unary_op = {}) const
inline

Definition at line 611 of file MemoryX.h.

Referenced by IteratorRange< Iterator >::min().

611  {} ) const
612  {
613  return this->accumulate(
614  std::numeric_limits< R >::max(),
615  (const R&(*)(const R&, const R&)) std::min,
616  unary_op
617  );
618  }
R accumulate(R init, Binary binary_op={}, Unary unary_op={}) const
Definition: MemoryX.h:578
int min(int a, int b)
template<typename Iterator>
template<typename R2 , typename C , typename R = R2>
R IteratorRange< Iterator >::min ( R2(C::*)() const  pmf) const
inline

Definition at line 624 of file MemoryX.h.

References IteratorRange< Iterator >::min().

625  {
626  return this->min( std::mem_fun( pmf ) );
627  }
R min(Unary unary_op={}) const
Definition: MemoryX.h:611
template<typename Iterator>
template<typename F >
bool IteratorRange< Iterator >::none_of ( const F &  f) const
inline

Definition at line 565 of file MemoryX.h.

References IteratorRange< Iterator >::any_of().

566  { return !this->any_of(f); }
bool any_of(const F &f) const
Definition: MemoryX.h:562
template<typename Iterator>
IteratorRange< Iterator >::operator bool ( ) const
inlineexplicit

Definition at line 525 of file MemoryX.h.

References IteratorRange< Iterator >::empty().

525 { return !this->empty(); }
bool empty() const
Definition: MemoryX.h:524
template<typename Iterator>
reverse_iterator IteratorRange< Iterator >::rbegin ( ) const
inline

Definition at line 521 of file MemoryX.h.

Referenced by IteratorRange< Iterator >::reversal().

521 { return reverse_iterator{ this->second }; }
std::reverse_iterator< Iterator > reverse_iterator
Definition: MemoryX.h:507
template<typename Iterator>
reverse_iterator IteratorRange< Iterator >::rend ( ) const
inline

Definition at line 522 of file MemoryX.h.

Referenced by IteratorRange< Iterator >::reversal().

522 { return reverse_iterator{ this->first }; }
std::reverse_iterator< Iterator > reverse_iterator
Definition: MemoryX.h:507
template<typename Iterator>
IteratorRange< reverse_iterator > IteratorRange< Iterator >::reversal ( ) const
inline

Definition at line 515 of file MemoryX.h.

References IteratorRange< Iterator >::rbegin(), and IteratorRange< Iterator >::rend().

516  { return { this->rbegin(), this->rend() }; }
reverse_iterator rend() const
Definition: MemoryX.h:522
reverse_iterator rbegin() const
Definition: MemoryX.h:521
template<typename Iterator>
size_t IteratorRange< Iterator >::size ( ) const
inline

Definition at line 526 of file MemoryX.h.

References IteratorRange< Iterator >::begin(), and IteratorRange< Iterator >::end().

526 { return std::distance(this->begin(), this->end()); }
Iterator begin() const
Definition: MemoryX.h:518
Iterator end() const
Definition: MemoryX.h:519
template<typename Iterator>
template<typename Unary = identity< decltype( *std::declval<Iterator>() ) >, typename R = decltype( std::declval<Unary>()( *std::declval<Iterator>() ) )>
R IteratorRange< Iterator >::sum ( Unary  unary_op = {}) const
inline

Definition at line 656 of file MemoryX.h.

Referenced by IteratorRange< Iterator >::sum().

656  {} ) const
657  {
658  return this->accumulate(
659  R{ 0 },
660  std::plus< R >{},
661  unary_op
662  );
663  }
R accumulate(R init, Binary binary_op={}, Unary unary_op={}) const
Definition: MemoryX.h:578
template<typename Iterator>
template<typename R2 , typename C , typename R = R2>
R IteratorRange< Iterator >::sum ( R2(C::*)() const  pmf) const
inline

Definition at line 669 of file MemoryX.h.

References IteratorRange< Iterator >::sum().

670  {
671  return this->sum( std::mem_fun( pmf ) );
672  }
R sum(Unary unary_op={}) const
Definition: MemoryX.h:656

The documentation for this struct was generated from the following file: