43 template <
class CONTAINER>
80 template <
class CONTAINER,
class ITERATOR =
typename CONTAINER::const_iterator>
83 static_assert( std::is_same_v<ITERATOR, typename CONTAINER::const_iterator> );
90 using Base = std::pair<iterator, iterator>;
109 template <
typename InputIterator>
110 Range_( InputIterator first, InputIterator last ) :
m_base( first, last ) {}
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 return Range_( std::next(
begin(), index1 ), std::next(
begin(), index2 ) );
182 return ( *
this )( index );
186 template <
class C,
class I>
188 return std::lexicographical_compare(
begin(),
end(), right.
begin(), right.
end() );
191 template <
class ANOTHERCONTAINER>
193 return std::lexicographical_compare(
begin(),
end(), right.begin(), right.end() );
198 if ( &right ==
this ) {
return true; }
202 template <
class ANOTHERCONTAINER>
204 return right.size() ==
size() && std::equal(
begin(),
end(), right.begin() );
210 explicit operator bool()
const {
return !
empty(); }
248 template <
class CONTAINER>
Useful class for representation of "sequence" of the objects through the range of valid iterators.
typename T::const_iterator const_iterator
bool operator==(const ANOTHERCONTAINER &right) const
compare with another container
typename Gaudi::details::container< T >::Container Container
Range_(InputIterator first, InputIterator last)
Constructor.
const_reference at(const long index) const
Checked access to the elements by index (valid for all sequences)
bool operator!() const
empty sequence?
Range_ slice(long index1, long index2) const
get a "slice" of a range, in Python style
iter_traits::value_type value_type
bool empty() const
empty sequence ?
std::reverse_iterator< iterator > const_reverse_iterator
Range_()=default
default constructor
bool operator==(const Range_ &right) const
equality with another range
std::reverse_iterator< iterator > reverse_iterator
Range_(const Container &cont)
constructor from the container
const_reference back() const
access for the back element (only for non-empty ranges!)
bool operator<(const ANOTHERCONTAINER &right) const
compare with another container
iter_traits::reference reference
const_reference operator[](const long index) const
non-checked access to the elements by index (valid only for non-empty sequences)
bool operator<(const Range_< C, I > &right) const
compare with another range
reverse_iterator rend() const
access to begin of the reversed sequence (const)
std::iterator_traits< iterator > iter_traits
const_reference operator()(const size_t index) const
non-checked access to the elements by index (valid only for non-empty sequences)
Range_(const Base &base)
constructor from the pair of iterators
const_reference front() const
access for the first element (only for non-empty ranges!)
std::pair< iterator, iterator > Base
iterator cend() const
access to end of the sequence (const version)
const Base & base() const
iterator cbegin() const
access to begin of the sequence (const version )
reverse_iterator rbegin() const
access to begin of the reversed sequence (const)
size_t size() const
size of the sequence (number of elements)
iter_traits::reference const_reference
typename details::detector< Default, void, Op, Args... >::type detected_or_t
GAUDI_API void rangeException(const long index, const size_t size)
Helpful function to throw an "out-of-range exception" for class Range_.
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
NamedRange_< CONTAINER > range(const CONTAINER &cnt, std::string name)
simple function to create the named range from arbitrary container
helper class to simplify the dealing with ranges in Python
helper structure to get container type
typename T::Container _has_container_t
Gaudi::cpp17::detected_or_t< CONTAINER, _has_container_t, CONTAINER > Container