Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

cafe::Collection< T > Class Template Reference

Wrap a TObjArray or TClonesArray in a 'STL like' container class. More...

#include <Collection.hpp>

List of all members.

Public Types

typedef T value_type
typedef size_t size_type
typedef T * pointer_type
typedef T & reference_type
typedef const T * const_pointer_type
typedef const T & const_reference_type

Public Member Functions

 Collection (TObjArray *data)
 Pass in array.

 Collection (const Collection< T > &other)
 Copy constructor.

 Collection (void)
 Default constructor.

virtual ~Collection ()
 Delete the collection if there are no more elemements in it.

Collection< T > & operator= (const Collection< T > &other)
 Assign other collection to this one.

void push_back (const T &item)
 Add an item to the array.

void push_back (T *item)
 Add an item to the array.

const T & operator[] (size_t index) const
 Easy [] access.

size_t size () const
 Return size of collection.

template<typename compare> void sort (iterator from, iterator to, compare CompFun)
 Sort a cafe::Collection<T>.

 ClassDef (Collection, 0)
Iterator access
iterator begin ()
 Iterators to first element in collection.

const_iterator begin () const
iterator end ()
 Iterator to one past the last element in collection.

const_iterator end () const
iterator erase (iterator it)
 Erase entry at iterator position. Return 'next' position.

iterator erase (iterator first, iterator last)
 Erase entries between iterator positions first and last.


Private Member Functions

void make_us_owner_of_data (void)
 If we don't own the data array, make a copy and assume ownership.

template<typename compare> void insert_sort (TObjArray &array, int const from, int const to, compare CompFun)
template<typename compare> void partial_quicksort (TObjArray &array, int indLow, int indHigh, compare CompFun)
template<typename compare> void full_sort (TObjArray &array, int const from, int const to, compare CompFun)
void swap (TObjArray &array, int i, int j)

Private Attributes

array_holder_data
 Holds pointer to the TObjArray and a reference count.


Detailed Description

template<class T>
class cafe::Collection< T >

Wrap a TObjArray or TClonesArray in a 'STL like' container class.

By default the Collection<T> does not own the TObjArray that is passed to it and will not delete it.

The exception is an empty collection or an assignment to it. In this case it implements copy-on-write semantics.

The TObjArray is deleted using a "delete" statement, so unless you set the kOwned bit, it shouldn't delete its contents.

Definition at line 23 of file Collection.hpp.


Member Typedef Documentation

template<class T>
typedef const T* cafe::Collection< T >::const_pointer_type
 

Definition at line 29 of file Collection.hpp.

Referenced by cafe::Collection< T >::const_iterator::operator->().

template<class T>
typedef const T& cafe::Collection< T >::const_reference_type
 

Definition at line 30 of file Collection.hpp.

Referenced by cafe::Collection< T >::const_iterator::operator *().

template<class T>
typedef T* cafe::Collection< T >::pointer_type
 

Definition at line 27 of file Collection.hpp.

Referenced by cafe::Collection< T >::iterator::operator->().

template<class T>
typedef T& cafe::Collection< T >::reference_type
 

Definition at line 28 of file Collection.hpp.

Referenced by cafe::Collection< T >::iterator::operator *().

template<class T>
typedef size_t cafe::Collection< T >::size_type
 

Definition at line 26 of file Collection.hpp.

template<class T>
typedef T cafe::Collection< T >::value_type
 

Definition at line 25 of file Collection.hpp.


Constructor & Destructor Documentation

template<class T>
cafe::Collection< T >::Collection TObjArray *  data  )  [inline]
 

Pass in array.

The TObjArray will not be deleted when Collection goes out of scope.

Definition at line 34 of file Collection.hpp.

template<class T>
cafe::Collection< T >::Collection const Collection< T > &  other  )  [inline]
 

Copy constructor.

TObjArray won't be deleted unless it is owned and the last one.

Definition at line 45 of file Collection.hpp.

template<class T>
cafe::Collection< T >::Collection void   )  [inline]
 

Default constructor.

New tobj array. Will be deleted when it does out of scope.

Definition at line 52 of file Collection.hpp.

template<class T>
virtual cafe::Collection< T >::~Collection  )  [inline, virtual]
 

Delete the collection if there are no more elemements in it.

Definition at line 57 of file Collection.hpp.


Member Function Documentation

template<class T>
const_iterator cafe::Collection< T >::begin  )  const [inline]
 

Definition at line 100 of file Collection.hpp.

template<class T>
iterator cafe::Collection< T >::begin  )  [inline]
 

Iterators to first element in collection.

Definition at line 99 of file Collection.hpp.

Referenced by caf_util::EMJetMatching::after(), caf_util::ApplyJES::after(), caf_util::VertexSelector::before(), caf_util::MuonSelector::before(), caf_util::JetSelector::before(), caf_util::ElectronSelector::before(), caf_util::TreeHandler::FillBranch(), caf_util::TRefFinder::FindTrack(), caf_util::TRefFinder::FindVertex(), cafe::Trigger::processEvent(), caf_util::TopologicalSelector::processEvent(), cafe::SelectUserObjects< T >::processEvent(), caf_util::ReComputeMET::processEvent(), and caf_util::VertexSelector::selectObject().

template<class T>
cafe::Collection< T >::ClassDef Collection< T >  ,
 

template<class T>
const_iterator cafe::Collection< T >::end  )  const [inline]
 

Definition at line 104 of file Collection.hpp.

template<class T>
iterator cafe::Collection< T >::end  )  [inline]
 

Iterator to one past the last element in collection.

Definition at line 103 of file Collection.hpp.

Referenced by caf_util::EMJetMatching::after(), caf_util::ApplyJES::after(), caf_util::VertexSelector::before(), caf_util::MuonSelector::before(), caf_util::JetSelector::before(), caf_util::ElectronSelector::before(), caf_util::TreeHandler::FillBranch(), caf_util::TRefFinder::FindTrack(), caf_util::TRefFinder::FindVertex(), cafe::Trigger::processEvent(), caf_util::TopologicalSelector::processEvent(), cafe::SelectUserObjects< T >::processEvent(), caf_util::ReComputeMET::processEvent(), and caf_util::VertexSelector::selectObject().

template<class T>
iterator cafe::Collection< T >::erase iterator  first,
iterator  last
[inline]
 

Erase entries between iterator positions first and last.

Definition at line 117 of file Collection.hpp.

template<class T>
iterator cafe::Collection< T >::erase iterator  it  )  [inline]
 

Erase entry at iterator position. Return 'next' position.

Definition at line 107 of file Collection.hpp.

template<class T>
template<typename compare>
void cafe::Collection< T >::full_sort TObjArray &  array,
int const   from,
int const   to,
compare  CompFun
[inline, private]
 

Definition at line 377 of file Collection.hpp.

Referenced by cafe::Collection< TMBJet >::sort().

template<class T>
template<typename compare>
void cafe::Collection< T >::insert_sort TObjArray &  array,
int const   from,
int const   to,
compare  CompFun
[inline, private]
 

Definition at line 310 of file Collection.hpp.

Referenced by cafe::Collection< TMBJet >::full_sort().

template<class T>
void cafe::Collection< T >::make_us_owner_of_data void   )  [inline, private]
 

If we don't own the data array, make a copy and assume ownership.

This is so we can add to a static item.

Definition at line 296 of file Collection.hpp.

Referenced by cafe::Collection< TMBJet >::erase(), cafe::Collection< TMBJet >::push_back(), and cafe::Collection< TMBJet >::sort().

template<class T>
Collection<T>& cafe::Collection< T >::operator= const Collection< T > &  other  )  [inline]
 

Assign other collection to this one.

Definition at line 62 of file Collection.hpp.

template<class T>
const T& cafe::Collection< T >::operator[] size_t  index  )  const [inline]
 

Easy [] access.

Definition at line 91 of file Collection.hpp.

template<class T>
template<typename compare>
void cafe::Collection< T >::partial_quicksort TObjArray &  array,
int  indLow,
int  indHigh,
compare  CompFun
[inline, private]
 

Definition at line 331 of file Collection.hpp.

Referenced by cafe::Collection< TMBJet >::full_sort(), and cafe::Collection< TMBJet >::partial_quicksort().

template<class T>
void cafe::Collection< T >::push_back T *  item  )  [inline]
 

Add an item to the array.

The collection will delete this item when it is done.

Definition at line 84 of file Collection.hpp.

template<class T>
void cafe::Collection< T >::push_back const T &  item  )  [inline]
 

Add an item to the array.

This item must be have been dynamically allocated and not on the stack. The Collection does not take ownership of the item.

Definition at line 75 of file Collection.hpp.

template<class T>
size_t cafe::Collection< T >::size  )  const [inline]
 

Return size of collection.

Definition at line 132 of file Collection.hpp.

Referenced by caf_util::ApplyJES::after(), caf_util::TopologicalSelector::processEvent(), caf_util::JetSelector::processEvent(), and caf_util::VertexSelector::selectObject().

template<class T>
template<typename compare>
void cafe::Collection< T >::sort iterator  from,
iterator  to,
compare  CompFun
[inline]
 

Sort a cafe::Collection<T>.

The predicate CompFun should be a function or a class that provides a boolean result. This predicate should be callable like

bool lessThan(T const& a, T const& b);

and should return true if a belongs before b in the sorted collection.

Definition at line 145 of file Collection.hpp.

Referenced by caf_util::VertexSelector::before(), caf_util::MuonSelector::before(), caf_util::JetSelector::before(), and caf_util::ElectronSelector::before().

template<class T>
void cafe::Collection< T >::swap TObjArray &  array,
int  i,
int  j
[inline, private]
 

Definition at line 388 of file Collection.hpp.

Referenced by cafe::Collection< TMBJet >::partial_quicksort().


Member Data Documentation

template<class T>
array_holder* cafe::Collection< T >::_data [private]
 

Holds pointer to the TObjArray and a reference count.

Prevent root from trying to save it for now.

Definition at line 292 of file Collection.hpp.

Referenced by cafe::Collection< TMBJet >::begin(), cafe::Collection< TMBJet >::Collection(), cafe::Collection< TMBJet >::end(), cafe::Collection< TMBJet >::erase(), cafe::Collection< TMBJet >::make_us_owner_of_data(), cafe::Collection< TMBJet >::operator=(), cafe::Collection< TMBJet >::size(), cafe::Collection< TMBJet >::sort(), and cafe::Collection< TMBJet >::~Collection().


The documentation for this class was generated from the following file:
Generated on Tue Mar 28 10:13:10 2006 for CAF by doxygen 1.3.4