Audacity 3.2.0
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 277 of file MemoryX.h.

Member Typedef Documentation

◆ iterator

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

Definition at line 278 of file MemoryX.h.

◆ reverse_iterator

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

Definition at line 279 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 281 of file MemoryX.h.

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

◆ IteratorRange() [2/2]

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

Definition at line 284 of file MemoryX.h.

285 : 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 369 of file MemoryX.h.

374 {
375 return this->accumulate( init, binary_op, std::mem_fn( pmf ) );
376 }
R accumulate(R init, Binary binary_op={}, Unary unary_op={}) const
Definition: MemoryX.h:350

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

352 {},
353 Unary unary_op = {}
354 ) const
355 {
356 R result = init;
357 for (auto&& v : *this)
358 result = binary_op(result, unary_op(v));
359 return result;
360 }

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

327 {
328 auto notF =
329 [&](typename std::iterator_traits<Iterator>::reference v)
330 { return !f(v); };
331 return !this->any_of( notF );
332 }
bool any_of(const F &f) const
Definition: MemoryX.h:334

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

335 { return this->end() != this->find_if(f); }
iterator find_if(const F &f) const
Definition: MemoryX.h:314
Iterator end() const
Definition: MemoryX.h:291

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

290{ return this->first; }

Referenced by IteratorRange< Iterator >::empty(), IteratorRange< Iterator >::find(), IteratorRange< Iterator >::find_if(), IteratorRange< Iterator >::index(), IteratorRange< Iterator >::index_if(), MixAndRender(), 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 311 of file MemoryX.h.

312 { return this->end() != this->find(t); }
iterator find(const T &t) const
Definition: MemoryX.h:300

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

296{ return this->begin() == this->end(); }
Iterator begin() const
Definition: MemoryX.h:290

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

Referenced by MixAndRender(), and 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 291 of file MemoryX.h.

291{ 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 300 of file MemoryX.h.

301 { 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 314 of file MemoryX.h.

315 { 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 303 of file MemoryX.h.

304 {
305 auto iter = this->find(t);
306 if (iter == this->end())
307 return -1;
308 return std::distance(this->begin(), iter);
309 }

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

318 {
319 auto iter = this->find_if(f);
320 if (iter == this->end())
321 return -1;
322 return std::distance(this->begin(), iter);
323 }

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

419 {
420 return this->max( std::mem_fn( pmf ) );
421 }
R max(Unary unary_op={}) const
Definition: MemoryX.h:405

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

405 {} ) const
406 {
407 return this->accumulate(
408 std::numeric_limits< R >::lowest(),
409 (const R&(*)(const R&, const R&)) std::max,
410 unary_op
411 );
412 }

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

397 {
398 return this->min( std::mem_fn( pmf ) );
399 }
R min(Unary unary_op={}) const
Definition: MemoryX.h:383

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

383 {} ) const
384 {
385 return this->accumulate(
386 std::numeric_limits< R >::max(),
387 (const R&(*)(const R&, const R&)) std::min,
388 unary_op
389 );
390 }
int min(int a, int b)

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

338 { 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 297 of file MemoryX.h.

297{ return !this->empty(); }
bool empty() const
Definition: MemoryX.h:296

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

293{ return reverse_iterator{ this->second }; }
std::reverse_iterator< Iterator > reverse_iterator
Definition: MemoryX.h:279

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

294{ 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 287 of file MemoryX.h.

288 { return { this->rbegin(), this->rend() }; }
reverse_iterator rend() const
Definition: MemoryX.h:294
reverse_iterator rbegin() const
Definition: MemoryX.h:293

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

298{ 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 440 of file MemoryX.h.

441 {
442 return this->sum( std::mem_fn( pmf ) );
443 }
R sum(Unary unary_op={}) const
Definition: MemoryX.h:427

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

427 {} ) const
428 {
429 return this->accumulate(
430 R{ 0 },
431 std::plus< R >{},
432 unary_op
433 );
434 }

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

Here is the caller graph for this function:

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