 |
Belle II Software
release-05-02-19
|
12 #include <tracking/trackFindingCDC/utilities/GetIterator.h>
23 namespace TrackFindingCDC {
26 template<
class AIterator>
27 class Range :
public std::pair<AIterator, AIterator> {
31 using Super = std::pair<AIterator, AIterator>;
41 using Reference =
typename std::iterator_traits<AIterator>::reference;
44 using value_type =
typename std::iterator_traits<AIterator>::value_type;
51 template<
class AOtherIterator>
52 explicit Range(
const std::pair<AOtherIterator, AOtherIterator>& itPair)
53 :
Super(AIterator(itPair.first), AIterator(itPair.second))
57 template<
class Ts,
class ItT = GetIterator<Ts>>
58 explicit Range(
const Ts& ts)
67 {
return this->first; }
71 {
return this->second; }
79 {
return std::distance(
begin(),
end()); }
83 {
return *(
begin()); }
87 {
return *(
end() - 1); }
91 {
return *(
begin() + i); }
96 if (not(i <
size())) {
97 throw std::out_of_range(
"Range : Requested index " + std::to_string(i) +
" is out of bounds.");
104 {
return std::count(this->
begin(), this->
end(), t); }
109 template<
class AIterator>
110 Range<AIterator> asRange(std::pair<AIterator, AIterator>
const& x)
116 template<
class AIterator>
Reference operator[](std::size_t i) const
Returns the object at index i.
Reference back() const
Returns the derefenced iterator before end()
Range()=default
Default constructor for ROOT.
std::size_t size() const
Returns the total number of objects in this range.
Iterator begin() const
Begin of the range for range based for.
typename std::iterator_traits< AIterator >::reference Reference
The type the iterator references.
Iterator end() const
End of the range for range based for.
map< unsigned, const TOPSampleTimes * >::const_iterator Iterator
Iteratior for m_map.
Abstract base class for different kinds of events.
bool count(Reference t)
Counts the number of equivalent items in the range.
AIterator Iterator
Iterator type of the range.
A pair of iterators usable with the range base for loop.
Iterator iterator
Iterator definition for stl.
Reference at(std::size_t i) const
Returns the object at index i.
std::pair< AIterator, AIterator > Super
Type of the base class.
bool empty() const
Checks if the begin equals the end iterator, hence if the range is empty.
Reference front() const
Returns the derefenced iterator at begin()
typename std::iterator_traits< AIterator >::value_type value_type
The type behind the iterator (make it possible to use the range as a "list")