| The Gaudi Framework v28r2p1 (f1a77ff4)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Types | Public Member Functions | Private Types | Private Attributes | List of all members
Gaudi::Range_< CONTAINER, ITERATOR > Class Template Reference

Useful class for representation of "sequence" of the objects through the range of valid iterators. More...

`#include <GaudiUtils/Range.h>`

Inheritance diagram for Gaudi::Range_< CONTAINER, ITERATOR >:
[legend]
Collaboration diagram for Gaudi::Range_< CONTAINER, ITERATOR >:
[legend]

## Public Types
typedef std::pair< ITERATOR, ITERATOR > | Base
typedef Gaudi::details::container< CONTAINER >::Container | Container
| type for actual contained iterator More...
typedef ITERATOR | iterator
typedef ITERATOR | const_iterator
typedef iter_traits::value_type | value_type
typedef iter_traits::reference | reference
typedef iter_traits::reference | const_reference
typedef std::reverse_iterator< iterator > | reverse_iterator
typedef std::reverse_iterator< iterator > | const_reverse_iterator

## Public Member Functions
| Range_ ()=default
| internal types More...
| Range_ (iterator ibegin, iterator iend)
| Constructor. More...
| Range_ (const Base &base)
| constructor from the pair of iterators More...
| Range_ (const Container &cont)
| constructor from the container More...
| Range_ (iterator ibegin)
| ~Range_ ()=default
| destructor More...
bool | empty () const
| empty sequence ? More...
size_t | size () const
| size of the sequence (number of elements) More...
iterator | begin () const
| access to begin of the sequence (const version ) More...
iterator | end () const
| access to end of the sequence (const version) More...
iterator | cbegin () const
| access to begin of the sequence (const version ) More...
iterator | cend () const
| access to end of the sequence (const version) More...
reverse_iterator | rbegin () const
| access to begin of the reversed sequence (const) More...
reverse_iterator | rend () const
| access to begin of the reversed sequence (const) More...
const_reference | front () const
| access for the first element (only for non-empty ranges!) More...
const_reference | back () const
| access for the back element (only for non-empty ranges!) More...
Range_ | slice (long index1, long index2) const
| get a "slice" of a range, in Python style More...
const_reference | operator() (const size_t index) const
| non-checked access to the elements by index (valid only for non-empty sequences) More...
const_reference | operator[] (const long index) const
| non-checked access to the elements by index (valid only for non-empty sequences) More...
const_reference | at (const long index) const
  | Checked access to the elements by index (valid for all sequences) Exceptions
  GaudiException | for out-of-range access.
More...
template<class C , class I >
bool | operator< (const Range_< C, I > &right) const
| compare with another range More...
template<class ANOTHERCONTAINER >
bool | operator< (const ANOTHERCONTAINER &right) const
| compare with another container More...
bool | operator== (const Range_ &right) const
| equality with another range More...
template<class CNT , class IT >
bool | operator== (const Range_< CNT, IT > &right) const
| equality with another range type More...
template<class ANOTHERCONTAINER >
bool | operator== (const ANOTHERCONTAINER &right) const
| compare with another container More...
bool | operator! () const
| empty sequence? More...
| operator bool () const
| non-empty sequence? More...
| operator const Base & () const
| conversion operator to the std::pair More...
const Base & | base () const
| conversion operator to the std::pair More...

## Private Types
typedef std::iterator_traits< iterator > | iter_traits

## Private Attributes
Base | m_base
| the base itself More...

## Detailed Description

### template<class CONTAINER, class ITERATOR = typename Gaudi::details::container<CONTAINER>::Iterator>
class Gaudi::Range_< CONTAINER, ITERATOR >

Useful class for representation of "sequence" of the objects through the range of valid iterators.

The range could be created over ALL container types which supports at least bidirectional iterators.

The minimum requirements from the container type:

- support the concept of "CONTAINER::value_type"
- support the concept of "CONTAINER::const_iterator"
- support the concept of "CONTAINER::const_reference"
- support the concept of "CONTAINER::const_reverse_iterator"
- the iterator should be ok for "std::distance" and "std::advance"
- support for "const_iterator CONTAINER::begin () const"
- support for "const_iterator CONTAINER::end () const"
- support for "const_reverse_iterator CONTAINER::rbegin () const"
- support for "const_reverse_iterator CONTAINER::rend () const"

Author
  Vanya Belyaev Ivan..nosp@m.Bely.nosp@m.aev@i.nosp@m.tep..nosp@m.ru

Date
  2002-07-12

Definition at line 102 of file Range.h.

## Member Typedef Documentation

template<class CONTAINER, class ITERATOR = typename Gaudi::details::container<CONTAINER>::Iterator>

typedef std::pair<ITERATOR,ITERATOR> Gaudi::Range_< CONTAINER, ITERATOR >::Base

Definition at line 106 of file Range.h.

template<class CONTAINER, class ITERATOR = typename Gaudi::details::container<CONTAINER>::Iterator>

typedef ITERATOR Gaudi::Range_< CONTAINER, ITERATOR >::const_iterator

Definition at line 114 of file Range.h.

template<class CONTAINER, class ITERATOR = typename Gaudi::details::container<CONTAINER>::Iterator>

typedef iter_traits::reference Gaudi::Range_< CONTAINER, ITERATOR >::const_reference

Definition at line 124 of file Range.h.

template<class CONTAINER, class ITERATOR = typename Gaudi::details::container<CONTAINER>::Iterator>

typedef std::reverse_iterator<iterator> Gaudi::Range_< CONTAINER, ITERATOR >::const_reverse_iterator

Definition at line 127 of file Range.h.

template<class CONTAINER, class ITERATOR = typename Gaudi::details::container<CONTAINER>::Iterator>

typedef Gaudi::details::container<CONTAINER>::Container Gaudi::Range_< CONTAINER, ITERATOR >::Container

type for actual contained iterator

Definition at line 111 of file Range.h.

template<class CONTAINER, class ITERATOR = typename Gaudi::details::container<CONTAINER>::Iterator>

typedef std::iterator_traits<iterator> Gaudi::Range_< CONTAINER, ITERATOR >::iter_traits
| private

Definition at line 118 of file Range.h.

template<class CONTAINER, class ITERATOR = typename Gaudi::details::container<CONTAINER>::Iterator>

typedef ITERATOR Gaudi::Range_< CONTAINER, ITERATOR >::iterator

Definition at line 113 of file Range.h.

template<class CONTAINER, class ITERATOR = typename Gaudi::details::container<CONTAINER>::Iterator>

typedef iter_traits::reference Gaudi::Range_< CONTAINER, ITERATOR >::reference

Definition at line 123 of file Range.h.

template<class CONTAINER, class ITERATOR = typename Gaudi::details::container<CONTAINER>::Iterator>

typedef std::reverse_iterator<iterator> Gaudi::Range_< CONTAINER, ITERATOR >::reverse_iterator

Definition at line 126 of file Range.h.

template<class CONTAINER, class ITERATOR = typename Gaudi::details::container<CONTAINER>::Iterator>

typedef iter_traits::value_type Gaudi::Range_< CONTAINER, ITERATOR >::value_type

Definition at line 122 of file Range.h.

## Constructor & Destructor Documentation

template<class CONTAINER, class ITERATOR = typename Gaudi::details::container<CONTAINER>::Iterator>

Gaudi::Range_< CONTAINER, ITERATOR >::Range_ | ( |  | ) |
| default

internal types

default constructor

template<class CONTAINER, class ITERATOR = typename Gaudi::details::container<CONTAINER>::Iterator>

Gaudi::Range_< CONTAINER, ITERATOR >::Range_ | ( | iterator | ibegin,
|  | iterator | iend
| ) |  |
| inline

Constructor.

Parameters

  ibegin | iterator to begin of the sequence
  iend | iterator to end of the sequence

Definition at line 138 of file Range.h.

138 : m_base ( ibegin , iend ) {}
Gaudi::Range_::m_base
Base m_base
the base itself
Definition: Range.h:278
template<class CONTAINER, class ITERATOR = typename Gaudi::details::container<CONTAINER>::Iterator>

Gaudi::Range_< CONTAINER, ITERATOR >::Range_ | ( | const Base & | base | ) |
| inline

constructor from the pair of iterators

Parameters

  base | pair of the iterators

Definition at line 142 of file Range.h.

142 : m_base( base ) {}
Gaudi::Range_::m_base
Base m_base
the base itself
Definition: Range.h:278
Gaudi::Range_::base
const Base & base() const
conversion operator to the std::pair
Definition: Range.h:273
template<class CONTAINER, class ITERATOR = typename Gaudi::details::container<CONTAINER>::Iterator>

Gaudi::Range_< CONTAINER, ITERATOR >::Range_ | ( | const Container & | cont | ) |
| inline

constructor from the container

Parameters

  cont | reference to the container

Definition at line 146 of file Range.h.

146 : m_base( cont.begin() , cont.end() ) {}
Gaudi::Range_::m_base
Base m_base
the base itself
Definition: Range.h:278
template<class CONTAINER, class ITERATOR = typename Gaudi::details::container<CONTAINER>::Iterator>

Gaudi::Range_< CONTAINER, ITERATOR >::Range_ | ( | iterator | ibegin | ) |
| inline

Definition at line 150 of file Range.h.

150 : m_base( ibegin , ibegin ) {}
Gaudi::Range_::m_base
Base m_base
the base itself
Definition: Range.h:278
template<class CONTAINER, class ITERATOR = typename Gaudi::details::container<CONTAINER>::Iterator>

Gaudi::Range_< CONTAINER, ITERATOR >::~Range_ | ( |  | ) |
| default

destructor

## Member Function Documentation

template<class CONTAINER, class ITERATOR = typename Gaudi::details::container<CONTAINER>::Iterator>

const_reference Gaudi::Range_< CONTAINER, ITERATOR >::at | ( | const long | index | ) | const
| inline

Checked access to the elements by index (valid for all sequences)

Exceptions

  GaudiException | for out-of-range access.

Parameters

  index | the index of the element to be accessed

Definition at line 213 of file Range.h.

214 {
215 if ( index < 0 || index >= (long) size () )
216 { Gaudi::details::rangeException( index , size() ) ; }
217 return (*this) ( index );
218 }
Gaudi::details::rangeException
GAUDI_API void rangeException(const long index, const size_t size)
Helpful function to throw an "out-of-range exception" for class Range_.
Definition: Range.cpp:31
Gaudi::Range_::size
size_t size() const
size of the sequence (number of elements)
Definition: Range.h:157
template<class CONTAINER, class ITERATOR = typename Gaudi::details::container<CONTAINER>::Iterator>

const_reference Gaudi::Range_< CONTAINER, ITERATOR >::back | ( |  | ) | const
| inline

access for the back element (only for non-empty ranges!)

Definition at line 174 of file Range.h.

174 { return *std::prev( end() ); }
std::prev
T prev(T...args)
Gaudi::Range_::end
iterator end() const
access to end of the sequence (const version)
Definition: Range.h:162
template<class CONTAINER, class ITERATOR = typename Gaudi::details::container<CONTAINER>::Iterator>

const Base& Gaudi::Range_< CONTAINER, ITERATOR >::base | ( |  | ) | const
| inline

conversion operator to the std::pair

Definition at line 273 of file Range.h.

273 { return m_base ; }
Gaudi::Range_::m_base
Base m_base
the base itself
Definition: Range.h:278
template<class CONTAINER, class ITERATOR = typename Gaudi::details::container<CONTAINER>::Iterator>

iterator Gaudi::Range_< CONTAINER, ITERATOR >::begin | ( |  | ) | const
| inline

access to begin of the sequence (const version )

Definition at line 160 of file Range.h.

160 { return m_base.first ; }
Gaudi::Range_::m_base
Base m_base
the base itself
Definition: Range.h:278
template<class CONTAINER, class ITERATOR = typename Gaudi::details::container<CONTAINER>::Iterator>

iterator Gaudi::Range_< CONTAINER, ITERATOR >::cbegin | ( |  | ) | const
| inline

access to begin of the sequence (const version )

Definition at line 164 of file Range.h.

164 { return m_base.first ; }
Gaudi::Range_::m_base
Base m_base
the base itself
Definition: Range.h:278
template<class CONTAINER, class ITERATOR = typename Gaudi::details::container<CONTAINER>::Iterator>

iterator Gaudi::Range_< CONTAINER, ITERATOR >::cend | ( |  | ) | const
| inline

access to end of the sequence (const version)

Definition at line 166 of file Range.h.

166 { return m_base.second ; }
Gaudi::Range_::m_base
Base m_base
the base itself
Definition: Range.h:278
template<class CONTAINER, class ITERATOR = typename Gaudi::details::container<CONTAINER>::Iterator>

bool Gaudi::Range_< CONTAINER, ITERATOR >::empty | ( |  | ) | const
| inline

empty sequence ?

Definition at line 155 of file Range.h.

155 { return m_base.second == m_base.first ; }
Gaudi::Range_::m_base
Base m_base
the base itself
Definition: Range.h:278
template<class CONTAINER, class ITERATOR = typename Gaudi::details::container<CONTAINER>::Iterator>

iterator Gaudi::Range_< CONTAINER, ITERATOR >::end | ( |  | ) | const
| inline

access to end of the sequence (const version)

Definition at line 162 of file Range.h.

162 { return m_base.second ; }
Gaudi::Range_::m_base
Base m_base
the base itself
Definition: Range.h:278
template<class CONTAINER, class ITERATOR = typename Gaudi::details::container<CONTAINER>::Iterator>

const_reference Gaudi::Range_< CONTAINER, ITERATOR >::front | ( |  | ) | const
| inline

access for the first element (only for non-empty ranges!)

Definition at line 172 of file Range.h.

172 { return *begin() ; }
Gaudi::Range_::begin
iterator begin() const
access to begin of the sequence (const version )
Definition: Range.h:160
template<class CONTAINER, class ITERATOR = typename Gaudi::details::container<CONTAINER>::Iterator>

Gaudi::Range_< CONTAINER, ITERATOR >::operator bool | ( |  | ) | const
| inline explicit

non-empty sequence?

Definition at line 266 of file Range.h.

266 { return !empty () ; }
Gaudi::Range_::empty
bool empty() const
empty sequence ?
Definition: Range.h:155
template<class CONTAINER, class ITERATOR = typename Gaudi::details::container<CONTAINER>::Iterator>

Gaudi::Range_< CONTAINER, ITERATOR >::operator const Base & | ( |  | ) | const
| inline

conversion operator to the std::pair

Definition at line 271 of file Range.h.

271 { return base () ; }
Gaudi::Range_::base
const Base & base() const
conversion operator to the std::pair
Definition: Range.h:273
template<class CONTAINER, class ITERATOR = typename Gaudi::details::container<CONTAINER>::Iterator>

bool Gaudi::Range_< CONTAINER, ITERATOR >::operator! | ( |  | ) | const
| inline

empty sequence?

Definition at line 264 of file Range.h.

264 { return empty () ; }
Gaudi::Range_::empty
bool empty() const
empty sequence ?
Definition: Range.h:155
template<class CONTAINER, class ITERATOR = typename Gaudi::details::container<CONTAINER>::Iterator>

const_reference Gaudi::Range_< CONTAINER, ITERATOR >::operator() | ( | const size_t | index | ) | const
| inline

non-checked access to the elements by index (valid only for non-empty sequences)

Parameters

  index | the index of the lement to be accessed

Definition at line 200 of file Range.h.

201 { return *std::next ( begin() , index ) ; }
std::next
T next(T...args)
Gaudi::Range_::begin
iterator begin() const
access to begin of the sequence (const version )
Definition: Range.h:160
template<class CONTAINER, class ITERATOR = typename Gaudi::details::container<CONTAINER>::Iterator>
template<class C , class I >

bool Gaudi::Range_< CONTAINER, ITERATOR >::operator< | ( | const Range_< C, I > & | right | ) | const
| inline

compare with another range

Definition at line 224 of file Range.h.

225 {
226 return std::lexicographical_compare
227 ( begin () , end () , right.begin () , right.end () ) ;
228 }
std::right
T right(T...args)
std::lexicographical_compare
T lexicographical_compare(T...args)
Gaudi::Range_::end
iterator end() const
access to end of the sequence (const version)
Definition: Range.h:162
Gaudi::Range_::begin
iterator begin() const
access to begin of the sequence (const version )
Definition: Range.h:160
template<class CONTAINER, class ITERATOR = typename Gaudi::details::container<CONTAINER>::Iterator>
template<class ANOTHERCONTAINER >

bool Gaudi::Range_< CONTAINER, ITERATOR >::operator< | ( | const ANOTHERCONTAINER & | right | ) | const
| inline

compare with another container

Definition at line 231 of file Range.h.

232 {
233 return std::lexicographical_compare
234 ( begin () , end () , right.begin () , right.end () ) ;
235 }
std::right
T right(T...args)
std::lexicographical_compare
T lexicographical_compare(T...args)
Gaudi::Range_::end
iterator end() const
access to end of the sequence (const version)
Definition: Range.h:162
Gaudi::Range_::begin
iterator begin() const
access to begin of the sequence (const version )
Definition: Range.h:160
template<class CONTAINER, class ITERATOR = typename Gaudi::details::container<CONTAINER>::Iterator>

bool Gaudi::Range_< CONTAINER, ITERATOR >::operator== | ( | const Range_< CONTAINER, ITERATOR > & | right | ) | const
| inline

equality with another range

Definition at line 240 of file Range.h.

241 {
242 if ( &right == this ) { return true ; } // RETURN
243 return right.size() == size() &&
244 std::equal ( begin () , end () , right.begin() ) ;
245 }
std::right
T right(T...args)
Gaudi::Range_::end
iterator end() const
access to end of the sequence (const version)
Definition: Range.h:162
Gaudi::Range_::size
size_t size() const
size of the sequence (number of elements)
Definition: Range.h:157
std::equal
T equal(T...args)
Gaudi::Range_::begin
iterator begin() const
access to begin of the sequence (const version )
Definition: Range.h:160
template<class CONTAINER, class ITERATOR = typename Gaudi::details::container<CONTAINER>::Iterator>
template<class CNT , class IT >

bool Gaudi::Range_< CONTAINER, ITERATOR >::operator== | ( | const Range_< CNT, IT > & | right | ) | const
| inline

equality with another range type

Definition at line 248 of file Range.h.

249 {
250 return right.size() == size() &&
251 std::equal ( begin () , end () , right.begin() ) ;
252 }
std::right
T right(T...args)
Gaudi::Range_::end
iterator end() const
access to end of the sequence (const version)
Definition: Range.h:162
Gaudi::Range_::size
size_t size() const
size of the sequence (number of elements)
Definition: Range.h:157
std::equal
T equal(T...args)
Gaudi::Range_::begin
iterator begin() const
access to begin of the sequence (const version )
Definition: Range.h:160
template<class CONTAINER, class ITERATOR = typename Gaudi::details::container<CONTAINER>::Iterator>
template<class ANOTHERCONTAINER >

bool Gaudi::Range_< CONTAINER, ITERATOR >::operator== | ( | const ANOTHERCONTAINER & | right | ) | const
| inline

compare with another container

Definition at line 255 of file Range.h.

256 {
257 return right.size() == size() &&
258 std::equal ( begin () , end () , right.begin() ) ;
259 }
std::right
T right(T...args)
Gaudi::Range_::end
iterator end() const
access to end of the sequence (const version)
Definition: Range.h:162
Gaudi::Range_::size
size_t size() const
size of the sequence (number of elements)
Definition: Range.h:157
std::equal
T equal(T...args)
Gaudi::Range_::begin
iterator begin() const
access to begin of the sequence (const version )
Definition: Range.h:160
template<class CONTAINER, class ITERATOR = typename Gaudi::details::container<CONTAINER>::Iterator>

const_reference Gaudi::Range_< CONTAINER, ITERATOR >::operator[] | ( | const long | index | ) | const
| inline

non-checked access to the elements by index (valid only for non-empty sequences)

Parameters

  index | the index of the lement to be accessed

Definition at line 206 of file Range.h.

207 { return (*this)( index ) ; }
template<class CONTAINER, class ITERATOR = typename Gaudi::details::container<CONTAINER>::Iterator>

reverse_iterator Gaudi::Range_< CONTAINER, ITERATOR >::rbegin | ( |  | ) | const
| inline

access to begin of the reversed sequence (const)

Definition at line 168 of file Range.h.

168 { return reverse_iterator ( end () ) ; }
Gaudi::Range_::reverse_iterator
std::reverse_iterator< iterator > reverse_iterator
Definition: Range.h:126
Gaudi::Range_::end
iterator end() const
access to end of the sequence (const version)
Definition: Range.h:162
template<class CONTAINER, class ITERATOR = typename Gaudi::details::container<CONTAINER>::Iterator>

reverse_iterator Gaudi::Range_< CONTAINER, ITERATOR >::rend | ( |  | ) | const
| inline

access to begin of the reversed sequence (const)

Definition at line 170 of file Range.h.

170 { return reverse_iterator ( begin () ) ; }
Gaudi::Range_::reverse_iterator
std::reverse_iterator< iterator > reverse_iterator
Definition: Range.h:126
Gaudi::Range_::begin
iterator begin() const
access to begin of the sequence (const version )
Definition: Range.h:160
template<class CONTAINER, class ITERATOR = typename Gaudi::details::container<CONTAINER>::Iterator>

size_t Gaudi::Range_< CONTAINER, ITERATOR >::size | ( |  | ) | const
| inline

size of the sequence (number of elements)

Definition at line 157 of file Range.h.

158 { return std::distance ( m_base.first , m_base.second ) ; }
Gaudi::Range_::m_base
Base m_base
the base itself
Definition: Range.h:278
std::distance
T distance(T...args)
template<class CONTAINER, class ITERATOR = typename Gaudi::details::container<CONTAINER>::Iterator>

Range_ Gaudi::Range_< CONTAINER, ITERATOR >::slice | ( | long | index1,
|  | long | index2
| ) |  | const
| inline

get a "slice" of a range, in Python style

Definition at line 177 of file Range.h.

178 {
179 // trivial cases
180 if ( empty() || index1 == index2 ) { return Range_() ; } // RETURN
181 // adjust indices
182 if ( index1 < 0 ) { index1 += size () ; }
183 if ( index2 < 0 ) { index2 += size () ; }
184 // check
185 if ( index1 < 0 ) { return Range_ () ; } // RETURN
186 if ( index2 < index1 ) { return Range_ () ; } // RETURN
187
188 if ( index1 > (long) size () ) { return Range_() ; } // RETURN
189 if ( index2 > (long) size () ) { index2 = size() ; }
190
191 // construct the slice
192 return Range_( std::next ( begin() , index1 ) ,
193 std::next ( begin() , index2 ) ) ; // RETURN
194 }
Gaudi::Range_::empty
bool empty() const
empty sequence ?
Definition: Range.h:155
std::next
T next(T...args)
Gaudi::Range_::Range_
Range_()=default
internal types
Gaudi::Range_::size
size_t size() const
size of the sequence (number of elements)
Definition: Range.h:157
Gaudi::Range_::begin
iterator begin() const
access to begin of the sequence (const version )
Definition: Range.h:160

## Member Data Documentation

template<class CONTAINER, class ITERATOR = typename Gaudi::details::container<CONTAINER>::Iterator>

Base Gaudi::Range_< CONTAINER, ITERATOR >::m_base
| private

the base itself

Definition at line 278 of file Range.h.

The documentation for this class was generated from the following file:

- GaudiKernel/GaudiKernel/Range.h