4 #define GAUDI_RANGE_H 1
76 template <
class CONTAINER>
81 typedef std::pair<
typename CONTAINER::const_iterator,
82 typename CONTAINER::const_iterator>
Base ;
89 typedef typename Container::const_iterator
iterator ;
93 typedef typename Container::const_reference
reference ;
96 typedef std::pair<iterator,iterator>
_Base ;
127 {
return std::distance (
m_base.first ,
m_base.second ) ; }
142 std::advance ( i , -1 ) ;
150 if (
empty() || index1 == index2 ) {
return Range_() ; }
152 if ( index1 < 0 ) { index1 +=
size () ; }
153 if ( index2 < 0 ) { index2 +=
size () ; }
155 if ( index1 < 0 ) {
return Range_ () ; }
156 if ( index2 < index1 ) {
return Range_ () ; }
158 if ( index1 > (
long)
size () ) {
return Range_() ; }
159 if ( index2 > (
long)
size () ) { index2 =
size() ; }
162 std::advance ( i1 , index1 ) ;
164 std::advance ( i2 , index2 ) ;
166 return Range_( i1 , i2 ) ;
176 std::advance ( i , index ) ;
184 {
return (*
this)( index ) ; }
192 if ( index < 0 || index >= (
long)
size () )
194 return (*
this) ( index );
202 return std::lexicographical_compare
208 return std::lexicographical_compare
209 (
begin () ,
end () , right.begin () , right.end () ) ;
217 if ( &right ==
this ) {
return true ; }
218 if ( right.
size () !=
size () ) {
return false ; }
224 if ( right.size () !=
size () ) {
return false ; }
225 return std::equal (
begin () ,
end () , right.begin() ) ;
274 template <
class CONTAINER>
284 #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.
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
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
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...
Range_()
default constructor
iterator end() const
access to end of the sequence (const version)
Range_(const Base &base)
constructor from the pair of iterators
This is a number of static methods for bootstrapping the Gaudi framework.
NamedRange_< CONTAINER > range(const CONTAINER &cnt, const std::string &name)
simple function to create the named range form arbitrary container
reverse_iterator rbegin() const
access to begin of the reversed sequence (const)
Container::const_reference reference
Container::const_reference const_reference
reverse_iterator rend() const
access to begin of the reversed sequence (const)
bool operator!() const
empty sequence?