Belle II Software development
Range< AIterator > Class Template Reference

A pair of iterators usable with the range base for loop. More...

#include <Range.h>

Inheritance diagram for Range< AIterator >:
CDCWireLayer CDCWireSuperLayer SortedRange< AIterator >

Public Types

using Iterator = AIterator
 Iterator type of the range.
 
using iterator = Iterator
 Iterator definition for stl.
 
using Reference = typename std::iterator_traits< AIterator >::reference
 The type the iterator references.
 
using value_type = typename std::iterator_traits< AIterator >::value_type
 The type behind the iterator (make it possible to use the range as a "list")
 

Public Member Functions

 Range ()=default
 Default constructor for ROOT.
 
template<class AOtherIterator >
 Range (const std::pair< AOtherIterator, AOtherIterator > &itPair)
 Constructor to adapt a pair as returned by e.g. std::equal_range.
 
template<class Ts , class ItT = GetIterator<Ts>>
 Range (const Ts &ts)
 Constructor from another range.
 
Iterator begin () const
 Begin of the range for range based for.
 
Iterator end () const
 End of the range for range based for.
 
bool empty () const
 Checks if the begin equals the end iterator, hence if the range is empty.
 
std::size_t size () const
 Returns the total number of objects in this range.
 
Reference front () const
 Returns the dereferenced iterator at begin()
 
Reference back () const
 Returns the dereferenced iterator before end()
 
Reference operator[] (std::size_t i) const
 Returns the object at index i.
 
Reference at (std::size_t i) const
 Returns the object at index i.
 
bool count (Reference t)
 Counts the number of equivalent items in the range.
 

Private Types

using Super = std::pair< AIterator, AIterator >
 Type of the base class.
 

Detailed Description

template<class AIterator>
class Belle2::TrackFindingCDC::Range< AIterator >

A pair of iterators usable with the range base for loop.

Definition at line 25 of file Range.h.

Member Typedef Documentation

◆ Iterator

using Iterator = AIterator

Iterator type of the range.

Definition at line 33 of file Range.h.

◆ iterator

using iterator = Iterator

Iterator definition for stl.

Definition at line 36 of file Range.h.

◆ Reference

using Reference = typename std::iterator_traits<AIterator>::reference

The type the iterator references.

Definition at line 39 of file Range.h.

◆ Super

using Super = std::pair<AIterator, AIterator>
private

Type of the base class.

Definition at line 29 of file Range.h.

◆ value_type

using value_type = typename std::iterator_traits<AIterator>::value_type

The type behind the iterator (make it possible to use the range as a "list")

Definition at line 42 of file Range.h.

Constructor & Destructor Documentation

◆ Range() [1/2]

Range ( const std::pair< AOtherIterator, AOtherIterator > &  itPair)
inlineexplicit

Constructor to adapt a pair as returned by e.g. std::equal_range.

Definition at line 50 of file Range.h.

51 : Super(AIterator(itPair.first), AIterator(itPair.second))
52 {}
std::pair< AIterator, AIterator > Super
Type of the base class.
Definition: Range.h:29

◆ Range() [2/2]

Range ( const Ts &  ts)
inlineexplicit

Constructor from another range.

Definition at line 56 of file Range.h.

57 : Super(AIterator(std::begin(ts)), AIterator(std::end(ts)))
58 {}

Member Function Documentation

◆ at()

Reference at ( std::size_t  i) const
inline

Returns the object at index i.

Definition at line 92 of file Range.h.

93 {
94 if (not(i < size())) {
95 throw std::out_of_range("Range : Requested index " + std::to_string(i) + " is out of bounds.");
96 }
97 return operator[](i);
98 }
Reference operator[](std::size_t i) const
Returns the object at index i.
Definition: Range.h:88
std::size_t size() const
Returns the total number of objects in this range.
Definition: Range.h:76

◆ back()

Reference back ( ) const
inline

Returns the dereferenced iterator before end()

Definition at line 84 of file Range.h.

85 { return *(end() - 1); }
Iterator end() const
End of the range for range based for.
Definition: Range.h:68

◆ begin()

Iterator begin ( ) const
inline

Begin of the range for range based for.

Definition at line 64 of file Range.h.

65 { return this->first; }

◆ count()

bool count ( Reference  t)
inline

Counts the number of equivalent items in the range.

Definition at line 101 of file Range.h.

102 { return std::count(this->begin(), this->end(), t); }
Iterator begin() const
Begin of the range for range based for.
Definition: Range.h:64

◆ empty()

bool empty ( ) const
inline

Checks if the begin equals the end iterator, hence if the range is empty.

Definition at line 72 of file Range.h.

73 { return begin() == end(); }

◆ end()

Iterator end ( ) const
inline

End of the range for range based for.

Definition at line 68 of file Range.h.

69 { return this->second; }

◆ front()

Reference front ( ) const
inline

Returns the dereferenced iterator at begin()

Definition at line 80 of file Range.h.

81 { return *(begin()); }

◆ operator[]()

Reference operator[] ( std::size_t  i) const
inline

Returns the object at index i.

Definition at line 88 of file Range.h.

89 { return *(begin() + i); }

◆ size()

std::size_t size ( ) const
inline

Returns the total number of objects in this range.

Definition at line 76 of file Range.h.

77 { return std::distance(begin(), end()); }

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