ROOT  6.07/01
Reference Guide
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TBtree.h
Go to the documentation of this file.
1 // @(#)root/cont:$Id$
2 // Author: Fons Rademakers 10/10/95
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, 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 #ifndef ROOT_TBtree
13 #define ROOT_TBtree
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TBtree //
19 // //
20 // Btree class. TBtree inherits from the TSeqCollection ABC. //
21 // //
22 // For a more extensive algorithmic description see the TBtree source. //
23 // //
24 //////////////////////////////////////////////////////////////////////////
25 
26 #ifndef ROOT_TSeqCollection
27 #include "TSeqCollection.h"
28 #endif
29 #ifndef ROOT_TError
30 #include "TError.h"
31 #endif
32 
33 #include <iterator>
34 
35 
36 class TBtNode;
37 class TBtInnerNode;
38 class TBtLeafNode;
39 class TBtreeIter;
40 
41 
42 class TBtree : public TSeqCollection {
43 
44 friend class TBtNode;
45 friend class TBtInnerNode;
46 friend class TBtLeafNode;
47 
48 private:
49  TBtNode *fRoot; //root node of btree
50 
51  Int_t fOrder; //the order of the tree (should be > 2)
52  Int_t fOrder2; //order*2+1 (assumes a memory access is
53  //cheaper than a multiply and increment by one
54  Int_t fInnerLowWaterMark; //inner node low water mark
55  Int_t fLeafLowWaterMark; //leaf low water mark
56  Int_t fInnerMaxIndex; //maximum inner node index
57  Int_t fLeafMaxIndex; //maximum leaf index
58 
59  void Init(Int_t i); //initialize btree
60  void RootIsFull(); //called when the root node is full
61  void RootIsEmpty(); //called when root is empty
62 
63 protected:
64  void IncrNofKeys() { fSize++; }
65  void DecrNofKeys() { fSize--; }
66 
67  // add the object to the tree; return the index in the tree at which
68  // the object was inserted. NOTE: other insertions and deletions may
69  // change this object's index.
70  Int_t IdxAdd(const TObject &obj);
71 
72 public:
74 
75  TBtree(Int_t ordern = 3); //create a TBtree of order n
76  virtual ~TBtree();
77  void Clear(Option_t *option="");
78  void Delete(Option_t *option="");
79  TObject *FindObject(const char *name) const;
80  TObject *FindObject(const TObject *obj) const;
81  TObject **GetObjectRef(const TObject *) const { return 0; }
83 
84  void Add(TObject *obj);
85  void AddFirst(TObject *obj) { Add(obj); }
86  void AddLast(TObject *obj) { Add(obj); }
87  void AddAt(TObject *obj, Int_t) { Add(obj); }
88  void AddAfter(const TObject *, TObject *obj) { Add(obj); }
89  void AddBefore(const TObject *, TObject *obj) { Add(obj); }
91 
92  TObject *At(Int_t idx) const;
93  TObject *Before(const TObject *obj) const;
94  TObject *After(const TObject *obj) const;
95  TObject *First() const;
96  TObject *Last() const;
97 
98  //void PrintOn(std::ostream &os) const;
99 
100  Int_t Order() { return fOrder; }
101  TObject *operator[](Int_t i) const;
102  Int_t Rank(const TObject *obj) const;
103 
104  ClassDef(TBtree,0) //A B-tree
105 };
106 
107 
108 //////////////////////////////////////////////////////////////////////////
109 // //
110 // TBtNode //
111 // //
112 // Abstract base class (ABC) of a TBtree node. //
113 // //
114 //////////////////////////////////////////////////////////////////////////
115 
116 class TBtNode {
117 
118 friend class TBtree;
119 friend class TBtInnerNode;
120 friend class TBtLeafNode;
121 
122 protected:
123  Int_t fLast; // for inner node 1 <= fLast <= fInnerMaxIndex
124  // for leaf node 1 <= fLast <= fLeafMaxIndex
125  // (fLast==0 only temporarily while the tree is being
126  // updated)
127 
128  TBtInnerNode *fParent; // a parent is always an inner node (or 0 for the root)
129  TBtree *fTree; // the tree of which this node is a part
130  Int_t fIsLeaf; // run-time type flag
131 
132 public:
133  TBtNode(Int_t isleaf, TBtInnerNode *p, TBtree *t = 0);
134  virtual ~TBtNode();
135 
136  virtual void Add(const TObject *obj, Int_t index) = 0;
137 #ifndef __CINT__
138  virtual TBtree *GetParentTree() const {return fTree;}
139  virtual void Remove(Int_t index) = 0;
140 
141  virtual TObject *operator[](Int_t i) const = 0;
142  virtual TObject *Found(const TObject *obj, TBtNode **which, Int_t *where) = 0;
143 
144  virtual Int_t FindRank(const TObject *obj) const = 0;
145  virtual Int_t NofKeys() const = 0; // # keys in or below this node
146 
147  virtual TBtLeafNode *FirstLeafNode() = 0;
148  virtual TBtLeafNode *LastLeafNode() = 0;
149 
150  virtual void Split() = 0;
151 #endif
152  // virtual void PrintOn(std::ostream &os) const = 0;
153  // friend std::ostream &operator<<(std::ostream &os, const TBtNode &node);
154 };
155 
156 
157 //////////////////////////////////////////////////////////////////////////
158 // //
159 // TBtItem //
160 // //
161 // Item stored in inner nodes of a TBtree. //
162 // //
163 //////////////////////////////////////////////////////////////////////////
164 
165 class TBtItem {
166 
167 friend class TBtInnerNode;
168 
169 private:
170  Int_t fNofKeysInTree; // number of keys in TBtree
171  TObject *fKey; // key
172  TBtNode *fTree; //! sub-tree
173 
174 public:
175  TBtItem();
176  TBtItem(TBtNode *n, TObject *o);
177  TBtItem(TObject *o, TBtNode *n);
178  ~TBtItem();
179 };
180 
181 
182 //////////////////////////////////////////////////////////////////////////
183 // //
184 // TBtInnerNode //
185 // //
186 // Inner node of a TBtree. //
187 // //
188 //////////////////////////////////////////////////////////////////////////
189 
190 class TBtInnerNode : public TBtNode {
191 
192 private:
193  TBtItem *fItem; // actually fItem[MaxIndex()+1] is desired
194 
195 public:
196  TBtInnerNode(TBtInnerNode *parent, TBtree *t = 0);
197  TBtInnerNode(TBtInnerNode *parent, TBtree *tree, TBtNode *oldroot);
198  ~TBtInnerNode();
199 
200 #ifndef __CINT__
201  void Add(const TObject *obj, Int_t idx);
202  void Add(TBtItem &i, Int_t idx);
203  void Add(Int_t at, TObject *obj, TBtNode *n);
204  void AddElt(TBtItem &itm, Int_t at);
205  void AddElt(Int_t at, TObject *obj, TBtNode *n);
206  void Remove(Int_t idx);
207  void RemoveItem(Int_t idx);
208 
209  TObject *operator[](Int_t i) const;
210  TObject *Found(const TObject *obj, TBtNode **which, Int_t *where);
211 
212  Int_t NofKeys(Int_t idx) const;
213  Int_t NofKeys() const;
214  void SetTree(Int_t i, TBtNode *node) { fItem[i].fTree = node; node->fParent = this; }
215  void SetKey(Int_t i, TObject *obj) { fItem[i].fKey = obj; }
216  void SetItem(Int_t i, TBtItem &itm) { fItem[i] = itm; itm.fTree->fParent = this; }
217  void SetItem(Int_t i, TObject *obj, TBtNode *node) { SetTree(i, node); SetKey(i, obj); }
218  Int_t GetNofKeys(Int_t i) const;
219  void SetNofKeys(Int_t i, Int_t r);
220  Int_t IncNofKeys(Int_t i, Int_t n=1);
221  Int_t DecNofKeys(Int_t i, Int_t n=1);
222  Int_t FindRank(const TObject *obj) const;
223  Int_t FindRankUp(const TBtNode *n) const;
224  TBtNode *GetTree(Int_t i) const { return fItem[i].fTree; }
225  TObject *GetKey(Int_t i) const { return fItem[i].fKey; }
226  TBtItem &GetItem(Int_t i) const { return fItem[i]; }
227 
228  Int_t IndexOf(const TBtNode *n) const;
229  void IncrNofKeys(TBtNode *np);
230  void DecrNofKeys(TBtNode *np);
231 
234 
235  void InformParent();
236 
237  void Split();
238  void SplitWith(TBtInnerNode *r, Int_t idx);
239  void MergeWithRight(TBtInnerNode *r, Int_t idx);
240  void BalanceWithLeft(TBtInnerNode *l, Int_t idx);
241  void BalanceWithRight(TBtInnerNode *r, Int_t idx);
242  void BalanceWith(TBtInnerNode *n, int idx);
243  void PushLeft(Int_t cnt, TBtInnerNode *leftsib, Int_t parentIdx);
244  void PushRight(Int_t cnt, TBtInnerNode *rightsib, Int_t parentIdx);
245  void AppendFrom(TBtInnerNode *src, Int_t start, Int_t stop);
246  void Append(TObject *obj, TBtNode *n);
247  void Append(TBtItem &itm);
248  void ShiftLeft(Int_t cnt);
249 
250  Int_t Psize() const { return fLast; }
251  Int_t Vsize() const;
252  Int_t MaxIndex() const { return fTree->fInnerMaxIndex; }
253  Int_t MaxPsize() const { return fTree->fInnerMaxIndex; }
254 
255  // void PrintOn(std::ostream &os) const;
256 
257  Int_t IsFull() const { return fLast == MaxIndex(); }
258  void IsFull(TBtNode *n);
259  Int_t IsAlmostFull() const { return fLast >= MaxIndex() - 1; }
260  Int_t IsLow() const { return fLast < fTree->fInnerLowWaterMark; }
261  void IsLow(TBtNode *n);
262 #endif
263 };
264 
265 
266 //////////////////////////////////////////////////////////////////////////
267 // //
268 // TBtLeafNode //
269 // //
270 // Leaf node of a TBtree. //
271 // //
272 //////////////////////////////////////////////////////////////////////////
273 
274 class TBtLeafNode : public TBtNode {
275 
276 friend class TBtInnerNode;
277 
278 private:
279  TObject **fItem; // actually TObject *fItem[MaxIndex()+1] is desired
280 
281 public:
282  TBtLeafNode(TBtInnerNode *p, const TObject *obj = 0, TBtree *t = 0);
283  ~TBtLeafNode();
284 
285 #ifndef __CINT__
286  void Add(const TObject *obj, Int_t idx);
287  void Remove(Int_t idx);
288  void RemoveItem(Int_t idx) { Remove(idx); }
289 
290  TObject *operator[](Int_t i) const;
291  TObject *Found(const TObject *obj, TBtNode **which, Int_t *where);
292 
293  Int_t NofKeys(Int_t i) const;
294  Int_t NofKeys() const;
295  Int_t FindRank(const TObject *obj) const;
296  TObject *GetKey(Int_t idx ) { return fItem[idx]; }
297  void SetKey(Int_t idx, TObject *obj) { fItem[idx] = obj; }
298 
299  Int_t IndexOf(const TObject *obj) const;
300 
303 
304  void Split();
305  void SplitWith(TBtLeafNode *r, Int_t idx);
306  void MergeWithRight(TBtLeafNode *r, Int_t idx);
307  void BalanceWithLeft(TBtLeafNode *l, Int_t idx);
308  void BalanceWithRight(TBtLeafNode *r, Int_t idx);
309  void BalanceWith(TBtLeafNode *n, Int_t idx);
310  void PushLeft(Int_t cnt, TBtLeafNode *l, Int_t parentIndex);
311  void PushRight(Int_t cnt, TBtLeafNode *r, Int_t parentIndex);
312  void AppendFrom(TBtLeafNode *src, Int_t start, Int_t stop);
313  void Append(TObject *obj);
314  void ShiftLeft(Int_t cnt);
315 
316  Int_t Psize() const { return fLast + 1; }
317  Int_t Vsize() const;
318  Int_t MaxIndex() const { return fTree->fLeafMaxIndex; }
319  Int_t MaxPsize() const { return fTree->fLeafMaxIndex + 1; }
320 
321  // void PrintOn(std::ostream &os) const;
322 
323  Int_t IsFull() const { return fLast == MaxIndex(); }
324  Int_t IsAlmostFull() const { return fLast >= MaxIndex() - 1; }
325  Int_t IsLow() const { return fLast < fTree->fLeafLowWaterMark; }
326 #endif
327 };
328 
329 
330 //////////////////////////////////////////////////////////////////////////
331 // //
332 // TBtreeIter //
333 // //
334 // Iterator of btree. //
335 // //
336 //////////////////////////////////////////////////////////////////////////
337 
338 class TBtreeIter : public TIterator,
339  public std::iterator<std::bidirectional_iterator_tag,
340  TObject*, std::ptrdiff_t,
341  const TObject**, const TObject*&> {
342 
343 private:
344  const TBtree *fTree; //btree being iterated
345  Int_t fCurCursor; //current position in btree
346  Int_t fCursor; //next position in btree
347  Bool_t fDirection; //iteration direction
348 
350 
351 public:
353  TBtreeIter(const TBtreeIter &iter);
355  TIterator &operator=(const TIterator &rhs);
356  TBtreeIter &operator=(const TBtreeIter &rhs);
357 
358  const TCollection *GetCollection() const { return fTree; }
359  TObject *Next();
360  void Reset();
361  Bool_t operator!=(const TIterator &aIter) const;
362  Bool_t operator!=(const TBtreeIter &aIter) const;
363  TObject *operator*() const;
364 
365  ClassDef(TBtreeIter,0) //B-tree iterator
366 };
367 
368 
369 //----- TBtree inlines ---------------------------------------------------------
370 
372 {
373  return (*fRoot)[i];
374 }
375 
376 inline TObject *TBtree::At(Int_t i) const
377 {
378  return (*fRoot)[i];
379 }
380 
381 inline TObject *TBtree::First() const
382 {
383  return (*fRoot)[0];
384 }
385 
386 inline TObject *TBtree::Last() const
387 {
388  return (*fRoot)[fSize-1];
389 }
390 
391 //----- TBtInnerNode inlines ---------------------------------------------------
392 
394 {
395  R__ASSERT(i >= 0 && i <= fLast);
396  return fItem[i].fNofKeysInTree;
397 }
398 
400 {
401  return GetNofKeys(idx);
402 }
403 
405 {
406  fItem[i].fNofKeysInTree = r;
407 }
408 
410 {
411  return (fItem[i].fNofKeysInTree += n);
412 }
413 
415 {
416  return (fItem[i].fNofKeysInTree -= n);
417 }
418 
420 {
421  R__ASSERT(fParent != 0 && fParent->GetTree(0) != (const TBtNode *)this);
422  return Psize()+1;
423 }
424 
425 
426 //----- TBtLeafNode inlines ----------------------------------------------------
427 
429 {
430  R__ASSERT(i >= 0 && i <= fLast);
431  return fItem[i];
432 }
433 
434 inline Int_t TBtLeafNode::Vsize() const
435 {
436  R__ASSERT(fParent != 0 && fParent->GetTree(0) != (const TBtNode *)this);
437  return Psize()+1;
438 }
439 
440 //inline std::ostream &operator<<(std::ostream& outputStream, const TBtNode &aNode)
441 //{
442 // aNode.PrintOn(outputStream);
443 // return outputStream;
444 //}
445 
446 #endif
TBtLeafNode(TBtInnerNode *p, const TObject *obj=0, TBtree *t=0)
Constructor.
Definition: TBtree.cxx:1362
void SetItem(Int_t i, TBtItem &itm)
Definition: TBtree.h:216
TObject * At(Int_t idx) const
Definition: TBtree.h:376
void BalanceWithLeft(TBtLeafNode *l, Int_t idx)
THIS has more than LEFTSIB; move some items from THIS to LEFTSIB.
Definition: TBtree.cxx:1451
void InformParent()
Tell the parent that we are full.
Definition: TBtree.cxx:957
void SetKey(Int_t idx, TObject *obj)
Definition: TBtree.h:297
const TBtree * fTree
Definition: TBtree.h:344
Int_t FindRankUp(const TBtNode *n) const
FindRankUp is FindRank in reverse.
Definition: TBtree.cxx:889
Int_t fLeafMaxIndex
Definition: TBtree.h:57
void SetItem(Int_t i, TObject *obj, TBtNode *node)
Definition: TBtree.h:217
TBtItem * fItem
Definition: TBtree.h:193
void ShiftLeft(Int_t cnt)
Shift.
Definition: TBtree.cxx:1678
void AddLast(TObject *obj)
Definition: TBtree.h:86
Int_t DecNofKeys(Int_t i, Int_t n=1)
Definition: TBtree.h:414
void AppendFrom(TBtInnerNode *src, Int_t start, Int_t stop)
This should never create a full node that is, it is not used anywhere where THIS could possibly be ne...
Definition: TBtree.cxx:776
Leaf node of a TBtree.
Definition: TBtree.h:274
TBtreeIter Iterator_t
Definition: TBtree.h:73
~TBtItem()
Delete a tree item.
Definition: TBtree.cxx:529
Int_t fLeafLowWaterMark
Definition: TBtree.h:55
TIterator * MakeIterator(Bool_t dir=kIterForward) const
Returns a B-tree iterator.
Definition: TBtree.cxx:384
void SetNofKeys(Int_t i, Int_t r)
Definition: TBtree.h:404
const char Option_t
Definition: RtypesCore.h:62
TBtInnerNode(TBtInnerNode *parent, TBtree *t=0)
Create a B-tree innernode.
Definition: TBtree.cxx:687
Int_t fInnerMaxIndex
Definition: TBtree.h:56
Int_t IsAlmostFull() const
Definition: TBtree.h:259
Int_t Psize() const
Definition: TBtree.h:316
TObject * operator[](Int_t i) const
Definition: TBtree.h:371
Int_t MaxIndex() const
Definition: TBtree.h:252
void RemoveItem(Int_t idx)
Definition: TBtree.h:288
void Add(TObject *obj)
Add object to B-tree.
Definition: TBtree.cxx:199
virtual ~TBtree()
Delete B-tree.
Definition: TBtree.cxx:188
Abstract base class (ABC) of a TBtree node.
Definition: TBtree.h:116
TBtLeafNode * FirstLeafNode()
Return the first node.
Definition: TBtree.cxx:1500
void AddAfter(const TObject *, TObject *obj)
Definition: TBtree.h:88
TBtree * fTree
Definition: TBtree.h:129
#define R__ASSERT(e)
Definition: TError.h:98
virtual TObject * operator[](Int_t i) const =0
void RootIsEmpty()
If root is empty clean up its space.
Definition: TBtree.cxx:440
Int_t Order()
Definition: TBtree.h:100
int Int_t
Definition: RtypesCore.h:41
bool Bool_t
Definition: RtypesCore.h:59
void Clear(Option_t *option="")
Remove all objects from B-tree.
Definition: TBtree.cxx:246
Int_t IsFull() const
Definition: TBtree.h:323
~TBtreeIter()
Definition: TBtree.h:354
virtual TObject * Found(const TObject *obj, TBtNode **which, Int_t *where)=0
void DecrNofKeys()
Definition: TBtree.h:65
virtual ~TBtNode()
Delete a B-tree node.
Definition: TBtree.cxx:563
TObject * After(const TObject *obj) const
Cannot use this method since B-tree decides order.
Definition: TBtree.cxx:227
TBtNode * fRoot
Definition: TBtree.h:49
void BalanceWithRight(TBtInnerNode *r, Int_t idx)
THIS has more than RIGHTSIB.
Definition: TBtree.cxx:825
Int_t IdxAdd(const TObject &obj)
Add object and return its index in the tree.
Definition: TBtree.cxx:300
Iterator abstract base class.
Definition: TIterator.h:32
TObject Int_t at
void AddElt(TBtItem &itm, Int_t at)
Add one element.
Definition: TBtree.cxx:734
Int_t NofKeys() const
Return the number of keys.
Definition: TBtree.cxx:1574
virtual void Add(const TObject *obj, Int_t index)=0
void PushLeft(Int_t cnt, TBtInnerNode *leftsib, Int_t parentIdx)
noFromThis==1 => moves the parent item into the leftsib, and the first item in this's array into the p...
Definition: TBtree.cxx:1169
Bool_t fDirection
Definition: TBtree.h:347
Int_t FindRank(const TObject *obj) const
Recursively look for WHAT starting in the current node.
Definition: TBtree.cxx:862
TObject * Next()
Get next object from B-tree. Returns 0 when no more objects in tree.
Definition: TBtree.cxx:638
Sequenceable collection abstract base class.
void SetTree(Int_t i, TBtNode *node)
Definition: TBtree.h:214
#define ClassDef(name, id)
Definition: Rtypes.h:254
Int_t fCursor
Definition: TBtree.h:346
void Remove(Int_t idx)
Remove an element.
Definition: TBtree.cxx:1655
void MergeWithRight(TBtLeafNode *r, Int_t idx)
Merge.
Definition: TBtree.cxx:1553
void Reset()
Reset the B-tree iterator.
Definition: TBtree.cxx:625
TObject ** GetObjectRef(const TObject *) const
Definition: TBtree.h:81
std::map< std::string, std::string >::const_iterator iter
Definition: TAlienJob.cxx:54
TObject * Found(const TObject *obj, TBtNode **which, Int_t *where)
Recursively look for WHAT starting in the current node.
Definition: TBtree.cxx:909
Int_t IsLow() const
Definition: TBtree.h:325
Item stored in inner nodes of a TBtree.
Definition: TBtree.h:165
TObject * GetKey(Int_t idx)
Definition: TBtree.h:296
tuple np
Definition: multifit.py:30
TIterator & operator=(const TIterator &rhs)
Overridden assignment operator.
Definition: TBtree.cxx:596
TBtLeafNode * LastLeafNode()
Return the last leaf node.
Definition: TBtree.cxx:1112
const Bool_t kIterForward
Definition: TCollection.h:43
TBtNode(Int_t isleaf, TBtInnerNode *p, TBtree *t=0)
Create a B-tree node.
Definition: TBtree.cxx:540
void BalanceWith(TBtLeafNode *n, Int_t idx)
PITEM is the parent item whose key will change when keys are shifted from one LeafNode to the other...
Definition: TBtree.cxx:1474
Int_t MaxIndex() const
Definition: TBtree.h:318
TBtNode * fTree
Definition: TBtree.h:172
TBtLeafNode * LastLeafNode()
return the last node.
Definition: TBtree.cxx:1545
TBtItem & GetItem(Int_t i) const
Definition: TBtree.h:226
Int_t fNofKeysInTree
Definition: TBtree.h:170
void MergeWithRight(TBtInnerNode *r, Int_t idx)
Merge the 2 part of the tree.
Definition: TBtree.cxx:1120
Int_t fOrder2
Definition: TBtree.h:52
Int_t fOrder
Definition: TBtree.h:51
TThread * t[5]
Definition: threadsh1.C:13
virtual TBtLeafNode * LastLeafNode()=0
void Split()
This function is called only when THIS is the only descendent of the root node, and THIS needs to be ...
Definition: TBtree.cxx:1276
Int_t Psize() const
Definition: TBtree.h:250
Int_t FindRank(const TObject *obj) const
WHAT was not in any inner node; it is either here, or it's not in the tree.
Definition: TBtree.cxx:1486
ROOT::R::TRInterface & r
Definition: Object.C:4
Int_t fCurCursor
Definition: TBtree.h:345
void PushRight(Int_t cnt, TBtLeafNode *r, Int_t parentIndex)
noFromThis==1 => moves the parent item into the rightsib, and the last item in this's array into the p...
Definition: TBtree.cxx:1611
virtual void Split()=0
void PushLeft(Int_t cnt, TBtLeafNode *l, Int_t parentIndex)
noFromThis==1 => moves the parent item into the leftsib, and the first item in this's array into the p...
Definition: TBtree.cxx:1592
Int_t fIsLeaf
Definition: TBtree.h:130
TBtNode * GetTree(Int_t i) const
Definition: TBtree.h:224
void Append(TObject *obj, TBtNode *n)
Never called from anywhere where it might fill up THIS.
Definition: TBtree.cxx:790
void AppendFrom(TBtLeafNode *src, Int_t start, Int_t stop)
A convenience function, does not worry about the element in the parent, simply moves elements from SR...
Definition: TBtree.cxx:1425
TObject * fKey
Definition: TBtree.h:171
void BalanceWithRight(TBtLeafNode *r, Int_t idx)
THIS has more than RIGHTSIB; move some items from THIS to RIGHTSIB.
Definition: TBtree.cxx:1462
TObject * operator*() const
Return current object or nullptr.
Definition: TBtree.cxx:674
Collection abstract base class.
Definition: TCollection.h:48
Int_t NofKeys() const
Number of key.
Definition: TBtree.cxx:1135
void DecrNofKeys(TBtNode *np)
THAT is a child of THIS that has just shrunk by 1.
Definition: TBtree.cxx:849
void RootIsFull()
The root of the tree is full.
Definition: TBtree.cxx:429
Int_t Vsize() const
Definition: TBtree.h:434
Int_t fLast
Definition: TBtree.h:123
TLine * l
Definition: textangle.C:4
Int_t fSize
Definition: TCollection.h:63
void Append(TObject *obj)
Never called from anywhere where it might fill up THIS does NOT handle nofKeys.
Definition: TBtree.cxx:1441
void IncrNofKeys(TBtNode *np)
THAT is a child of THIS that has just grown by 1.
Definition: TBtree.cxx:931
TObject * operator[](Int_t i) const
Definition: TBtree.h:428
void Init(Int_t i)
Initialize a B-tree.
Definition: TBtree.cxx:343
TBtree(Int_t ordern=3)
void Remove(Int_t idx)
Remove an element.
Definition: TBtree.cxx:1232
virtual void Remove(Int_t index)=0
virtual TBtree * GetParentTree() const
Definition: TBtree.h:138
Int_t IsAlmostFull() const
Definition: TBtree.h:324
virtual Int_t FindRank(const TObject *obj) const =0
TObject * operator[](Int_t i) const
return an element.
Definition: TBtree.cxx:1146
TObject * Before(const TObject *obj) const
May not use this method since B-tree decides order.
Definition: TBtree.cxx:236
~TBtLeafNode()
Destructor.
Definition: TBtree.cxx:1375
void AddAt(TObject *obj, Int_t)
Definition: TBtree.h:87
~TBtInnerNode()
Constructor.
Definition: TBtree.cxx:711
Int_t IsLow() const
Definition: TBtree.h:260
Iterator of btree.
Definition: TBtree.h:338
TObject * GetKey(Int_t i) const
Definition: TBtree.h:225
void AddFirst(TObject *obj)
Definition: TBtree.h:85
tuple tree
Definition: tree.py:24
Int_t Rank(const TObject *obj) const
Returns the rank of the object in the tree.
Definition: TBtree.cxx:392
TObject * Last() const
Definition: TBtree.h:386
void SplitWith(TBtLeafNode *r, Int_t idx)
Split.
Definition: TBtree.cxx:1705
TBtreeIter()
Definition: TBtree.h:349
Int_t IsFull() const
Definition: TBtree.h:257
TObject * Remove(TObject *obj)
Remove an object from the tree.
Definition: TBtree.cxx:407
Int_t IncNofKeys(Int_t i, Int_t n=1)
Definition: TBtree.h:409
void IncrNofKeys()
Definition: TBtree.h:64
void dir(char *path=0)
Definition: rootalias.C:30
void SetKey(Int_t i, TObject *obj)
Definition: TBtree.h:215
void Delete(Option_t *option="")
Remove all objects from B-tree AND delete all heap based objects.
Definition: TBtree.cxx:259
void BalanceWithLeft(TBtInnerNode *l, Int_t idx)
THIS has more than LEFTSIB.
Definition: TBtree.cxx:811
void PushRight(Int_t cnt, TBtInnerNode *rightsib, Int_t parentIdx)
The operation is three steps:
Definition: TBtree.cxx:1188
Bool_t operator!=(const TIterator &aIter) const
This operator compares two TIterator objects.
Definition: TBtree.cxx:654
#define name(a, b)
Definition: linkTestLib0.cpp:5
void AddBefore(const TObject *, TObject *obj)
Definition: TBtree.h:89
Mother of all ROOT objects.
Definition: TObject.h:58
void RemoveItem(Int_t idx)
Remove an item.
Definition: TBtree.cxx:1243
Int_t Vsize() const
Definition: TBtree.h:419
TObject * Found(const TObject *obj, TBtNode **which, Int_t *where)
WHAT was not in any inner node; it is either here, or it's not in the tree.
Definition: TBtree.cxx:1509
Int_t IndexOf(const TObject *obj) const
Returns a number in the range 0 to MaxIndex().
Definition: TBtree.cxx:1532
TBtLeafNode * FirstLeafNode()
Return the first leaf node.
Definition: TBtree.cxx:901
Int_t MaxPsize() const
Definition: TBtree.h:253
void ShiftLeft(Int_t cnt)
Shift to the left.
Definition: TBtree.cxx:1262
TObject * First() const
Definition: TBtree.h:381
Int_t IndexOf(const TBtNode *n) const
Returns a number in the range 0 to this->fLast 0 is returned if THAT == fTree[0]. ...
Definition: TBtree.cxx:945
void SplitWith(TBtInnerNode *r, Int_t idx)
THIS and SIB are too full; create a NEWNODE, and balance the number of keys between the three of them...
Definition: TBtree.cxx:1315
TObject * FindObject(const char *name) const
Find object using its name (see object's GetName()).
Definition: TBtree.cxx:274
const TCollection * GetCollection() const
Definition: TBtree.h:358
Int_t GetNofKeys(Int_t i) const
Definition: TBtree.h:393
virtual TBtLeafNode * FirstLeafNode()=0
TObject * obj
Inner node of a TBtree.
Definition: TBtree.h:190
void Split()
This function is called only when THIS is the only descendent of the root node, and THIS needs to be ...
Definition: TBtree.cxx:1692
virtual Int_t NofKeys() const =0
TObject ** fItem
Definition: TBtree.h:279
Int_t fInnerLowWaterMark
Definition: TBtree.h:54
const Int_t n
Definition: legend1.C:16
B-tree class.
Definition: TBtree.h:42
const char * cnt
Definition: TXMLSetup.cxx:75
Int_t MaxPsize() const
Definition: TBtree.h:319
TBtInnerNode * fParent
Definition: TBtree.h:128
void Add(const TObject *obj, Int_t idx)
This is called only from TBtree::Add().
Definition: TBtree.cxx:724
void Add(const TObject *obj, Int_t idx)
Add the object OBJ to the leaf node, inserting it at location INDEX in the fItem array.
Definition: TBtree.cxx:1384
void BalanceWith(TBtInnerNode *n, int idx)
PINDX is the index of the parent item whose key will change when keys are shifted from one InnerNode ...
Definition: TBtree.cxx:838
TBtItem()
sub-tree
Definition: TBtree.cxx:495