Gaudi Framework, version v23r9

Home   Generated: Thu Jul 18 2013
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Types | Public Member Functions | Private Attributes | List of all members
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 >:
Inheritance graph
[legend]
Collaboration diagram for Gaudi::Range_< CONTAINER >:
Collaboration graph
[legend]

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
GaudiExceptionfor 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 Basebase () 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:

Author
Vanya Belyaev Ivan..nosp@m.Bely.nosp@m.aev@i.nosp@m.tep..nosp@m.ru
Date
2002-07-12

Definition at line 77 of file Range.h.

Member Typedef Documentation

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

internal types

Definition at line 96 of file Range.h.

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

Definition at line 97 of file Range.h.

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

Definition at line 82 of file Range.h.

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

Definition at line 90 of file Range.h.

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

Definition at line 94 of file Range.h.

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

Definition at line 92 of file Range.h.

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

type for actual contained iterator

Definition at line 87 of file Range.h.

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

Definition at line 89 of file Range.h.

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

Definition at line 93 of file Range.h.

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

Definition at line 91 of file Range.h.

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

Definition at line 88 of file Range.h.

Constructor & Destructor Documentation

template<class CONTAINER>
Gaudi::Range_< CONTAINER >::Range_ ( )
inline

default constructor

Definition at line 102 of file Range.h.

: m_base( iterator() , iterator() ) {}
template<class CONTAINER>
Gaudi::Range_< CONTAINER >::Range_ ( iterator  ibegin,
iterator  iend 
)
inline

Constructor.

Parameters
ibeginiterator to begin of the sequence
ienditerator to end of the sequence

Definition at line 107 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
basepair of the iterators

Definition at line 111 of file Range.h.

: m_base( base ) {}
template<class CONTAINER>
Gaudi::Range_< CONTAINER >::Range_ ( const Container cont)
inline

constructor from the container

Parameters
contreference to the container

Definition at line 115 of file Range.h.

: m_base( cont.begin() , cont.end() ) {}
template<class CONTAINER>
Gaudi::Range_< CONTAINER >::Range_ ( iterator  ibegin)
inline

Definition at line 119 of file Range.h.

: m_base( ibegin , ibegin ) {}
template<class CONTAINER>
Gaudi::Range_< CONTAINER >::~Range_ ( )
inline

destructor

Definition at line 121 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
GaudiExceptionfor out-of-range access.

Parameters
indexthe index of the element to be accessed

Definition at line 190 of file Range.h.

{
if ( index < 0 || index >= (long) size () )
return (*this) ( index );
}
template<class CONTAINER>
const_reference Gaudi::Range_< CONTAINER >::back ( ) const
inline

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

Definition at line 139 of file Range.h.

{
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 238 of file Range.h.

{ return m_base ; }
template<class CONTAINER>
iterator Gaudi::Range_< CONTAINER >::begin ( ) const
inline

access to begin of the sequence (const version )

Definition at line 129 of file Range.h.

{ return m_base.first ; }
template<class CONTAINER>
bool Gaudi::Range_< CONTAINER >::empty ( ) const
inline

empty sequence ?

Definition at line 124 of file Range.h.

{ return m_base.second == m_base.first ; }
template<class CONTAINER>
iterator Gaudi::Range_< CONTAINER >::end ( ) const
inline

access to end of the sequence (const version)

Definition at line 131 of file Range.h.

{ return m_base.second ; }
template<class CONTAINER>
const_reference Gaudi::Range_< CONTAINER >::front ( ) const
inline

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

Definition at line 137 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 236 of file Range.h.

{ return base () ; }
template<class CONTAINER>
bool Gaudi::Range_< CONTAINER >::operator! ( ) const
inline

empty sequence?

Definition at line 231 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
indexthe index of the lement to be accessed

Definition at line 173 of file Range.h.

{
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 200 of file Range.h.

{
( 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 206 of file Range.h.

{
( 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 215 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 222 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
indexthe index of the lement to be accessed

Definition at line 183 of file Range.h.

{ return (*this)( index ) ; }
template<class CONTAINER>
reverse_iterator Gaudi::Range_< CONTAINER >::rbegin ( ) const
inline

access to begin of the reversed sequence (const)

Definition at line 133 of file Range.h.

{ return reverse_iterator ( end () ) ; }
template<class CONTAINER>
reverse_iterator Gaudi::Range_< CONTAINER >::rend ( ) const
inline

access to begin of the reversed sequence (const)

Definition at line 135 of file Range.h.

{ return reverse_iterator ( begin () ) ; }
template<class CONTAINER>
size_t Gaudi::Range_< CONTAINER >::size ( ) const
inline

size of the sequence (number of elements)

Definition at line 126 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

Definition at line 147 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() ; }
std::advance ( i1 , index1 ) ;
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 243 of file Range.h.


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

Generated at Thu Jul 18 2013 12:18:13 for Gaudi Framework, version v23r9 by Doxygen version 1.8.2 written by Dimitri van Heesch, © 1997-2004