#include <Collection.hpp>
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 25 of file Collection.hpp.
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 |
| typedef iterator | cafe_collection_iterator |
| Remove ambiguity with the two iterators below. | |
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. | |
|
|||||
|
Remove ambiguity with the two iterators below. I'm not sure what the C++ standard has to say here -- need to investigate which compiler is doing the right thing. But it certianly is confusing anyway. ;-) Definition at line 205 of file Collection.hpp. Referenced by cafe::Collection< T >::const_iterator::const_iterator(). |
|
|||||
|
Definition at line 31 of file Collection.hpp. Referenced by cafe::Collection< T >::const_iterator::operator->(). |
|
|||||
|
Definition at line 32 of file Collection.hpp. Referenced by cafe::Collection< T >::const_iterator::operator *(). |
|
|||||
|
Definition at line 29 of file Collection.hpp. Referenced by cafe::Collection< T >::iterator::operator->(). |
|
|||||
|
Definition at line 30 of file Collection.hpp. Referenced by cafe::Collection< T >::iterator::operator *(). |
|
|||||
|
Definition at line 28 of file Collection.hpp. |
|
|||||
|
Definition at line 27 of file Collection.hpp. |
|
||||||||||
|
Pass in array. The TObjArray will not be deleted when Collection goes out of scope. Definition at line 36 of file Collection.hpp. References cafe::Collection< T >::_data. |
|
||||||||||
|
Copy constructor. TObjArray won't be deleted unless it is owned and the last one. Definition at line 47 of file Collection.hpp. References cafe::Collection< T >::_data, and cafe::Collection< T >::array_holder::inc(). |
|
||||||||||
|
Default constructor. New tobj array. Will be deleted when it does out of scope. Definition at line 54 of file Collection.hpp. References cafe::Collection< T >::_data. |
|
|||||||||
|
Delete the collection if there are no more elemements in it.
Definition at line 59 of file Collection.hpp. References cafe::Collection< T >::_data, and cafe::Collection< T >::array_holder::decAndDeleteIf(). |
|
|||||||||
|
Definition at line 102 of file Collection.hpp. References cafe::Collection< T >::_data. |
|
|||||||||
|
Iterators to first element in collection.
Definition at line 101 of file Collection.hpp. References cafe::Collection< T >::_data. Referenced by cafe::Event::isMC(), cafe::Event::isRun2b(), cafe::Trigger::processEvent(), cafe::SelectUserObjects< T >::processEvent(), cafe::RandomSelectUserObjects< T >::processEvent(), and cafe::AssociatedTracks::processEvent(). |
|
||||||||||||||||
|
|
|
|||||||||
|
Definition at line 106 of file Collection.hpp. References cafe::Collection< T >::_data. |
|
|||||||||
|
Iterator to one past the last element in collection.
Definition at line 105 of file Collection.hpp. References cafe::Collection< T >::_data. Referenced by cafe::Event::isMC(), cafe::Event::isRun2b(), cafe::Trigger::processEvent(), cafe::SelectUserObjects< T >::processEvent(), cafe::RandomSelectUserObjects< T >::processEvent(), and cafe::AssociatedTracks::processEvent(). |
|
||||||||||||||||
|
Erase entries between iterator positions first and last.
Definition at line 119 of file Collection.hpp. References cafe::Collection< T >::_data, cafe::Collection< T >::iterator::_index, and cafe::Collection< T >::make_us_owner_of_data(). |
|
||||||||||
|
Erase entry at iterator position. Return 'next' position.
Definition at line 109 of file Collection.hpp. References cafe::Collection< T >::_data, cafe::Collection< T >::iterator::_index, and cafe::Collection< T >::make_us_owner_of_data(). |
|
||||||||||||||||||||||||||||
|
Definition at line 383 of file Collection.hpp. References cafe::Collection< T >::insert_sort(), and cafe::Collection< T >::partial_quicksort(). Referenced by cafe::Collection< T >::sort(). |
|
||||||||||||||||||||||||||||
|
Definition at line 316 of file Collection.hpp. Referenced by cafe::Collection< T >::full_sort(). |
|
||||||||||
|
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 302 of file Collection.hpp. References cafe::Collection< T >::_data, cafe::Collection< T >::array_holder::decAndDeleteIf(), and cafe::Collection< T >::array_holder::isOwned(). Referenced by cafe::Collection< T >::erase(), cafe::Collection< T >::push_back(), and cafe::Collection< T >::sort(). |
|
||||||||||
|
Assign other collection to this one.
Definition at line 64 of file Collection.hpp. References cafe::Collection< T >::_data, cafe::Collection< T >::array_holder::decAndDeleteIf(), and cafe::Collection< T >::array_holder::inc(). |
|
||||||||||
|
Easy [] access.
Definition at line 93 of file Collection.hpp. |
|
||||||||||||||||||||||||||||
|
Definition at line 337 of file Collection.hpp. References cafe::Collection< T >::swap(). Referenced by cafe::Collection< T >::full_sort(). |
|
||||||||||
|
Add an item to the array. The collection will delete this item when it is done. Definition at line 86 of file Collection.hpp. References cafe::Collection< T >::make_us_owner_of_data(). |
|
||||||||||
|
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 77 of file Collection.hpp. References cafe::Collection< T >::make_us_owner_of_data(). Referenced by cafe::StatSample::ListEventWeights(). |
|
|||||||||
|
Return size of collection.
Definition at line 134 of file Collection.hpp. References cafe::Collection< T >::_data. Referenced by cafe::Event::getTMBLeBob(), cafe::Trigger::processEvent(), and cafe::AssociatedTracks::processEvent(). |
|
||||||||||||||||||||||||
|
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 147 of file Collection.hpp. References cafe::Collection< T >::_data, cafe::Collection< T >::iterator::_index, cafe::Collection< T >::full_sort(), and cafe::Collection< T >::make_us_owner_of_data(). |
|
||||||||||||||||||||
|
Definition at line 394 of file Collection.hpp. Referenced by cafe::Collection< T >::partial_quicksort(). |
|
|||||
|
Holds pointer to the TObjArray and a reference count. Prevent root from trying to save it for now. Definition at line 298 of file Collection.hpp. Referenced by cafe::Collection< T >::begin(), cafe::Collection< T >::Collection(), cafe::Collection< T >::end(), cafe::Collection< T >::erase(), cafe::Collection< T >::make_us_owner_of_data(), cafe::Collection< T >::operator=(), cafe::Collection< T >::size(), cafe::Collection< T >::sort(), and cafe::Collection< T >::~Collection(). |
1.3.4