| # Gaudi Framework, version v22r2 |

Home |  | Generated: Tue May 10 2011

Public Types | Public Member Functions | Private Attributes

# Gaudi::Range_< CONTAINER > 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 >:
[legend]
Collaboration diagram for Gaudi::Range_< CONTAINER >:
[legend]

List of all members.

## Public Types
typedef std::pair< typename CONTAINER::const_iterator, typename CONTAINER::const_iterator > | Base
typedef CONTAINER | Container
| type for actual contained iterator
typedef Container::value_type | value_type
typedef Container::const_iterator | iterator
typedef Container::const_iterator | const_iterator
typedef Container::const_reverse_iterator | reverse_iterator
typedef Container::const_reverse_iterator | const_reverse_iterator
typedef Container::const_reference | reference
typedef Container::const_reference | const_reference
typedef std::pair< iterator, iterator > | _Base
| internal types
typedef Range_< Container > | _Self
## Public Member Functions
| Range_ ()
| default constructor
| Range_ (iterator ibegin, iterator iend)
| Constructor.
| Range_ (const Base &base)
| constructor from the pair of iterators
| Range_ (const Container &cont)
| constructor from the container
| Range_ (iterator ibegin)
| ~Range_ ()
| destructor
bool | empty () const
| empty sequence ?
size_t | size () const
| size of the sequence (number of elements)
iterator | begin () const
| access to begin of the sequence (const version )
iterator | end () const
| access to end of the sequence (const version)
reverse_iterator | rbegin () const
| access to begin of the reversed sequence (const)
reverse_iterator | rend () const
| access to begin of the reversed sequence (const)
const_reference | front () const
| access for the first element (only for non-empty ranges!)
const_reference | back () const
| access for the back element (only for non-empty ranges!)
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)
const_reference | operator[] (const long index) const
| non-checked access to the elements by index (valid only for non-empty sequences)
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.
bool | operator< (const Range_ &right) const
| compare with another range
bool | operator< (const Container &right) const
| compare with the base container
bool | operator== (const Range_ &right) const
| equality with another range
bool | operator== (const Container &right) const
| equality with the base container
bool | operator! () const
| empty sequence?
| operator const Base & () const
| conversion operator to the std::pair
const Base & | base () const
| conversion operator to the std::pair
## Private Attributes
Base | m_base
| the base itself

## Detailed Description

### template<class CONTAINER>
class Gaudi::Range_< CONTAINER >

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.Belyaev@itep.ru

Date:
  2002-07-12

Definition at line 76 of file Range.h.

## Member Typedef Documentation

template<class CONTAINER>

typedef std::pair<iterator,iterator> Gaudi::Range_< CONTAINER >::_Base

internal types

Definition at line 95 of file Range.h.

template<class CONTAINER>

typedef Range_<Container> Gaudi::Range_< CONTAINER >::_Self

Definition at line 96 of file Range.h.

template<class CONTAINER>

typedef std::pair<typename CONTAINER::const_iterator, typename CONTAINER::const_iterator> Gaudi::Range_< CONTAINER >::Base

Reimplemented in Gaudi::NamedRange_< TYPE >.

Definition at line 81 of file Range.h.

template<class CONTAINER>

typedef Container::const_iterator Gaudi::Range_< CONTAINER >::const_iterator

Definition at line 89 of file Range.h.

template<class CONTAINER>

typedef Container::const_reference Gaudi::Range_< CONTAINER >::const_reference

Definition at line 93 of file Range.h.

template<class CONTAINER>

typedef Container::const_reverse_iterator Gaudi::Range_< CONTAINER >::const_reverse_iterator

Definition at line 91 of file Range.h.

template<class CONTAINER>

typedef CONTAINER Gaudi::Range_< CONTAINER >::Container

type for actual contained iterator

Definition at line 86 of file Range.h.

template<class CONTAINER>

typedef Container::const_iterator Gaudi::Range_< CONTAINER >::iterator

Definition at line 88 of file Range.h.

template<class CONTAINER>

typedef Container::const_reference Gaudi::Range_< CONTAINER >::reference

Definition at line 92 of file Range.h.

template<class CONTAINER>

typedef Container::const_reverse_iterator Gaudi::Range_< CONTAINER >::reverse_iterator

Definition at line 90 of file Range.h.

template<class CONTAINER>

typedef Container::value_type Gaudi::Range_< CONTAINER >::value_type

Definition at line 87 of file Range.h.

## Constructor & Destructor Documentation

template<class CONTAINER>

Gaudi::Range_< CONTAINER >::Range_ | ( | ) | `[inline]`

default constructor

Definition at line 101 of file Range.h.

    : m_base( iterator() , iterator() ) {};

template<class CONTAINER>

Gaudi::Range_< CONTAINER >::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 106 of file Range.h.

    : m_base ( ibegin , iend ) {} ;

template<class CONTAINER>

Gaudi::Range_< CONTAINER >::Range_ | ( | const Base & | base ) | `[inline]`

constructor from the pair of iterators

Parameters:

  base | pair of the iterators

Definition at line 110 of file Range.h.

    : m_base( base ) {};

template<class CONTAINER>

Gaudi::Range_< CONTAINER >::Range_ | ( | const Container & | cont ) | `[inline]`

constructor from the container

Parameters:

  cont | reference to the container

Definition at line 114 of file Range.h.

    : m_base( cont.begin() , cont.end() ) {} ;

template<class CONTAINER>

Gaudi::Range_< CONTAINER >::Range_ | ( | iterator | ibegin ) | `[inline]`

Definition at line 118 of file Range.h.

    : m_base( ibegin , ibegin ) {};

template<class CONTAINER>

Gaudi::Range_< CONTAINER >::~Range_ | ( | ) | `[inline]`

destructor

Definition at line 120 of file Range.h.

    {};

## Member Function Documentation

template<class CONTAINER>

const_reference Gaudi::Range_< CONTAINER >::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 189 of file Range.h.

        {
          if ( index < 0 || index >= (long) size () )
          { Gaudi::details::rangeException( index , size() ) ; }
          return (*this) ( index );
        }

template<class CONTAINER>

const_reference Gaudi::Range_< CONTAINER >::back | ( | void | ) | const`[inline]`

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

Definition at line 138 of file Range.h.

        {
          const_iterator i = end() ;
          std::advance ( i , -1 ) ;
          return *i ;
        }

template<class CONTAINER>

const Base& Gaudi::Range_< CONTAINER >::base | ( | ) | const`[inline]`

conversion operator to the std::pair

Definition at line 237 of file Range.h.

    { return m_base    ; }

template<class CONTAINER>

iterator Gaudi::Range_< CONTAINER >::begin | ( | void | ) | const`[inline]`

access to begin of the sequence (const version )

Definition at line 128 of file Range.h.

    { return m_base.first  ; }

template<class CONTAINER>

bool Gaudi::Range_< CONTAINER >::empty | ( | void | ) | const`[inline]`

empty sequence ?

Definition at line 123 of file Range.h.

    { return m_base.second == m_base.first  ; }

template<class CONTAINER>

iterator Gaudi::Range_< CONTAINER >::end | ( | void | ) | const`[inline]`

access to end of the sequence (const version)

Definition at line 130 of file Range.h.

    { return m_base.second ; }

template<class CONTAINER>

const_reference Gaudi::Range_< CONTAINER >::front | ( | void | ) | const`[inline]`

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

Definition at line 136 of file Range.h.

    { return *( begin ()     ) ; }

template<class CONTAINER>

Gaudi::Range_< CONTAINER >::operator const Base & | ( | ) | const`[inline]`

conversion operator to the std::pair

Definition at line 235 of file Range.h.

    { return   base () ; }

template<class CONTAINER>

bool Gaudi::Range_< CONTAINER >::operator! | ( | ) | const`[inline]`

empty sequence?

Definition at line 230 of file Range.h.

    { return  empty () ; }

template<class CONTAINER>

const_reference Gaudi::Range_< CONTAINER >::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 172 of file Range.h.

        {
          const_iterator i = begin() ;
          std::advance ( i , index ) ;
          return *i ;
        }

template<class CONTAINER>

bool Gaudi::Range_< CONTAINER >::operator< | ( | const Range_< CONTAINER > & | right ) | const`[inline]`

compare with another range

Definition at line 199 of file Range.h.

        {
          return std::lexicographical_compare
            ( begin () , end () , right.begin () , right.end () ) ;
        }

template<class CONTAINER>

bool Gaudi::Range_< CONTAINER >::operator< | ( | const Container & | right ) | const`[inline]`

compare with the base container

Definition at line 205 of file Range.h.

        {
          return std::lexicographical_compare
            ( begin () , end () , right.begin () , right.end () ) ;
        }

template<class CONTAINER>

bool Gaudi::Range_< CONTAINER >::operator== | ( | const Range_< CONTAINER > & | right ) | const`[inline]`

equality with another range

Definition at line 214 of file Range.h.

        {
          if ( &right        == this    ) { return true  ; } // RETURN
          if ( right.size () != size () ) { return false ; } // RETURN
          return std::equal ( begin () , end () , right.begin() ) ;
        }

template<class CONTAINER>

bool Gaudi::Range_< CONTAINER >::operator== | ( | const Container & | right ) | const`[inline]`

equality with the base container

Definition at line 221 of file Range.h.

        {
          if ( right.size () != size () ) { return false ; } // RETURN
          return std::equal ( begin () , end () , right.begin() ) ;
        }

template<class CONTAINER>

const_reference Gaudi::Range_< CONTAINER >::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 182 of file Range.h.

        { return (*this)( index ) ; }

template<class CONTAINER>

reverse_iterator Gaudi::Range_< CONTAINER >::rbegin | ( | void | ) | const`[inline]`

access to begin of the reversed sequence (const)

Definition at line 132 of file Range.h.

    { return reverse_iterator ( end   () ) ; }

template<class CONTAINER>

reverse_iterator Gaudi::Range_< CONTAINER >::rend | ( | void | ) | const`[inline]`

access to begin of the reversed sequence (const)

Definition at line 134 of file Range.h.

    { return reverse_iterator ( begin () ) ; }

template<class CONTAINER>

size_t Gaudi::Range_< CONTAINER >::size | ( | void | ) | const`[inline]`

size of the sequence (number of elements)

Definition at line 125 of file Range.h.

        { return std::distance ( m_base.first  , m_base.second  ) ; }

template<class CONTAINER>

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

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

Reimplemented in Gaudi::NamedRange_< TYPE >.

Definition at line 146 of file Range.h.

        {
          // trivial cases
          if ( empty() || index1 == index2 ) { return Range_() ; } // RETURN
          // adjust indices
          if ( index1 < 0      ) { index1 += size () ; }
          if ( index2 < 0      ) { index2 += size () ; }
          // check
          if ( index1 < 0      ) { return  Range_ () ; }            // RETURN
          if ( index2 < index1 ) { return  Range_ () ; }            // RETURN

          if ( index1 > (long) size () ) { return  Range_() ; }     // RETURN
          if ( index2 > (long) size () ) { index2  = size() ; }

          const_iterator i1 = begin()  ;
          std::advance ( i1 , index1 ) ;
          const_iterator i2 = begin()  ;
          std::advance ( i2 , index2 ) ;
          // construct the slice
          return Range_( i1 , i2 ) ;                                 // RETURN
        }

## Member Data Documentation

template<class CONTAINER>

Base Gaudi::Range_< CONTAINER >::m_base`[private]`

the base itself

Definition at line 242 of file Range.h.

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

- /afs/.cern.ch/sw/Gaudi/releases/GAUDI/GAUDI_v22r2/GaudiKernel/GaudiKernel/Range.h

All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines