203 Error(
"Add",
"object must be sortable");
213 if (
fRoot->Found(obj, &loc, &idx)) {
285 Error(
"FindObject",
"object must be sortable");
293 return fRoot->Found(obj, &loc, &idx);
304 Error(
"IdxAdd",
"object must be sortable");
315 if (
fRoot->Found(&obj, &loc, &idx)) {
346 Warning(
"Init",
"order must be at least 3");
386 return new TBtreeIter(
this, dir);
395 Error(
"Rank",
"object must be sortable");
401 return fRoot->FindRank(obj);
410 Error(
"Remove",
"object must be sortable");
442 if (
fRoot->fIsLeaf) {
451 fRoot->fParent =
nullptr;
463 b.ReadVersion(&R__s, &R__c);
481 b.SetByteCount(R__c,
kTRUE);
691 ::Fatal(
"TBtInnerNode::TBtInnerNode",
"no more memory");
703 ::Fatal(
"TBtInnerNode::TBtInnerNode",
"no more memory");
713 delete fItem[0].fTree;
816 PushLeft(noFromThis, leftsib, pidx);
851 fItem[i].fNofKeysInTree--;
855 fTree->DecrNofKeys();
892 for (
Int_t i = 0; i <
l; i++)
933 fItem[i].fNofKeysInTree++;
937 fTree->IncrNofKeys();
985 Int_t hasLeftSib = (leafidx > 0) &&
993 }
else if (hasLeftSib) {
1000 }
else if (hasRightSib) {
1003 }
else if (leftSibFull) {
1006 }
else if (hasLeftSib) {
1021 Int_t hasLeftSib = (inneridx > 0) &&
1028 }
else if (hasLeftSib) {
1034 }
else if (hasRightSib) {
1036 }
else if (leftSibFull) {
1038 }
else if (hasLeftSib) {
1064 Int_t hasLeftSib = (leafidx > 0) &&
1074 }
else if (hasLeftSib) {
1077 }
else if (hasRightSib) {
1090 Int_t hasLeftSib = (inneridx > 0) &&
1098 }
else if (hasLeftSib) {
1100 }
else if (hasRightSib) {
1122 if (rightsib->
Psize() > 0)
1153 ::Error(
"TBtInnerNode::operator[]",
"should not happen, 0 returned");
1160 ::Error(
"TBtInnerNode::operator[]",
"should not happen, 0 returned");
1198 tgt = rightsib->
fLast + noFromThis;
1199 src = rightsib->
fLast;
1200 rightsib->
fLast = tgt;
1221 fLast -= noFromThis;
1252 fTree->RootIsEmpty();
1320 Int_t newSizeThis = nofKeys / 3;
1321 Int_t newSizeNew = (nofKeys - newSizeThis) / 2;
1322 Int_t newSizeSib = (nofKeys - newSizeThis - newSizeNew);
1324 Int_t noFromSib = rightsib->
Vsize() - newSizeSib;
1333 if (noFromThis > 0) {
1337 this->
PushRight(noFromThis-1, newNode, keyidx);
1338 rightsib->
PushLeft(noFromSib, newNode, keyidx+1);
1344 fParent->SetTree(keyidx, newNode);
1345 rightsib->
PushLeft(noFromSib-1, newNode, keyidx+1);
1395 fTree->IncrNofKeys();
1407 fTree->RootIsFull();
1455 PushLeft(noFromThis, leftsib, pidx);
1534 if (
fItem[i] == that)
1626 tgt = rightsib->
fLast + noFromThis;
1627 src = rightsib->
fLast;
1628 rightsib->
fLast = tgt;
1630 rightsib->
fItem[tgt--] = rightsib->
fItem[src--];
1644 fLast -= noFromThis;
1661 fTree->DecrNofKeys();
1668 fTree->RootIsEmpty();
1709 Int_t newSizeThis = nofKeys / 3;
1710 Int_t newSizeNew = (nofKeys - newSizeThis) / 2;
1711 Int_t newSizeSib = (nofKeys - newSizeThis - newSizeNew);
1713 Int_t noFromSib = rightsib->
Vsize() - newSizeSib;
1719 fParent->SetNofKeys(keyidx, 0);
1720 fParent->DecNofKeys(keyidx-1);
1721 this->
PushRight(noFromThis-1, newNode, keyidx);
1722 rightsib->
PushLeft(noFromSib, newNode, keyidx+1);
int Int_t
Signed integer 4 bytes (int).
unsigned int UInt_t
Unsigned integer 4 bytes (unsigned int).
bool Bool_t
Boolean (0=false, 1=true) (bool).
const char Option_t
Option string (const char).
const Bool_t kIterForward
Error("WriteTObject","The current directory (%s) is not associated with a file. The object (%s) has not been written.", GetName(), objname)
#define R__ASSERT(e)
Checks condition e and reports a fatal error if it's false.
void Fatal(const char *location, const char *msgfmt,...)
Use this function in case of a fatal error. It will abort the program.
#define R__CHECK(e)
Checks condition e and reports a warning message if it's false.
Int_t Compare(const void *item1, const void *item2)
Int_t DecNofKeys(Int_t i, Int_t n=1)
void InformParent()
Tell the parent that we are full.
void ShiftLeft(Int_t cnt)
Shift to the left.
Int_t NofKeys() const override
Number of key.
void BalanceWithLeft(TBtInnerNode *l, Int_t idx)
THIS has more than LEFTSIB. Move some item from THIS to LEFTSIB. PIDX is the index of the parent item...
Int_t IncNofKeys(Int_t i, Int_t n=1)
void BalanceWithRight(TBtInnerNode *r, Int_t idx)
THIS has more than RIGHTSIB. Move some items from THIS to RIGHTSIB. PIDX is the index of the parent i...
Int_t FindRankUp(const TBtNode *n) const
FindRankUp is FindRank in reverse. Whereas FindRank looks for the object and computes the rank along ...
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...
void Append(TObject *obj, TBtNode *n)
Never called from anywhere where it might fill up THIS.
TBtItem & GetItem(Int_t i) const
void SetKey(Int_t i, TObject *obj)
Int_t GetNofKeys(Int_t i) const
void AddElt(TBtItem &itm, Int_t at)
Add one element.
Int_t IndexOf(const TBtNode *n) const
Returns a number in the range 0 to this->fLast 0 is returned if THAT == fTree[0].
Int_t FindRank(const TObject *obj) const override
Recursively look for WHAT starting in the current node.
void Add(const TObject *obj, Int_t idx) override
This is called only from TBtree::Add().
void MergeWithRight(TBtInnerNode *r, Int_t idx)
Merge the 2 part of the tree.
Int_t IsAlmostFull() const
void SetItem(Int_t i, TBtItem &itm)
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 ...
void IncrNofKeys(TBtNode *np)
THAT is a child of THIS that has just grown by 1.
TBtInnerNode(TBtInnerNode *parent, TBtree *t=nullptr)
Create a B-tree innernode.
TObject * GetKey(Int_t i) const
void DecrNofKeys(TBtNode *np)
THAT is a child of THIS that has just shrunk by 1.
void Remove(Int_t idx) override
Remove an element.
~TBtInnerNode()
Constructor.
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 ...
void Split() override
This function is called only when THIS is the only descendent of the root node, and THIS needs to be ...
void PushRight(Int_t cnt, TBtInnerNode *rightsib, Int_t parentIdx)
The operation is three steps:
TObject * operator[](Int_t i) const override
return an element.
TBtNode * GetTree(Int_t i) const
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...
void RemoveItem(Int_t idx)
Remove an item.
TBtLeafNode * FirstLeafNode() override
Return the first leaf node.
Int_t NofKeys(Int_t idx) const
TObject * Found(const TObject *obj, TBtNode **which, Int_t *where) override
Recursively look for WHAT starting in the current node.
TBtLeafNode * LastLeafNode() override
Return the last leaf node.
Item stored in inner nodes of a TBtree.
TBtItem()
Create an item to be stored in the tree. An item contains a counter of the number of keys (i....
~TBtItem()
Delete a tree item.
TBtNode * fTree
! sub-tree
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.
void BalanceWithRight(TBtLeafNode *r, Int_t idx)
THIS has more than RIGHTSIB; move some items from THIS to RIGHTSIB.
void Split() override
This function is called only when THIS is the only descendent of the root node, and THIS needs to be ...
Int_t IsAlmostFull() const
void RemoveItem(Int_t idx)
void ShiftLeft(Int_t cnt)
Shift.
friend class TBtInnerNode
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 ...
void SplitWith(TBtLeafNode *r, Int_t idx)
Split.
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.
TBtLeafNode * FirstLeafNode() override
Return the first node.
void Remove(Int_t idx) override
Remove an element.
void BalanceWithLeft(TBtLeafNode *l, Int_t idx)
THIS has more than LEFTSIB; move some items from THIS to LEFTSIB.
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 ...
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.
void MergeWithRight(TBtLeafNode *r, Int_t idx)
Merge.
~TBtLeafNode()
Destructor.
Int_t NofKeys() const override
Return the number of keys.
Int_t NofKeys(Int_t i) const
Return the number of keys.
TBtLeafNode * LastLeafNode() override
return the last node.
void Append(TObject *obj)
Never called from anywhere where it might fill up THIS does NOT handle nofKeys.
TBtLeafNode(TBtInnerNode *p, const TObject *obj=nullptr, TBtree *t=nullptr)
Constructor.
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.
Int_t IndexOf(const TObject *obj) const
Returns a number in the range 0 to MaxIndex().
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...
Abstract base class (ABC) of a TBtree node.
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.
TBtNode(Int_t isleaf, TBtInnerNode *p, TBtree *t=nullptr)
Create a B-tree node.
friend class TBtInnerNode
virtual TBtree * GetParentTree() const
virtual void Remove(Int_t index)=0
virtual TBtLeafNode * FirstLeafNode()=0
virtual TObject * Found(const TObject *obj, TBtNode **which, Int_t *where)=0
Bool_t operator!=(const TIterator &aIter) const override
This operator compares two TIterator objects.
TIterator & operator=(const TIterator &rhs) override
Overridden assignment operator.
TObject * Next() override
Get next object from B-tree. Returns 0 when no more objects in tree.
void Reset() override
Reset the B-tree iterator.
TObject * operator*() const override
Return current object or nullptr.
Int_t IdxAdd(const TObject &obj)
Int_t Rank(const TObject *obj) const
TClass * IsA() const override
void Delete(Option_t *option="") override
Delete this object.
TObject * Before(const TObject *obj) const override
friend class TBtInnerNode
TObject * Remove(TObject *obj) override
void Add(TObject *obj) override
void Clear(Option_t *option="") override
void Streamer(TBuffer &) override
Stream an object of class TObject.
TObject * After(const TObject *obj) const override
TIterator * MakeIterator(Bool_t dir=kIterForward) const override
TObject * At(Int_t idx) const override
TObject * FindObject(const char *name) const override
Must be redefined in derived classes.
Buffer base class used for serializing objects.
Bool_t IsArgNull(const char *where, const TObject *obj) const
Returns true if object is a null pointer.
TObject * FindObject(const char *name) const override
Find an object in this collection using its name.
static void GarbageCollect(TObject *obj)
Add to the list of things to be cleaned up.
Iterator abstract base class.
virtual TClass * IsA() const
Mother of all ROOT objects.
virtual Bool_t IsSortable() const
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
void MayNotUse(const char *method) const
Use this method to signal that a method (defined in a base class) may not be called in a derived clas...
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
TObject()
TObject constructor.
void Streamer(TBuffer &) override
Stream all objects in the collection to or from the I/O buffer.
static uint64_t sum(uint64_t i)