2 #define GAUDI_RANGE_H 1 74 template <
class CONTAINER>
79 typedef std::pair<
typename CONTAINER::const_iterator,
80 typename CONTAINER::const_iterator>
Base ;
87 typedef typename Container::const_iterator
iterator ;
91 typedef typename Container::const_reference
reference ;
105 Range_( iterator ibegin , iterator iend ) : m_base ( ibegin , iend ) {}
109 Range_(
const Base& base ) : m_base( base ) {}
117 Range_( iterator ibegin ) : m_base( ibegin , ibegin ) {}
122 inline bool empty ()
const {
return m_base.second == m_base.first ; }
127 inline iterator
begin ()
const {
return m_base.first ; }
129 inline iterator
end ()
const {
return m_base.second ; }
131 inline reverse_iterator
rbegin ()
const {
return reverse_iterator (
end () ) ; }
133 inline reverse_iterator
rend ()
const {
return reverse_iterator (
begin () ) ; }
143 if ( empty() || index1 == index2 ) {
return Range_() ; }
145 if ( index1 < 0 ) { index1 += size () ; }
146 if ( index2 < 0 ) { index2 += size () ; }
148 if ( index1 < 0 ) {
return Range_ () ; }
149 if ( index2 < index1 ) {
return Range_ () ; }
151 if ( index1 > (
long) size () ) {
return Range_() ; }
152 if ( index2 > (
long) size () ) { index2 = size() ; }
163 inline const_reference operator () (
const size_t index )
const 171 inline const_reference operator [] (
const long index )
const 172 {
return (*
this)( index ) ; }
178 inline const_reference
at (
const long index )
const 180 if ( index < 0 || index >= (
long) size () )
182 return (*
this) ( index );
197 (
begin () ,
end () , right.begin () , right.end () ) ;
205 if ( &right ==
this ) {
return true ; }
206 return right.
size() == size() &&
212 return right.size() == size() &&
219 bool operator! ()
const {
return empty () ; }
224 operator const Base& ()
const {
return base () ; }
226 inline const Base&
base ()
const {
return m_base ; }
262 template <
class CONTAINER>
272 #endif // GAUDI_RANGE_H bool empty() const
empty sequence ?
bool operator==(const Range_ &right) const
equality with another range
std::pair< iterator, iterator > _Base
internal types
std::pair< typename CONTAINER::const_iterator, typename CONTAINER::const_iterator > Base
GAUDI_API void rangeException(const long index, const size_t size)
Helpful function to throw an "out-of-range exception" for class Range_.
Range_ slice(long index1, long index2) const
get a "slice" of a range, in Python style
helper class to simplify the dealing with ranges in Python
Base m_base
the base itself
Range_(iterator ibegin, iterator iend)
Constructor.
const_reference back() const
access for the back element (only for non-empty ranges!)
const_reference front() const
access for the first element (only for non-empty ranges!)
const_reference at(const long index) const
Checked access to the elements by index (valid for all sequences) for out-of-range access...
size_t size() const
size of the sequence (number of elements)
auto begin(reverse_wrapper< T > &w)
Range_< Container > _Self
Container::const_reverse_iterator const_reverse_iterator
NamedRange_< CONTAINER > range(const CONTAINER &cnt, std::string name)
simple function to create the named range form arbitrary container
CONTAINER Container
type for actual contained iterator
Container::value_type value_type
iterator begin() const
access to begin of the sequence (const version )
auto end(reverse_wrapper< T > &w)
bool operator==(const Container &right) const
equality with the base container
Container::const_iterator const_iterator
bool operator<(const EventIDBase &lhs, const EventIDBase &rhs)
T lexicographical_compare(T...args)
Range_(const Container &cont)
constructor from the container
Container::const_iterator iterator
Container::const_reverse_iterator reverse_iterator
const Base & base() const
conversion operator to the std::pair
Useful class for representation of "sequence" of the objects through the range of valid iterators...
iterator end() const
access to end of the sequence (const version)
Range_(const Base &base)
constructor from the pair of iterators
reverse_iterator rbegin() const
access to begin of the reversed sequence (const)
Container::const_reference reference
Helper functions to set/get the application return code.
Container::const_reference const_reference
reverse_iterator rend() const
access to begin of the reversed sequence (const)