Logo ROOT   6.14/05
Reference Guide
TEntryListBlock.h
Go to the documentation of this file.
1 // @(#)root/tree:$Id$
2 // Author: Anna Kreshuk 27/10/2006
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2006, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 //////////////////////////////////////////////////////////////////////////
13 // TEntryListBlock
14 //
15 // Used internally in TEntryList to store the entry numbers.
16 //
17 // There are 2 ways to represent entry numbers in a TEntryListBlock:
18 // 1) as bits, where passing entry numbers are assigned 1, not passing - 0
19 // 2) as a simple array of entry numbers
20 // In both cases, a UShort_t* is used. The second option is better in case
21 // less than 1/16 of entries passes the selection, and the representation can be
22 // changed by calling OptimizeStorage() function.
23 // When the block is being filled, it's always stored as bits, and the OptimizeStorage()
24 // function is called by TEntryList when it starts filling the next block. If
25 // Enter() or Remove() is called after OptimizeStorage(), representation is
26 // again changed to 1).
27 //
28 // Operations on blocks (see also function comments):
29 // - Merge() - adds all entries from one block to the other. If the first block
30 // uses array representation, it's changed to bits representation only
31 // if the total number of passing entries is still less than kBlockSize
32 // - GetEntry(n) - returns n-th non-zero entry.
33 // - Next() - return next non-zero entry. In case of representation 1), Next()
34 // is faster than GetEntry()
35 //
36 //////////////////////////////////////////////////////////////////////////
37 
38 #ifndef ROOT_TEntryListBlock
39 #define ROOT_TEntryListBlock
40 
41 #include "TObject.h"
42 
44 {
45  protected:
46  Int_t fNPassed; ///< number of entries in the entry list (if fPassing=0 - number of entries
47  ///< not in the entry list
48  Int_t fN; ///< size of fIndices for I/O =fNPassed for list, fBlockSize for bits
49  UShort_t *fIndices; ///<[fN]
50  Int_t fType; ///<0 - bits, 1 - list
51  Bool_t fPassing; ///<1 - stores entries that belong to the list
52  ///<0 - stores entries that don't belong to the list
53  UShort_t fCurrent; ///<! to fasten Contains() in list mode
54  Int_t fLastIndexQueried; ///<! to optimize GetEntry() in a loop
55  Int_t fLastIndexReturned; ///<! to optimize GetEntry() in a loop
56 
57  void Transform(Bool_t dir, UShort_t *indexnew);
58 
59  public:
60 
61  enum { kBlockSize = 4000 }; //size of the block, 4000 UShort_ts
63  TEntryListBlock(const TEntryListBlock &eblock);
66 
67  Bool_t Enter(Int_t entry);
68  Bool_t Remove(Int_t entry);
69  Int_t Contains(Int_t entry);
70  void OptimizeStorage();
71  Int_t Merge(TEntryListBlock *block);
72  Int_t Next();
73  Int_t GetEntry(Int_t entry);
74  void ResetIndices() {fLastIndexQueried = -1, fLastIndexReturned = -1;}
75  Int_t GetType() { return fType; }
76  Int_t GetNPassed();
77  virtual void Print(const Option_t *option = "") const;
78  void PrintWithShift(Int_t shift) const;
79 
80  ClassDef(TEntryListBlock, 1) //Used internally in TEntryList to store the entry numbers
81 
82 };
83 
84 #endif
Int_t fLastIndexQueried
! to optimize GetEntry() in a loop
const char Option_t
Definition: RtypesCore.h:62
void OptimizeStorage()
If there are < kBlockSize or >kBlockSize*15 entries, change to an array representation.
unsigned short UShort_t
Definition: RtypesCore.h:36
Int_t fLastIndexReturned
! to optimize GetEntry() in a loop
Int_t Merge(TEntryListBlock *block)
Merge with the other block Returns the resulting number of entries in the block.
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
Int_t fType
0 - bits, 1 - list
Bool_t Enter(Int_t entry)
If the block has already been optimized and the entries are stored as a list and not as bits...
#define ClassDef(name, id)
Definition: Rtypes.h:320
Int_t GetEntry(Int_t entry)
Return entry #entry.
void PrintWithShift(Int_t shift) const
Print the indices of this block + shift (used from TEntryList::Print()) to print the current values...
UShort_t * fIndices
[fN]
TEntryListBlock()
Default c-tor.
Bool_t fPassing
1 - stores entries that belong to the list 0 - stores entries that don&#39;t belong to the list ...
~TEntryListBlock()
Destructor.
Int_t Contains(Int_t entry)
True if the block contains entry #entry.
Int_t GetNPassed()
Returns the number of entries, passing the selection.
Int_t Next()
Return the next non-zero entry Faster than GetEntry() function.
Int_t fNPassed
number of entries in the entry list (if fPassing=0 - number of entries not in the entry list ...
virtual void Print(const Option_t *option="") const
Print the entries in this block.
UShort_t fCurrent
! to fasten Contains() in list mode
Mother of all ROOT objects.
Definition: TObject.h:37
Bool_t Remove(Int_t entry)
Remove entry #entry If the block has already been optimized and the entries are stored as a list and ...
void Transform(Bool_t dir, UShort_t *indexnew)
Transform the existing fIndices.
Used by TEntryList to store the entry numbers.
Int_t fN
size of fIndices for I/O =fNPassed for list, fBlockSize for bits
TEntryListBlock & operator=(const TEntryListBlock &rhs)