ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 #ifndef ROOT_TObject
42 #include "TObject.h"
43 #endif
44 
46 {
47  protected:
48  Int_t fNPassed; //number of entries in the entry list (if fPassing=0 - number of entries
49  //not in the entry list
50  Int_t fN; //size of fIndices for I/O =fNPassed for list, fBlockSize for bits
51  UShort_t *fIndices; //[fN]
52  Int_t fType; //0 - bits, 1 - list
53  Bool_t fPassing; //1 - stores entries that belong to the list
54  //0 - stores entries that don't belong to the list
55  UShort_t fCurrent; //! to fasten Contains() in list mode
56  Int_t fLastIndexQueried; //! to optimize GetEntry() in a loop
57  Int_t fLastIndexReturned; //! to optimize GetEntry() in a loop
58 
59  void Transform(Bool_t dir, UShort_t *indexnew);
60 
61  public:
62 
63  enum { kBlockSize = 4000 }; //size of the block, 4000 UShort_ts
65  TEntryListBlock(const TEntryListBlock &eblock);
68 
72  void OptimizeStorage();
73  Int_t Merge(TEntryListBlock *block);
74  Int_t Next();
77  Int_t GetType() { return fType; }
78  Int_t GetNPassed();
79  virtual void Print(const Option_t *option = "") const;
80  void PrintWithShift(Int_t shift) const;
81 
82  ClassDef(TEntryListBlock, 1) //Used internally in TEntryList to store the entry numbers
83 
84 };
85 
86 #endif
Int_t fLastIndexQueried
to fasten Contains() in list mode
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
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:254
Int_t GetEntry(Int_t entry)
Return entry entry.
UShort_t * fIndices
void PrintWithShift(Int_t shift) const
Print the indices of this block + shift (used from TEntryList::Print()) to print the corrent values...
~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.
Long64_t entry
Int_t Next()
Return the next non-zero entry Faster than GetEntry() function.
void dir(char *path=0)
Definition: rootalias.C:30
virtual void Print(const Option_t *option="") const
Print the entries in this block.
Mother of all ROOT objects.
Definition: TObject.h:58
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 n...
void Transform(Bool_t dir, UShort_t *indexnew)
to optimize GetEntry() in a loop
Used by TEntryList to store the entry numbers.
TEntryListBlock & operator=(const TEntryListBlock &rhs)