8
0
mirror of https://github.com/FirebirdSQL/firebird.git synced 2025-01-23 22:03:03 +01:00

Formatting and VC6 hack.

This commit is contained in:
robocop 2007-05-16 06:52:23 +00:00
parent 63644eb3cb
commit e058195959

View File

@ -140,7 +140,7 @@ public:
// Delete all items pages
NodeList *lists = items->parent;
while ( items ) {
while (items) {
ItemList *t = items->next;
items->~ItemList();
pool->deallocate(items);
@ -151,7 +151,7 @@ public:
while (lists) {
NodeList *list = lists;
lists = lists->parent;
while ( list ) {
while (list) {
NodeList *t = list->next;
list->~NodeList();
pool->deallocate(list);
@ -222,7 +222,8 @@ public:
// Compute approximate number of leafs in the tree
size_t approxCount() const {
if (!root) return 0;
if (!root)
return 0;
if (level == 0) return ((ItemList*)root)->getCount();
@ -241,7 +242,8 @@ public:
// Compute approximate memory consumption for tree in bytes
size_t approxSize() const {
if (!root) return 0;
if (!root)
return 0;
if (level == 0)
return sizeof(ItemList);
@ -285,7 +287,7 @@ public:
ItemList *next, *prev;
// Adds newly created item to doubly-linked list
ItemList(ItemList *items) : parent(NULL) {
if ( (next = items->next) )
if ((next = items->next))
next->prev = this;
prev = items;
items->next = this;
@ -304,7 +306,7 @@ public:
public:
// Adds newly created item to the doubly-linked list
NodeList(NodeList *items) : parent(NULL) {
if ( (next = items->next) )
if ((next = items->next))
next->prev = this;
prev = items;
items->next = this;
@ -357,33 +359,33 @@ public:
if (this != &tree->defaultAccessor)
tree->defaultAccessor.curr = NULL;
if ( !tree->level ) {
if (!tree->level) {
curr->remove(curPos);
return curPos < curr->getCount();
}
if ( curr->getCount() == 1 ) {
if (curr->getCount() == 1) {
// Only one node left in the current page. We cannot remove it directly
// because is would invalidate our tree structure
fb_assert(curPos == 0);
ItemList *temp;
if ( (temp = curr->prev) && NEED_MERGE(temp->getCount(), LeafCount) ) {
if ((temp = curr->prev) && NEED_MERGE(temp->getCount(), LeafCount)) {
temp = curr->next;
tree->_removePage(0, curr);
curr = temp;
return curr;
}
if ( (temp = curr->next) && NEED_MERGE(temp->getCount(), LeafCount) ) {
if ((temp = curr->next) && NEED_MERGE(temp->getCount(), LeafCount)) {
tree->_removePage(0, curr);
curr = temp;
return true;
}
if ( (temp = curr->prev) ) {
if ((temp = curr->prev)) {
(*curr)[0] = (*temp)[temp->getCount() - 1];
temp->shrink(temp->getCount() - 1);
curr = curr->next;
return curr;
}
if ( (temp = curr->next) ) {
if ((temp = curr->next)) {
(*curr)[0] = (*temp)[0];
temp->remove(0);
return true;
@ -394,7 +396,7 @@ public:
}
curr->remove(curPos);
ItemList *temp;
if ( (temp = curr->prev) && NEED_MERGE(temp->getCount() + curr->getCount(), LeafCount) ) {
if ((temp = curr->prev) && NEED_MERGE(temp->getCount() + curr->getCount(), LeafCount)) {
// After join upper levels of the tree remain stable because join doesn't change
// key of the page. The same applies to lower case too.
curPos += temp->getCount();
@ -404,7 +406,7 @@ public:
// The code below will adjust current position if needed
}
else {
if ( (temp = curr->next) && NEED_MERGE(temp->getCount() + curr->getCount(), LeafCount) ) {
if ((temp = curr->next) && NEED_MERGE(temp->getCount() + curr->getCount(), LeafCount)) {
curr->join(*temp);
tree->_removePage(0, temp);
return true;
@ -433,7 +435,10 @@ public:
for (int lev = tree->level; lev; lev--) {
size_t pos;
if (!((NodeList *)list)->find(key, pos))
if ( pos > 0 ) pos--;
{
if (pos > 0)
pos--;
}
list = (*(NodeList *)list)[pos];
}
@ -448,19 +453,22 @@ public:
}
return found || curr;
case locLessEqual:
if (found) return true;
if (found)
return true;
// NOTE: fall into next case statement
case locLess:
if (curPos == 0) {
curr = curr->prev;
if (!curr) return false;
if (!curr)
return false;
curPos = curr->getCount() - 1;
}
else
curPos--;
return true;
case locGreat:
if (found) curPos++;
if (found)
curPos++;
if (curPos == curr->getCount()) {
curr = curr->next;
curPos = 0;
@ -473,7 +481,8 @@ public:
// position of accessor is not defined.
bool getFirst() {
void *items = tree->root;
if (!items) return false; // Uninitalized tree
if (!items)
return false; // Uninitalized tree
for (int i = tree->level; i > 0; i--)
items = (*(NodeList *)items)[0];
curr = (ItemList *)items;
@ -484,7 +493,8 @@ public:
// position of accessor is not defined.
bool getLast() {
void *items = tree->root;
if (!items) return false; // Uninitalized tree
if (!items)
return false; // Uninitalized tree
for (int i = tree->level; i > 0; i--)
items = (*(NodeList *)items)[((NodeList *)items)->getCount() - 1];
curr = (ItemList *)items;
@ -551,10 +561,10 @@ public:
}
ItemList *curr;
size_t curPos;
private:
BePlusTree* tree;
size_t curPos;
friend class BePlusTree;
}; // class Accessor
@ -578,7 +588,8 @@ template <typename Value, typename Key, typename Allocator, typename KeyOfValue,
bool BePlusTree<Value, Key, Allocator, KeyOfValue, Cmp, LeafCount, NodeCount>::add(const Value& item, Accessor* accessor)
{
// Finish initialization of the tree if necessary
if (!root) root = new (pool->allocate(sizeof(ItemList))) ItemList();
if (!root)
root = new (pool->allocate(sizeof(ItemList))) ItemList();
// Find leaf page for our item
void *vList = this->root;
@ -586,7 +597,10 @@ bool BePlusTree<Value, Key, Allocator, KeyOfValue, Cmp, LeafCount, NodeCount>::a
for (int lev = this->level; lev > 0 ; lev--) {
size_t pos;
if (!((NodeList *)vList)->find(key, pos))
if ( pos > 0 ) pos--;
{
if (pos > 0)
pos--;
}
vList = (*(NodeList *)vList)[pos];
}
@ -807,25 +821,25 @@ void BePlusTree<Value, Key, Allocator, KeyOfValue, Cmp, LeafCount, NodeCount>::_
list = temp->parent;
}
if ( list->getCount() == 1 ) {
if (list->getCount() == 1) {
// Only one node left in the list. We cannot remove it directly
// because is would invalidate our tree structure
NodeList *temp;
if ( (temp = list->prev) && NEED_MERGE(temp->getCount(), NodeCount) ) {
if ((temp = list->prev) && NEED_MERGE(temp->getCount(), NodeCount)) {
_removePage(nodeLevel + 1, list);
}
else
if ( (temp = list->next) && NEED_MERGE(temp->getCount(), NodeCount) ) {
if ((temp = list->next) && NEED_MERGE(temp->getCount(), NodeCount)) {
_removePage(nodeLevel + 1, list);
}
else
if ( (temp = list->prev) ) {
if ((temp = list->prev)) {
NodeList::setNodeParent(
((*list)[0] = (*temp)[temp->getCount() - 1]), nodeLevel, list);
temp->shrink(temp->getCount() - 1);
}
else
if ( (temp = list->next) ) {
if ((temp = list->next)) {
NodeList::setNodeParent(
((*list)[0] = (*temp)[0]), nodeLevel, list);
temp->remove(0);
@ -859,8 +873,8 @@ void BePlusTree<Value, Key, Allocator, KeyOfValue, Cmp, LeafCount, NodeCount>::_
}
else {
NodeList *temp;
if ( (temp = list->prev) &&
NEED_MERGE(temp->getCount() + list->getCount(), NodeCount) )
if ((temp = list->prev) &&
NEED_MERGE(temp->getCount() + list->getCount(), NodeCount))
{
// After join upper levels of the tree remain stable because join doesn't change
// key of the page. The same applies to lower case too.
@ -870,8 +884,8 @@ void BePlusTree<Value, Key, Allocator, KeyOfValue, Cmp, LeafCount, NodeCount>::_
_removePage(nodeLevel + 1, list);
}
else
if ( (temp = list->next) &&
NEED_MERGE(temp->getCount() + list->getCount(), NodeCount) )
if ((temp = list->next) &&
NEED_MERGE(temp->getCount() + list->getCount(), NodeCount))
{
list->join(*temp);
for (size_t i = 0; i < temp->getCount(); i++)