Belle II Software development
SortedRange< AIterator > Class Template Reference

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

#include <SortedRange.h>

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

Public Types

using Iterator = AIterator
 Iterator type of the range.
 
using Reference = typename std::iterator_traits<AIterator>::reference
 The type the iterator references.
 
using iterator = Iterator
 Iterator definition for stl.
 
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

template<class AOtherIterator>
 SortedRange (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>>
 SortedRange (const Ts &ts)
 Constructor from another range.
 
template<class T>
SortedRange< AIterator > equal_range (const T &t) const
 Access to a sub range to mimic the behaviour of a sorted container.
 
template<class T>
SortedRange< AIterator > upper_bound (const T &t) const
 Access to a upper bound to mimic the behaviour of a sorted container.
 
template<class T>
SortedRange< AIterator > lowers_bound (const T &t) const
 Access to a lower bound to mimic the behaviour of a sorted container.
 
bool count (Reference t) const
 Counts the number of equivalent items in the 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.
 

Public Attributes

T1 first_type
 STL member.
 
T2 second_type
 STL member.
 

Private Types

using Super = Range<AIterator>
 Type of the base class.
 

Detailed Description

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

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

Definition at line 25 of file SortedRange.h.

Member Typedef Documentation

◆ Iterator

template<class AIterator>
using Iterator = AIterator

Iterator type of the range.

Definition at line 33 of file SortedRange.h.

◆ iterator

template<class AIterator>
using iterator = Iterator
inherited

Iterator definition for stl.

Definition at line 36 of file Range.h.

◆ Reference

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

The type the iterator references.

Definition at line 36 of file SortedRange.h.

◆ Super

template<class AIterator>
using Super = Range<AIterator>
private

Type of the base class.

Definition at line 29 of file SortedRange.h.

◆ value_type

template<class AIterator>
using value_type = typename std::iterator_traits<AIterator>::value_type
inherited

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

◆ SortedRange() [1/2]

template<class AIterator>
template<class AOtherIterator>
SortedRange ( const std::pair< AOtherIterator, AOtherIterator > & itPair)
inlineexplicit

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

Definition at line 41 of file SortedRange.h.

42 : Super(AIterator(itPair.first), AIterator(itPair.second))
43 {}

◆ SortedRange() [2/2]

template<class AIterator>
template<class Ts, class ItT = GetIterator<Ts>>
SortedRange ( const Ts & ts)
inlineexplicit

Constructor from another range.

Definition at line 47 of file SortedRange.h.

48 : Super(AIterator(std::begin(ts)), AIterator(std::end(ts)))
49 {}

Member Function Documentation

◆ at()

template<class AIterator>
Reference at ( std::size_t i) const
inlineinherited

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 }

◆ back()

template<class AIterator>
Reference back ( ) const
inlineinherited

Returns the dereferenced iterator before end()

Definition at line 84 of file Range.h.

85 { return *(end() - 1); }

◆ begin()

template<class AIterator>
Iterator begin ( ) const
inlineinherited

Begin of the range for range based for.

Definition at line 64 of file Range.h.

65 { return this->first; }

◆ count() [1/2]

template<class AIterator>
bool count ( Reference t)
inlineinherited

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); }

◆ count() [2/2]

template<class AIterator>
bool count ( Reference t) const
inline

Counts the number of equivalent items in the range.

Definition at line 70 of file SortedRange.h.

71 {
72 Range<AIterator> relevant_range = this->equal_range(t);
73 return relevant_range.count(t);
74 }

◆ empty()

template<class AIterator>
bool empty ( ) const
inlineinherited

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()

template<class AIterator>
Iterator end ( ) const
inlineinherited

End of the range for range based for.

Definition at line 68 of file Range.h.

69 { return this->second; }

◆ equal_range()

template<class AIterator>
template<class T>
SortedRange< AIterator > equal_range ( const T & t) const
inline

Access to a sub range to mimic the behaviour of a sorted container.

Definition at line 56 of file SortedRange.h.

57 { return SortedRange<AIterator>(std::equal_range(this->begin(), this->end(), t)); }

◆ front()

template<class AIterator>
Reference front ( ) const
inlineinherited

Returns the dereferenced iterator at begin()

Definition at line 80 of file Range.h.

81 { return *(begin()); }

◆ lowers_bound()

template<class AIterator>
template<class T>
SortedRange< AIterator > lowers_bound ( const T & t) const
inline

Access to a lower bound to mimic the behaviour of a sorted container.

Definition at line 66 of file SortedRange.h.

67 { return SortedRange<AIterator>(std::lower_bound(this->begin(), this->end(), t)); }

◆ operator[]()

template<class AIterator>
Reference operator[] ( std::size_t i) const
inlineinherited

Returns the object at index i.

Definition at line 88 of file Range.h.

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

◆ size()

template<class AIterator>
std::size_t size ( ) const
inlineinherited

Returns the total number of objects in this range.

Definition at line 76 of file Range.h.

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

◆ upper_bound()

template<class AIterator>
template<class T>
SortedRange< AIterator > upper_bound ( const T & t) const
inline

Access to a upper bound to mimic the behaviour of a sorted container.

Definition at line 61 of file SortedRange.h.

62 { return SortedRange<AIterator>(std::upper_bound(this->begin(), this->end(), t)); }

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