mirror of
https://github.com/FirebirdSQL/firebird.git
synced 2025-01-23 03:23:04 +01:00
Taken into account several useful notes made by Nickolay
This commit is contained in:
parent
15740e1a35
commit
5c2cfcc38b
@ -119,7 +119,7 @@ public:
|
||||
|
||||
const T val_aligned = value & ~(T) (BUNCH_BITS - 1);
|
||||
const BUNCH_T bit_mask = BUNCH_ONE << (value - val_aligned);
|
||||
if (tree.found(val_aligned) || tree.locate(val_aligned)) {
|
||||
if (tree.isPositioned(val_aligned) || tree.locate(val_aligned)) {
|
||||
tree.current().bits |= bit_mask;
|
||||
}
|
||||
else {
|
||||
@ -142,7 +142,7 @@ public:
|
||||
}
|
||||
|
||||
const T val_aligned = value & ~(T)(BUNCH_BITS - 1);
|
||||
if (tree.found(val_aligned) || tree.locate(val_aligned)) {
|
||||
if (tree.isPositioned(val_aligned) || tree.locate(val_aligned)) {
|
||||
const BUNCH_T bit_mask = BUNCH_ONE << (value - val_aligned);
|
||||
Bucket *current_bucket = &tree.current();
|
||||
if (current_bucket->bits & bit_mask) {
|
||||
@ -162,7 +162,7 @@ public:
|
||||
}
|
||||
|
||||
const T val_aligned = value & ~(T) (BUNCH_BITS - 1);
|
||||
if (tree.found(val_aligned) || tree.locate(val_aligned)) {
|
||||
if (tree.isPositioned(val_aligned) || tree.locate(val_aligned)) {
|
||||
const BUNCH_T bit_mask = BUNCH_ONE << (value - val_aligned);
|
||||
return tree.current().bits & bit_mask;
|
||||
}
|
||||
|
@ -179,7 +179,7 @@ public:
|
||||
// If next item doesn't exist method returns false
|
||||
bool fastRemove() { return defaultAccessor.fastRemove(); }
|
||||
|
||||
bool found(const Key& key) const { return defaultAccessor.found(key); }
|
||||
bool isPositioned(const Key& key) const { return defaultAccessor.isPositioned(key); }
|
||||
|
||||
bool locate(const Key& key) { return defaultAccessor.locate(locEqual, key); }
|
||||
|
||||
@ -339,6 +339,11 @@ public:
|
||||
// Remove item. Current position moves to next item after this call.
|
||||
// If next item doesn't exist method returns false
|
||||
bool fastRemove() {
|
||||
// invalidate current position of defaultAccessor
|
||||
// if i'm not a defaultAccessor
|
||||
if (this != &tree->defaultAccessor)
|
||||
tree->defaultAccessor.curr = NULL;
|
||||
|
||||
if ( !tree->level ) {
|
||||
curr->remove(curPos);
|
||||
return curPos < curr->getCount();
|
||||
@ -400,12 +405,6 @@ public:
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool found(const Key& key) const
|
||||
{
|
||||
return (curr && curPos < curr->getCount() &&
|
||||
KeyOfValue::generate(this, current()) == key);
|
||||
}
|
||||
|
||||
bool locate(const Key& key) {
|
||||
return locate(locEqual, key);
|
||||
@ -519,9 +518,22 @@ public:
|
||||
}
|
||||
Value& current() const { return (*curr)[curPos]; }
|
||||
private:
|
||||
|
||||
// Returns true if current position is valid and already points to the given key.
|
||||
// Note that we can't guarantie validity of current position if tree is accessed
|
||||
// by different Accessor's. Therefore this method is private and can be used only
|
||||
// via tree::defaultAccessor.
|
||||
bool isPositioned(const Key& key) const
|
||||
{
|
||||
return (curr && curPos < curr->getCount() &&
|
||||
KeyOfValue::generate(this, current()) == key);
|
||||
}
|
||||
|
||||
BePlusTree* tree;
|
||||
ItemList *curr;
|
||||
size_t curPos;
|
||||
|
||||
friend class BePlusTree;
|
||||
}; // class Accessor
|
||||
|
||||
private:
|
||||
|
Loading…
Reference in New Issue
Block a user