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

A convenience for use with range-for. More...

#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 >

A convenience for use with range-for.

Definition at line 437 of file MemoryX.h.

Member Typedef Documentation

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

Definition at line 438 of file MemoryX.h.

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

Definition at line 439 of file MemoryX.h.

Constructor & Destructor Documentation

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

Definition at line 441 of file MemoryX.h.

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

Definition at line 444 of file MemoryX.h.

445  : 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 510 of file MemoryX.h.

Referenced by IteratorRange< TrackIter< TrackType > >::accumulate().

512  {},
513  Unary unary_op = {}
514  ) const
515  {
516  R result = init;
517  for (auto&& v : *this)
518  result = binary_op(result, unary_op(v));
519  return result;
520  }
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 529 of file MemoryX.h.

534  {
535  return this->accumulate( init, binary_op, std::mem_fn( pmf ) );
536  }
R accumulate(R init, Binary binary_op={}, Unary unary_op={}) const
Definition: MemoryX.h:510
template<typename Iterator>
template<typename F >
bool IteratorRange< Iterator >::all_of ( const F &  f) const
inline

Definition at line 486 of file MemoryX.h.

487  {
488  auto notF =
489  [&](typename std::iterator_traits<Iterator>::reference v)
490  { return !f(v); };
491  return !this->any_of( notF );
492  }
bool any_of(const F &f) const
Definition: MemoryX.h:494
template<typename Iterator>
template<typename F >
bool IteratorRange< Iterator >::any_of ( const F &  f) const
inline

Definition at line 494 of file MemoryX.h.

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

495  { return this->end() != this->find_if(f); }
iterator find_if(const F &f) const
Definition: MemoryX.h:474
Iterator end() const
Definition: MemoryX.h:451
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 471 of file MemoryX.h.

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

Definition at line 456 of file MemoryX.h.

Referenced by IteratorRange< TrackIter< TrackType > >::operator bool().

456 { return this->begin() == this->end(); }
Iterator begin() const
Definition: MemoryX.h:450
Iterator end() const
Definition: MemoryX.h:451
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 460 of file MemoryX.h.

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

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

Definition at line 474 of file MemoryX.h.

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

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

Definition at line 463 of file MemoryX.h.

464  {
465  auto iter = this->find(t);
466  if (iter == this->end())
467  return -1;
468  return std::distance(this->begin(), iter);
469  }
iterator find(const T &t) const
Definition: MemoryX.h:460
Iterator begin() const
Definition: MemoryX.h:450
Iterator end() const
Definition: MemoryX.h:451
template<typename Iterator>
template<typename F >
long IteratorRange< Iterator >::index_if ( const F &  f) const
inline

Definition at line 477 of file MemoryX.h.

478  {
479  auto iter = this->find_if(f);
480  if (iter == this->end())
481  return -1;
482  return std::distance(this->begin(), iter);
483  }
iterator find_if(const F &f) const
Definition: MemoryX.h:474
Iterator begin() const
Definition: MemoryX.h:450
Iterator end() const
Definition: MemoryX.h:451
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 565 of file MemoryX.h.

Referenced by IteratorRange< TrackIter< TrackType > >::max().

565  {} ) const
566  {
567  return this->accumulate(
568  std::numeric_limits< R >::lowest(),
569  (const R&(*)(const R&, const R&)) std::max,
570  unary_op
571  );
572  }
R accumulate(R init, Binary binary_op={}, Unary unary_op={}) const
Definition: MemoryX.h:510
template<typename Iterator>
template<typename R2 , typename C , typename R = R2>
R IteratorRange< Iterator >::max ( R2(C::*)() const  pmf) const
inline

Definition at line 578 of file MemoryX.h.

579  {
580  return this->max( std::mem_fn( pmf ) );
581  }
R max(Unary unary_op={}) const
Definition: MemoryX.h:565
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 543 of file MemoryX.h.

Referenced by IteratorRange< TrackIter< TrackType > >::min().

543  {} ) const
544  {
545  return this->accumulate(
546  std::numeric_limits< R >::max(),
547  (const R&(*)(const R&, const R&)) std::min,
548  unary_op
549  );
550  }
R accumulate(R init, Binary binary_op={}, Unary unary_op={}) const
Definition: MemoryX.h:510
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 556 of file MemoryX.h.

557  {
558  return this->min( std::mem_fn( pmf ) );
559  }
R min(Unary unary_op={}) const
Definition: MemoryX.h:543
template<typename Iterator>
template<typename F >
bool IteratorRange< Iterator >::none_of ( const F &  f) const
inline

Definition at line 497 of file MemoryX.h.

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

Definition at line 457 of file MemoryX.h.

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

Definition at line 453 of file MemoryX.h.

Referenced by IteratorRange< TrackIter< TrackType > >::reversal().

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

Definition at line 454 of file MemoryX.h.

Referenced by IteratorRange< TrackIter< TrackType > >::reversal().

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

Definition at line 447 of file MemoryX.h.

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

Definition at line 458 of file MemoryX.h.

458 { return std::distance(this->begin(), this->end()); }
Iterator begin() const
Definition: MemoryX.h:450
Iterator end() const
Definition: MemoryX.h:451
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 587 of file MemoryX.h.

Referenced by IteratorRange< TrackIter< TrackType > >::sum().

587  {} ) const
588  {
589  return this->accumulate(
590  R{ 0 },
591  std::plus< R >{},
592  unary_op
593  );
594  }
R accumulate(R init, Binary binary_op={}, Unary unary_op={}) const
Definition: MemoryX.h:510
template<typename Iterator>
template<typename R2 , typename C , typename R = R2>
R IteratorRange< Iterator >::sum ( R2(C::*)() const  pmf) const
inline

Definition at line 600 of file MemoryX.h.

601  {
602  return this->sum( std::mem_fn( pmf ) );
603  }
R sum(Unary unary_op={}) const
Definition: MemoryX.h:587

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