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 ) {}
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() ; }
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 ; }
212 return right.size() ==
size() &&
224 operator const Base& ()
const {
return 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
const_reference operator[](const long index) const
non-checked access to the elements by index (valid only for non-empty sequences)
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
const_reference operator()(const size_t index) const
non-checked access to the elements by index (valid only for non-empty sequences)
helper class to simplify the dealing with ranges in Python
Base m_base
the base itself
Range_(iterator ibegin, iterator iend)
Constructor.
~Range_()=default
destructor
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)
Range_< Container > _Self
bool operator<(const Range_ &right) const
compare with another range
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 )
bool operator==(const Container &right) const
equality with the base container
Container::const_iterator const_iterator
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
Range_()=default
default constructor
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)
bool operator!() const
empty sequence?