Audacity  3.0.3
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 >:
[legend]
Collaboration diagram for IteratorRange< Iterator >:
[legend]

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 378 of file MemoryX.h.

Member Typedef Documentation

◆ iterator

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

Definition at line 379 of file MemoryX.h.

◆ reverse_iterator

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

Definition at line 380 of file MemoryX.h.

Constructor & Destructor Documentation

◆ IteratorRange() [1/2]

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

Definition at line 382 of file MemoryX.h.

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

◆ IteratorRange() [2/2]

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

Definition at line 385 of file MemoryX.h.

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

Member Function Documentation

◆ accumulate() [1/2]

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 470 of file MemoryX.h.

475  {
476  return this->accumulate( init, binary_op, std::mem_fn( pmf ) );
477  }

References IteratorRange< Iterator >::accumulate().

Here is the call graph for this function:

◆ accumulate() [2/2]

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 451 of file MemoryX.h.

453  {},
454  Unary unary_op = {}
455  ) const
456  {
457  R result = init;
458  for (auto&& v : *this)
459  result = binary_op(result, unary_op(v));
460  return result;
461  }

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

Here is the caller graph for this function:

◆ all_of()

template<typename Iterator >
template<typename F >
bool IteratorRange< Iterator >::all_of ( const F &  f) const
inline

Definition at line 427 of file MemoryX.h.

428  {
429  auto notF =
430  [&](typename std::iterator_traits<Iterator>::reference v)
431  { return !f(v); };
432  return !this->any_of( notF );
433  }

References IteratorRange< Iterator >::any_of().

Here is the call graph for this function:

◆ any_of()

template<typename Iterator >
template<typename F >
bool IteratorRange< Iterator >::any_of ( const F &  f) const
inline

Definition at line 435 of file MemoryX.h.

436  { return this->end() != this->find_if(f); }

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

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ begin()

template<typename Iterator >
Iterator IteratorRange< Iterator >::begin ( ) const
inline

Definition at line 391 of file MemoryX.h.

391 { return this->first; }

Referenced by IteratorRange< Iterator >::empty(), IteratorRange< Iterator >::find(), IteratorRange< Iterator >::find_if(), IteratorRange< Iterator >::index(), IteratorRange< Iterator >::index_if(), and IteratorRange< Iterator >::size().

Here is the caller graph for this function:

◆ contains()

template<typename Iterator >
template<typename T >
bool IteratorRange< Iterator >::contains ( const T &  t) const
inline

Definition at line 412 of file MemoryX.h.

413  { return this->end() != this->find(t); }

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

Here is the call graph for this function:

◆ empty()

template<typename Iterator >
bool IteratorRange< Iterator >::empty ( ) const
inline

Definition at line 397 of file MemoryX.h.

397 { return this->begin() == this->end(); }

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

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ end()

template<typename Iterator >
Iterator IteratorRange< Iterator >::end ( ) const
inline

Definition at line 392 of file MemoryX.h.

392 { return this->second; }

Referenced by IteratorRange< Iterator >::any_of(), IteratorRange< Iterator >::contains(), IteratorRange< Iterator >::empty(), IteratorRange< Iterator >::find(), IteratorRange< Iterator >::find_if(), IteratorRange< Iterator >::index(), IteratorRange< Iterator >::index_if(), and IteratorRange< Iterator >::size().

Here is the caller graph for this function:

◆ find()

template<typename Iterator >
template<typename T >
iterator IteratorRange< Iterator >::find ( const T &  t) const
inline

Definition at line 401 of file MemoryX.h.

402  { return std::find(this->begin(), this->end(), t); }

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

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ find_if()

template<typename Iterator >
template<typename F >
iterator IteratorRange< Iterator >::find_if ( const F &  f) const
inline

Definition at line 415 of file MemoryX.h.

416  { return std::find_if(this->begin(), this->end(), f); }

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

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

Here is the call graph for this function:
Here is the caller graph for this function:

◆ index()

template<typename Iterator >
template<typename T >
long IteratorRange< Iterator >::index ( const T &  t) const
inline

Definition at line 404 of file MemoryX.h.

405  {
406  auto iter = this->find(t);
407  if (iter == this->end())
408  return -1;
409  return std::distance(this->begin(), iter);
410  }

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

Here is the call graph for this function:

◆ index_if()

template<typename Iterator >
template<typename F >
long IteratorRange< Iterator >::index_if ( const F &  f) const
inline

Definition at line 418 of file MemoryX.h.

419  {
420  auto iter = this->find_if(f);
421  if (iter == this->end())
422  return -1;
423  return std::distance(this->begin(), iter);
424  }

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

Here is the call graph for this function:

◆ max() [1/2]

template<typename Iterator >
template<typename R2 , typename C , typename R = R2>
R IteratorRange< Iterator >::max ( R2(C ::*)() const  pmf) const
inline

Definition at line 519 of file MemoryX.h.

520  {
521  return this->max( std::mem_fn( pmf ) );
522  }

References IteratorRange< Iterator >::max().

Here is the call graph for this function:

◆ max() [2/2]

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 506 of file MemoryX.h.

506  {} ) const
507  {
508  return this->accumulate(
509  std::numeric_limits< R >::lowest(),
510  (const R&(*)(const R&, const R&)) std::max,
511  unary_op
512  );
513  }

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

Here is the caller graph for this function:

◆ min() [1/2]

template<typename Iterator >
template<typename R2 , typename C , typename R = R2>
R IteratorRange< Iterator >::min ( R2(C ::*)() const  pmf) const
inline

Definition at line 497 of file MemoryX.h.

498  {
499  return this->min( std::mem_fn( pmf ) );
500  }

References IteratorRange< Iterator >::min().

Here is the call graph for this function:

◆ min() [2/2]

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 484 of file MemoryX.h.

484  {} ) const
485  {
486  return this->accumulate(
487  std::numeric_limits< R >::max(),
488  (const R&(*)(const R&, const R&)) std::min,
489  unary_op
490  );
491  }

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

Here is the caller graph for this function:

◆ none_of()

template<typename Iterator >
template<typename F >
bool IteratorRange< Iterator >::none_of ( const F &  f) const
inline

Definition at line 438 of file MemoryX.h.

439  { return !this->any_of(f); }

References IteratorRange< Iterator >::any_of().

Here is the call graph for this function:

◆ operator bool()

template<typename Iterator >
IteratorRange< Iterator >::operator bool ( ) const
inlineexplicit

Definition at line 398 of file MemoryX.h.

398 { return !this->empty(); }

References IteratorRange< Iterator >::empty().

Here is the call graph for this function:

◆ rbegin()

template<typename Iterator >
reverse_iterator IteratorRange< Iterator >::rbegin ( ) const
inline

Definition at line 394 of file MemoryX.h.

394 { return reverse_iterator{ this->second }; }

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

Here is the caller graph for this function:

◆ rend()

template<typename Iterator >
reverse_iterator IteratorRange< Iterator >::rend ( ) const
inline

Definition at line 395 of file MemoryX.h.

395 { return reverse_iterator{ this->first }; }

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

Here is the caller graph for this function:

◆ reversal()

template<typename Iterator >
IteratorRange< reverse_iterator > IteratorRange< Iterator >::reversal ( ) const
inline

Definition at line 388 of file MemoryX.h.

389  { return { this->rbegin(), this->rend() }; }

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

Here is the call graph for this function:

◆ size()

template<typename Iterator >
size_t IteratorRange< Iterator >::size ( ) const
inline

Definition at line 399 of file MemoryX.h.

399 { return std::distance(this->begin(), this->end()); }

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

Here is the call graph for this function:

◆ sum() [1/2]

template<typename Iterator >
template<typename R2 , typename C , typename R = R2>
R IteratorRange< Iterator >::sum ( R2(C ::*)() const  pmf) const
inline

Definition at line 541 of file MemoryX.h.

542  {
543  return this->sum( std::mem_fn( pmf ) );
544  }

References IteratorRange< Iterator >::sum().

Here is the call graph for this function:

◆ sum() [2/2]

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 528 of file MemoryX.h.

528  {} ) const
529  {
530  return this->accumulate(
531  R{ 0 },
532  std::plus< R >{},
533  unary_op
534  );
535  }

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

Here is the caller graph for this function:

The documentation for this struct was generated from the following file:
IteratorRange::any_of
bool any_of(const F &f) const
Definition: MemoryX.h:435
IteratorRange::rend
reverse_iterator rend() const
Definition: MemoryX.h:395
IteratorRange::begin
Iterator begin() const
Definition: MemoryX.h:391
IteratorRange::max
R max(Unary unary_op={}) const
Definition: MemoryX.h:506
IteratorRange::empty
bool empty() const
Definition: MemoryX.h:397
IteratorRange::end
Iterator end() const
Definition: MemoryX.h:392
IteratorRange::reverse_iterator
std::reverse_iterator< Iterator > reverse_iterator
Definition: MemoryX.h:380
IteratorRange::find
iterator find(const T &t) const
Definition: MemoryX.h:401
IteratorRange::rbegin
reverse_iterator rbegin() const
Definition: MemoryX.h:394
min
int min(int a, int b)
Definition: CompareAudioCommand.cpp:106
IteratorRange::min
R min(Unary unary_op={}) const
Definition: MemoryX.h:484
IteratorRange::accumulate
R accumulate(R init, Binary binary_op={}, Unary unary_op={}) const
Definition: MemoryX.h:451
IteratorRange::sum
R sum(Unary unary_op={}) const
Definition: MemoryX.h:528
IteratorRange::find_if
iterator find_if(const F &f) const
Definition: MemoryX.h:415