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

Member Typedef Documentation

◆ iterator

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

Definition at line 253 of file MemoryX.h.

◆ reverse_iterator

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

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

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

◆ IteratorRange() [2/2]

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

Definition at line 259 of file MemoryX.h.

260 : 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 344 of file MemoryX.h.

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

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

327 {},
328 Unary unary_op = {}
329 ) const
330 {
331 R result = init;
332 for (auto&& v : *this)
333 result = binary_op(result, unary_op(v));
334 return result;
335 }

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

302 {
303 auto notF =
304 [&](typename std::iterator_traits<Iterator>::reference v)
305 { return !f(v); };
306 return !this->any_of( notF );
307 }
bool any_of(const F &f) const
Definition: MemoryX.h:309

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

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

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

265{ return this->first; }

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

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

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

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

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

266{ 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 275 of file MemoryX.h.

276 { 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 289 of file MemoryX.h.

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

279 {
280 auto iter = this->find(t);
281 if (iter == this->end())
282 return -1;
283 return std::distance(this->begin(), iter);
284 }

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

293 {
294 auto iter = this->find_if(f);
295 if (iter == this->end())
296 return -1;
297 return std::distance(this->begin(), iter);
298 }

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

394 {
395 return this->max( std::mem_fn( pmf ) );
396 }
R max(Unary unary_op={}) const
Definition: MemoryX.h:380

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

380 {} ) const
381 {
382 return this->accumulate(
383 std::numeric_limits< R >::lowest(),
384 (const R&(*)(const R&, const R&)) std::max,
385 unary_op
386 );
387 }

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

372 {
373 return this->min( std::mem_fn( pmf ) );
374 }
R min(Unary unary_op={}) const
Definition: MemoryX.h:358

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

358 {} ) const
359 {
360 return this->accumulate(
361 std::numeric_limits< R >::max(),
362 (const R&(*)(const R&, const R&)) std::min,
363 unary_op
364 );
365 }
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 312 of file MemoryX.h.

313 { 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 272 of file MemoryX.h.

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

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

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

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

269{ 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 262 of file MemoryX.h.

263 { return { this->rbegin(), this->rend() }; }
reverse_iterator rend() const
Definition: MemoryX.h:269
reverse_iterator rbegin() const
Definition: MemoryX.h:268

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

273{ 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 415 of file MemoryX.h.

416 {
417 return this->sum( std::mem_fn( pmf ) );
418 }
R sum(Unary unary_op={}) const
Definition: MemoryX.h:402

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

402 {} ) const
403 {
404 return this->accumulate(
405 R{ 0 },
406 std::plus< R >{},
407 unary_op
408 );
409 }

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

Here is the caller graph for this function:

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