Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
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#include "TSeqCollection.h"
27#include "TError.h"
28
29#include <iterator>
30
31
32class TBtNode;
33class TBtInnerNode;
34class TBtLeafNode;
35class TBtreeIter;
36
37
38class TBtree : public TSeqCollection {
39
40friend class TBtNode;
41friend class TBtInnerNode;
42friend class TBtLeafNode;
43
44private:
45 TBtNode *fRoot; //root node of btree
46
47 Int_t fOrder; //the order of the tree (should be > 2)
48 Int_t fOrder2; //order*2+1 (assumes a memory access is
49 //cheaper than a multiply and increment by one
50 Int_t fInnerLowWaterMark; //inner node low water mark
51 Int_t fLeafLowWaterMark; //leaf low water mark
52 Int_t fInnerMaxIndex; //maximum inner node index
53 Int_t fLeafMaxIndex; //maximum leaf index
54
55 void Init(Int_t i); //initialize btree
56 void RootIsFull(); //called when the root node is full
57 void RootIsEmpty(); //called when root is empty
58
59protected:
60 void IncrNofKeys() { fSize++; }
61 void DecrNofKeys() { fSize--; }
62
63 // add the object to the tree; return the index in the tree at which
64 // the object was inserted. NOTE: other insertions and deletions may
65 // change this object's index.
66 Int_t IdxAdd(const TObject &obj);
67
68public:
70
71 TBtree(Int_t ordern = 3); //create a TBtree of order n
72 virtual ~TBtree();
73 void Clear(Option_t *option="") override;
74 void Delete(Option_t *option="") override;
75 TObject *FindObject(const char *name) const override;
76 TObject *FindObject(const TObject *obj) const override;
77 TObject **GetObjectRef(const TObject *) const override { return nullptr; }
78 TIterator *MakeIterator(Bool_t dir = kIterForward) const override;
79
80 void Add(TObject *obj) override;
81 void Add(TObject *obj, Option_t *) override { Add(obj); };
82 void AddFirst(TObject *obj) override { Add(obj); }
83 void AddFirst(TObject *obj, Option_t *) override { Add(obj); }
84 void AddLast(TObject *obj) override { Add(obj); }
85 void AddLast(TObject *obj, Option_t *) override { Add(obj); }
86 void AddAt(TObject *obj, Int_t) override { Add(obj); }
87 void AddAt(TObject *obj, Int_t, Option_t *) override { Add(obj); }
88 void AddAfter(const TObject *, TObject *obj) override { Add(obj); }
89 void AddAfter(const TObject *, TObject *obj, Option_t *) override { Add(obj); }
90 void AddBefore(const TObject *, TObject *obj) override { Add(obj); }
91 void AddBefore(const TObject *, TObject *obj, Option_t *) override { Add(obj); }
92 TObject *Remove(TObject *obj) override;
93
94 TObject *At(Int_t idx) const override;
95 TObject *Before(const TObject *obj) const override;
96 TObject *After(const TObject *obj) const override;
97 TObject *First() const override;
98 TObject *Last() const override;
99
100 //void PrintOn(std::ostream &os) const;
101
102 Int_t Order() { return fOrder; }
103 TObject *operator[](Int_t i) const;
104 Int_t Rank(const TObject *obj) const;
105
107};
108
109
110//////////////////////////////////////////////////////////////////////////
111// //
112// TBtNode //
113// //
114// Abstract base class (ABC) of a TBtree node. //
115// //
116//////////////////////////////////////////////////////////////////////////
117
118class TBtNode {
119
120friend class TBtree;
121friend class TBtInnerNode;
122friend class TBtLeafNode;
123
124protected:
125 Int_t fLast; // for inner node 1 <= fLast <= fInnerMaxIndex
126 // for leaf node 1 <= fLast <= fLeafMaxIndex
127 // (fLast==0 only temporarily while the tree is being
128 // updated)
129
130 TBtInnerNode *fParent; // a parent is always an inner node (or 0 for the root)
131 TBtree *fTree; // the tree of which this node is a part
132 Int_t fIsLeaf; // run-time type flag
133
134public:
135 TBtNode(Int_t isleaf, TBtInnerNode *p, TBtree *t = nullptr);
136 virtual ~TBtNode();
137
138 virtual void Add(const TObject *obj, Int_t index) = 0;
139 virtual TBtree *GetParentTree() const {return fTree;}
140 virtual void Remove(Int_t index) = 0;
141
142 virtual TObject *operator[](Int_t i) const = 0;
143 virtual TObject *Found(const TObject *obj, TBtNode **which, Int_t *where) = 0;
144
145 virtual Int_t FindRank(const TObject *obj) const = 0;
146 virtual Int_t NofKeys() const = 0; // # keys in or below this node
147
149 virtual TBtLeafNode *LastLeafNode() = 0;
150
151 virtual void Split() = 0;
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
165class TBtItem {
166
167friend class TBtInnerNode;
168
169private:
170 Int_t fNofKeysInTree; // number of keys in TBtree
171 TObject *fKey; // key
172 TBtNode *fTree; //! sub-tree
173
174public:
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
190class TBtInnerNode : public TBtNode {
191
192private:
193 TBtItem *fItem; // actually fItem[MaxIndex()+1] is desired
194
195public:
196 TBtInnerNode(TBtInnerNode *parent, TBtree *t = nullptr);
199
200 void Add(const TObject *obj, Int_t idx) override;
201 void Add(TBtItem &i, Int_t idx);
202 void Add(Int_t at, TObject *obj, TBtNode *n);
203 void AddElt(TBtItem &itm, Int_t at);
204 void AddElt(Int_t at, TObject *obj, TBtNode *n);
205 void Remove(Int_t idx) override;
206 void RemoveItem(Int_t idx);
207
208 TObject *operator[](Int_t i) const override;
209 TObject *Found(const TObject *obj, TBtNode **which, Int_t *where) override;
210
211 Int_t NofKeys(Int_t idx) const;
212 Int_t NofKeys() const override;
213 void SetTree(Int_t i, TBtNode *node) { fItem[i].fTree = node; node->fParent = this; }
214 void SetKey(Int_t i, TObject *obj) { fItem[i].fKey = obj; }
215 void SetItem(Int_t i, TBtItem &itm) { fItem[i] = itm; itm.fTree->fParent = this; }
216 void SetItem(Int_t i, TObject *obj, TBtNode *node) { SetTree(i, node); SetKey(i, obj); }
217 Int_t GetNofKeys(Int_t i) const;
218 void SetNofKeys(Int_t i, Int_t r);
221 Int_t FindRank(const TObject *obj) const override;
222 Int_t FindRankUp(const TBtNode *n) const;
223 TBtNode *GetTree(Int_t i) const { return fItem[i].fTree; }
224 TObject *GetKey(Int_t i) const { return fItem[i].fKey; }
225 TBtItem &GetItem(Int_t i) const { return fItem[i]; }
226
227 Int_t IndexOf(const TBtNode *n) const;
228 void IncrNofKeys(TBtNode *np);
229 void DecrNofKeys(TBtNode *np);
230
231 TBtLeafNode *FirstLeafNode() override;
232 TBtLeafNode *LastLeafNode() override;
233
234 void InformParent();
235
236 void Split() override;
237 void SplitWith(TBtInnerNode *r, Int_t idx);
241 void BalanceWith(TBtInnerNode *n, int idx);
244 void AppendFrom(TBtInnerNode *src, Int_t start, Int_t stop);
245 void Append(TObject *obj, TBtNode *n);
246 void Append(TBtItem &itm);
247 void ShiftLeft(Int_t cnt);
248
249 Int_t Psize() const { return fLast; }
250 Int_t Vsize() const;
251 Int_t MaxIndex() const { return fTree ? fTree->fInnerMaxIndex : 0; }
252 Int_t MaxPsize() const { return fTree ? fTree->fInnerMaxIndex : 0; }
253
254 // void PrintOn(std::ostream &os) const;
255
256 Int_t IsFull() const { return fLast == MaxIndex(); }
257 void IsFull(TBtNode *n);
258 Int_t IsAlmostFull() const { return fLast >= MaxIndex() - 1; }
259 Int_t IsLow() const { return fLast < fTree->fInnerLowWaterMark; }
260 void IsLow(TBtNode *n);
261};
262
263
264//////////////////////////////////////////////////////////////////////////
265// //
266// TBtLeafNode //
267// //
268// Leaf node of a TBtree. //
269// //
270//////////////////////////////////////////////////////////////////////////
271
272class TBtLeafNode : public TBtNode {
273
274friend class TBtInnerNode;
275
276private:
277 TObject **fItem; // actually TObject *fItem[MaxIndex()+1] is desired
278
279public:
280 TBtLeafNode(TBtInnerNode *p, const TObject *obj = nullptr, TBtree *t = nullptr);
281 ~TBtLeafNode();
282
283 void Add(const TObject *obj, Int_t idx) override;
284 void Remove(Int_t idx) override;
285 void RemoveItem(Int_t idx) { Remove(idx); }
286
287 TObject *operator[](Int_t i) const override;
288 TObject *Found(const TObject *obj, TBtNode **which, Int_t *where) override;
289
290 Int_t NofKeys(Int_t i) const;
291 Int_t NofKeys() const override;
292 Int_t FindRank(const TObject *obj) const override;
293 TObject *GetKey(Int_t idx ) { return fItem[idx]; }
294 void SetKey(Int_t idx, TObject *obj) { fItem[idx] = obj; }
295
296 Int_t IndexOf(const TObject *obj) const;
297
298 TBtLeafNode *FirstLeafNode() override;
299 TBtLeafNode *LastLeafNode() override;
300
301 void Split() override;
302 void SplitWith(TBtLeafNode *r, Int_t idx);
303 void MergeWithRight(TBtLeafNode *r, Int_t idx);
306 void BalanceWith(TBtLeafNode *n, Int_t idx);
309 void AppendFrom(TBtLeafNode *src, Int_t start, Int_t stop);
310 void Append(TObject *obj);
311 void ShiftLeft(Int_t cnt);
312
313 Int_t Psize() const { return fLast + 1; }
314 Int_t Vsize() const;
315 Int_t MaxIndex() const { return fTree ? fTree->fLeafMaxIndex : 0; }
316 Int_t MaxPsize() const { return fTree ? fTree->fLeafMaxIndex + 1 : 0; }
317
318 // void PrintOn(std::ostream &os) const;
319
320 Int_t IsFull() const { return fLast == MaxIndex(); }
321 Int_t IsAlmostFull() const { return fLast >= MaxIndex() - 1; }
322 Int_t IsLow() const { return fLast < fTree->fLeafLowWaterMark; }
323};
324
325
326//////////////////////////////////////////////////////////////////////////
327// //
328// TBtreeIter //
329// //
330// Iterator of btree. //
331// //
332//////////////////////////////////////////////////////////////////////////
333
334class TBtreeIter : public TIterator {
335
336private:
337 const TBtree *fTree; //btree being iterated
338 Int_t fCurCursor; //current position in btree
339 Int_t fCursor; //next position in btree
340 Bool_t fDirection; //iteration direction
341
343
344public:
345 using iterator_category = std::bidirectional_iterator_tag;
347 using difference_type = std::ptrdiff_t;
348 using pointer = TObject **;
349 using const_pointer = const TObject **;
350 using reference = const TObject *&;
351
352 TBtreeIter(const TBtree *t, Bool_t dir = kIterForward);
353 TBtreeIter(const TBtreeIter &iter);
355 TIterator &operator=(const TIterator &rhs) override;
357
358 const TCollection *GetCollection() const override { return fTree; }
359 TObject *Next() override;
360 void Reset() override;
361 Bool_t operator!=(const TIterator &aIter) const override;
362 Bool_t operator!=(const TBtreeIter &aIter) const;
363 TObject *operator*() const override;
364
365 ClassDefOverride(TBtreeIter,0) //B-tree iterator
366};
367
368//----- TBtree inlines ---------------------------------------------------------
369
371{
372 return (*fRoot)[i];
373}
374
375inline TObject *TBtree::At(Int_t i) const
376{
377 return (*fRoot)[i];
378}
379
380inline TObject *TBtree::First() const
381{
382 return (*fRoot)[0];
383}
384
385inline TObject *TBtree::Last() const
386{
387 return (*fRoot)[fSize-1];
388}
389
390//----- TBtInnerNode inlines ---------------------------------------------------
391
393{
394 R__ASSERT(i >= 0 && i <= fLast);
395 return fItem[i].fNofKeysInTree;
396}
397
399{
400 return GetNofKeys(idx);
401}
402
404{
406}
407
409{
410 return (fItem[i].fNofKeysInTree += n);
411}
412
414{
415 return (fItem[i].fNofKeysInTree -= n);
416}
417
419{
420 R__ASSERT(fParent != nullptr && fParent->GetTree(0) != (const TBtNode *)this);
421 return Psize()+1;
422}
423
424
425//----- TBtLeafNode inlines ----------------------------------------------------
426
428{
429 R__ASSERT(i >= 0 && i <= fLast);
430 return fItem[i];
431}
432
434{
435 R__ASSERT(fParent != nullptr && fParent->GetTree(0) != (const TBtNode *)this);
436 return Psize()+1;
437}
438
439//inline std::ostream &operator<<(std::ostream& outputStream, const TBtNode &aNode)
440//{
441// aNode.PrintOn(outputStream);
442// return outputStream;
443//}
444
445#endif
bool Bool_t
Boolean (0=false, 1=true) (bool)
Definition RtypesCore.h:77
int Int_t
Signed integer 4 bytes (int)
Definition RtypesCore.h:59
const char Option_t
Option string (const char)
Definition RtypesCore.h:80
#define ClassDefOverride(name, id)
Definition Rtypes.h:348
const Bool_t kIterForward
Definition TCollection.h:42
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
Definition TError.h:125
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t option
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t np
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t r
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t index
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t src
char name[80]
Definition TGX11.cxx:110
Inner node of a TBtree.
Definition TBtree.h:190
Int_t DecNofKeys(Int_t i, Int_t n=1)
Definition TBtree.h:413
void InformParent()
Tell the parent that we are full.
Definition TBtree.cxx:956
void ShiftLeft(Int_t cnt)
Shift to the left.
Definition TBtree.cxx:1261
Int_t NofKeys() const override
Number of key.
Definition TBtree.cxx:1134
void BalanceWithLeft(TBtInnerNode *l, Int_t idx)
THIS has more than LEFTSIB.
Definition TBtree.cxx:810
Int_t IncNofKeys(Int_t i, Int_t n=1)
Definition TBtree.h:408
void BalanceWithRight(TBtInnerNode *r, Int_t idx)
THIS has more than RIGHTSIB.
Definition TBtree.cxx:824
Int_t FindRankUp(const TBtNode *n) const
FindRankUp is FindRank in reverse.
Definition TBtree.cxx:888
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:775
void Append(TObject *obj, TBtNode *n)
Never called from anywhere where it might fill up THIS.
Definition TBtree.cxx:789
Int_t IsFull() const
Definition TBtree.h:256
TBtItem & GetItem(Int_t i) const
Definition TBtree.h:225
void SetKey(Int_t i, TObject *obj)
Definition TBtree.h:214
Int_t GetNofKeys(Int_t i) const
Definition TBtree.h:392
void AddElt(TBtItem &itm, Int_t at)
Add one element.
Definition TBtree.cxx:733
Int_t MaxIndex() const
Definition TBtree.h:251
Int_t Vsize() const
Definition TBtree.h:418
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:944
Int_t FindRank(const TObject *obj) const override
Recursively look for WHAT starting in the current node.
Definition TBtree.cxx:861
void Add(const TObject *obj, Int_t idx) override
This is called only from TBtree::Add().
Definition TBtree.cxx:723
void MergeWithRight(TBtInnerNode *r, Int_t idx)
Merge the 2 part of the tree.
Definition TBtree.cxx:1119
Int_t IsAlmostFull() const
Definition TBtree.h:258
void SetItem(Int_t i, TBtItem &itm)
Definition TBtree.h:215
void SetNofKeys(Int_t i, Int_t r)
Definition TBtree.h:403
Int_t MaxPsize() const
Definition TBtree.h:252
void SetTree(Int_t i, TBtNode *node)
Definition TBtree.h:213
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 ...
Definition TBtree.cxx:1168
void IncrNofKeys(TBtNode *np)
THAT is a child of THIS that has just grown by 1.
Definition TBtree.cxx:930
TObject * GetKey(Int_t i) const
Definition TBtree.h:224
void SetItem(Int_t i, TObject *obj, TBtNode *node)
Definition TBtree.h:216
void DecrNofKeys(TBtNode *np)
THAT is a child of THIS that has just shrunk by 1.
Definition TBtree.cxx:848
void Remove(Int_t idx) override
Remove an element.
Definition TBtree.cxx:1231
~TBtInnerNode()
Constructor.
Definition TBtree.cxx:710
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:837
void Split() override
This function is called only when THIS is the only descendent of the root node, and THIS needs to be ...
Definition TBtree.cxx:1275
void PushRight(Int_t cnt, TBtInnerNode *rightsib, Int_t parentIdx)
The operation is three steps:
Definition TBtree.cxx:1187
TObject * operator[](Int_t i) const override
return an element.
Definition TBtree.cxx:1145
TBtNode * GetTree(Int_t i) const
Definition TBtree.h:223
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:1314
void RemoveItem(Int_t idx)
Remove an item.
Definition TBtree.cxx:1242
TBtItem * fItem
Definition TBtree.h:193
TBtLeafNode * FirstLeafNode() override
Return the first leaf node.
Definition TBtree.cxx:900
TObject * Found(const TObject *obj, TBtNode **which, Int_t *where) override
Recursively look for WHAT starting in the current node.
Definition TBtree.cxx:908
Int_t IsLow() const
Definition TBtree.h:259
TBtLeafNode * LastLeafNode() override
Return the last leaf node.
Definition TBtree.cxx:1111
Int_t Psize() const
Definition TBtree.h:249
Item stored in inner nodes of a TBtree.
Definition TBtree.h:165
TBtItem()
sub-tree
Definition TBtree.cxx:495
~TBtItem()
Delete a tree item.
Definition TBtree.cxx:529
TObject * fKey
Definition TBtree.h:171
Int_t fNofKeysInTree
Definition TBtree.h:170
TBtNode * fTree
Definition TBtree.h:172
Leaf node of a TBtree.
Definition TBtree.h:272
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:1473
TObject * operator[](Int_t i) const override
Definition TBtree.h:427
void BalanceWithRight(TBtLeafNode *r, Int_t idx)
THIS has more than RIGHTSIB; move some items from THIS to RIGHTSIB.
Definition TBtree.cxx:1461
Int_t Vsize() const
Definition TBtree.h:433
TObject * GetKey(Int_t idx)
Definition TBtree.h:293
void Split() override
This function is called only when THIS is the only descendent of the root node, and THIS needs to be ...
Definition TBtree.cxx:1691
Int_t IsAlmostFull() const
Definition TBtree.h:321
void RemoveItem(Int_t idx)
Definition TBtree.h:285
Int_t Psize() const
Definition TBtree.h:313
TObject ** fItem
Definition TBtree.h:277
void ShiftLeft(Int_t cnt)
Shift.
Definition TBtree.cxx:1677
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 ...
Definition TBtree.cxx:1610
Int_t MaxPsize() const
Definition TBtree.h:316
void SplitWith(TBtLeafNode *r, Int_t idx)
Split.
Definition TBtree.cxx:1704
TObject * Found(const TObject *obj, TBtNode **which, Int_t *where) override
WHAT was not in any inner node; it is either here, or it's not in the tree.
Definition TBtree.cxx:1508
TBtLeafNode * FirstLeafNode() override
Return the first node.
Definition TBtree.cxx:1499
void Remove(Int_t idx) override
Remove an element.
Definition TBtree.cxx:1654
void BalanceWithLeft(TBtLeafNode *l, Int_t idx)
THIS has more than LEFTSIB; move some items from THIS to LEFTSIB.
Definition TBtree.cxx:1450
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 ...
Definition TBtree.cxx:1591
void Add(const TObject *obj, Int_t idx) override
Add the object OBJ to the leaf node, inserting it at location INDEX in the fItem array.
Definition TBtree.cxx:1383
void MergeWithRight(TBtLeafNode *r, Int_t idx)
Merge.
Definition TBtree.cxx:1552
~TBtLeafNode()
Destructor.
Definition TBtree.cxx:1374
Int_t NofKeys() const override
Return the number of keys.
Definition TBtree.cxx:1573
Int_t MaxIndex() const
Definition TBtree.h:315
TBtLeafNode * LastLeafNode() override
return the last node.
Definition TBtree.cxx:1544
Int_t IsLow() const
Definition TBtree.h:322
void Append(TObject *obj)
Never called from anywhere where it might fill up THIS does NOT handle nofKeys.
Definition TBtree.cxx:1440
Int_t IsFull() const
Definition TBtree.h:320
Int_t FindRank(const TObject *obj) const override
WHAT was not in any inner node; it is either here, or it's not in the tree.
Definition TBtree.cxx:1485
void SetKey(Int_t idx, TObject *obj)
Definition TBtree.h:294
Int_t IndexOf(const TObject *obj) const
Returns a number in the range 0 to MaxIndex().
Definition TBtree.cxx:1531
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:1424
Abstract base class (ABC) of a TBtree node.
Definition TBtree.h:118
virtual TObject * operator[](Int_t i) const =0
virtual void Add(const TObject *obj, Int_t index)=0
virtual TBtLeafNode * LastLeafNode()=0
virtual Int_t FindRank(const TObject *obj) const =0
virtual ~TBtNode()
Delete a B-tree node.
Definition TBtree.cxx:563
virtual Int_t NofKeys() const =0
friend class TBtLeafNode
Definition TBtree.h:122
TBtNode(Int_t isleaf, TBtInnerNode *p, TBtree *t=nullptr)
Create a B-tree node.
Definition TBtree.cxx:540
TBtInnerNode * fParent
Definition TBtree.h:130
friend class TBtInnerNode
Definition TBtree.h:121
virtual void Split()=0
TBtree * fTree
Definition TBtree.h:131
Int_t fIsLeaf
Definition TBtree.h:132
Int_t fLast
Definition TBtree.h:125
virtual TBtree * GetParentTree() const
Definition TBtree.h:139
virtual void Remove(Int_t index)=0
virtual TBtLeafNode * FirstLeafNode()=0
virtual TObject * Found(const TObject *obj, TBtNode **which, Int_t *where)=0
Iterator of btree.
Definition TBtree.h:334
std::bidirectional_iterator_tag iterator_category
Definition TBtree.h:345
const TBtree * fTree
Definition TBtree.h:337
const TCollection * GetCollection() const override
Definition TBtree.h:358
TBtreeIter()
Definition TBtree.h:342
Int_t fCurCursor
Definition TBtree.h:338
~TBtreeIter()
Definition TBtree.h:354
Bool_t operator!=(const TIterator &aIter) const override
This operator compares two TIterator objects.
Definition TBtree.cxx:653
TIterator & operator=(const TIterator &rhs) override
Overridden assignment operator.
Definition TBtree.cxx:595
Bool_t fDirection
Definition TBtree.h:340
std::ptrdiff_t difference_type
Definition TBtree.h:347
TObject * Next() override
Get next object from B-tree. Returns 0 when no more objects in tree.
Definition TBtree.cxx:637
void Reset() override
Reset the B-tree iterator.
Definition TBtree.cxx:624
Int_t fCursor
Definition TBtree.h:339
TObject * operator*() const override
Return current object or nullptr.
Definition TBtree.cxx:673
B-tree class.
Definition TBtree.h:38
Int_t fOrder
Definition TBtree.h:47
Int_t fInnerMaxIndex
Definition TBtree.h:52
Int_t IdxAdd(const TObject &obj)
Add object and return its index in the tree.
Definition TBtree.cxx:300
Int_t Rank(const TObject *obj) const
Returns the rank of the object in the tree.
Definition TBtree.cxx:392
void Delete(Option_t *option="") override
Remove all objects from B-tree AND delete all heap based objects.
Definition TBtree.cxx:259
virtual ~TBtree()
Delete B-tree.
Definition TBtree.cxx:188
void Init(Int_t i)
Initialize a B-tree.
Definition TBtree.cxx:343
void DecrNofKeys()
Definition TBtree.h:61
TBtNode * fRoot
Definition TBtree.h:45
Int_t fLeafLowWaterMark
Definition TBtree.h:51
void AddAt(TObject *obj, Int_t, Option_t *) override
Definition TBtree.h:87
Int_t fLeafMaxIndex
Definition TBtree.h:53
TObject * Before(const TObject *obj) const override
May not use this method since B-tree decides order.
Definition TBtree.cxx:236
TObject * Remove(TObject *obj) override
Remove an object from the tree.
Definition TBtree.cxx:407
void RootIsFull()
The root of the tree is full.
Definition TBtree.cxx:429
TObject * First() const override
Definition TBtree.h:380
TBtree(Int_t ordern=3)
Create a B-tree of certain order (by default 3).
Definition TBtree.cxx:179
TBtreeIter Iterator_t
Definition TBtree.h:69
void AddAt(TObject *obj, Int_t) override
Definition TBtree.h:86
void Add(TObject *obj) override
Add object to B-tree.
Definition TBtree.cxx:199
void Clear(Option_t *option="") override
Remove all objects from B-tree.
Definition TBtree.cxx:246
TObject * Last() const override
Definition TBtree.h:385
Int_t Order()
Definition TBtree.h:102
TObject * After(const TObject *obj) const override
Cannot use this method since B-tree decides order.
Definition TBtree.cxx:227
void AddAfter(const TObject *, TObject *obj) override
Definition TBtree.h:88
void AddLast(TObject *obj, Option_t *) override
Definition TBtree.h:85
void AddLast(TObject *obj) override
Definition TBtree.h:84
void Add(TObject *obj, Option_t *) override
Definition TBtree.h:81
Int_t fOrder2
Definition TBtree.h:48
TObject ** GetObjectRef(const TObject *) const override
Definition TBtree.h:77
TIterator * MakeIterator(Bool_t dir=kIterForward) const override
Returns a B-tree iterator.
Definition TBtree.cxx:384
void RootIsEmpty()
If root is empty clean up its space.
Definition TBtree.cxx:440
void AddBefore(const TObject *, TObject *obj, Option_t *) override
Definition TBtree.h:91
void AddFirst(TObject *obj) override
Definition TBtree.h:82
void AddBefore(const TObject *, TObject *obj) override
Definition TBtree.h:90
Int_t fInnerLowWaterMark
Definition TBtree.h:50
TObject * At(Int_t idx) const override
Definition TBtree.h:375
TObject * FindObject(const char *name) const override
Find object using its name (see object's GetName()).
Definition TBtree.cxx:274
TObject * operator[](Int_t i) const
Definition TBtree.h:370
void IncrNofKeys()
Definition TBtree.h:60
void AddAfter(const TObject *, TObject *obj, Option_t *) override
Definition TBtree.h:89
void AddFirst(TObject *obj, Option_t *) override
Definition TBtree.h:83
Collection abstract base class.
Definition TCollection.h:65
Iterator abstract base class.
Definition TIterator.h:30
Mother of all ROOT objects.
Definition TObject.h:41
Sequenceable collection abstract base class.
const Int_t n
Definition legend1.C:16
TLine l
Definition textangle.C:4