Added a BPlusTree::Remove() inline method for strings.

Style cleanups.


git-svn-id: file:///srv/svn/repos/haiku/trunk/current@2051 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Axel Dörfler
2002-11-21 20:22:36 +00:00
parent 2edddca0dc
commit def426bce2
+36 -13
View File
@@ -177,6 +177,7 @@ class BPlusTree {
status_t Remove(Transaction *transaction, const uint8 *key, uint16 keyLength, off_t value);
status_t Insert(Transaction *transaction, const uint8 *key, uint16 keyLength, off_t value);
status_t Remove(Transaction *transaction, const char *key, off_t value);
status_t Insert(Transaction *transaction, const char *key, off_t value);
status_t Insert(Transaction *transaction, int32 key, off_t value);
status_t Insert(Transaction *transaction, uint32 key, off_t value);
@@ -197,18 +198,26 @@ class BPlusTree {
// no implementation
int32 CompareKeys(const void *key1, int keylength1, const void *key2, int keylength2);
status_t FindKey(bplustree_node *node, const uint8 *key, uint16 keyLength, uint16 *index = NULL, off_t *next = NULL);
status_t FindKey(bplustree_node *node, const uint8 *key, uint16 keyLength,
uint16 *index = NULL, off_t *next = NULL);
status_t SeekDown(Stack<node_and_key> &stack, const uint8 *key, uint16 keyLength);
status_t FindFreeDuplicateFragment(bplustree_node *node, CachedNode *cached, off_t *_offset, bplustree_node **_fragment,uint32 *_index);
status_t InsertDuplicate(Transaction *transaction,CachedNode *cached,bplustree_node *node,uint16 index,off_t value);
void InsertKey(bplustree_node *node, uint16 index, uint8 *key, uint16 keyLength, off_t value);
status_t SplitNode(bplustree_node *node, off_t nodeOffset, bplustree_node *other, off_t otherOffset, uint16 *_keyIndex, uint8 *key, uint16 *_keyLength, off_t *_value);
status_t FindFreeDuplicateFragment(bplustree_node *node, CachedNode *cached,
off_t *_offset, bplustree_node **_fragment, uint32 *_index);
status_t InsertDuplicate(Transaction *transaction, CachedNode *cached,
bplustree_node *node, uint16 index, off_t value);
void InsertKey(bplustree_node *node, uint16 index, uint8 *key, uint16 keyLength,
off_t value);
status_t SplitNode(bplustree_node *node, off_t nodeOffset, bplustree_node *other,
off_t otherOffset, uint16 *_keyIndex, uint8 *key, uint16 *_keyLength,
off_t *_value);
status_t RemoveDuplicate(Transaction *transaction,bplustree_node *node,CachedNode *cached,uint16 keyIndex, off_t value);
status_t RemoveDuplicate(Transaction *transaction, bplustree_node *node,
CachedNode *cached, uint16 keyIndex, off_t value);
void RemoveKey(bplustree_node *node, uint16 index);
void UpdateIterators(off_t offset,off_t nextOffset,uint16 keyIndex,uint16 splitAt,int8 change);
void UpdateIterators(off_t offset, off_t nextOffset, uint16 keyIndex,
uint16 splitAt, int8 change);
void AddIterator(TreeIterator *iterator);
void RemoveIterator(TreeIterator *iterator);
@@ -229,7 +238,8 @@ class BPlusTree {
//***** helper classes/functions *****
extern int32 compareKeys(type_code type,const void *key1, int keyLength1, const void *key2, int keyLength2);
extern int32 compareKeys(type_code type, const void *key1, int keyLength1,
const void *key2, int keyLength2);
class TreeIterator {
public:
@@ -237,12 +247,15 @@ class TreeIterator {
~TreeIterator();
status_t Goto(int8 to);
status_t Traverse(int8 direction, void *key, uint16 *keyLength, uint16 maxLength, off_t *value,uint16 *duplicate = NULL);
status_t Traverse(int8 direction, void *key, uint16 *keyLength, uint16 maxLength,
off_t *value, uint16 *duplicate = NULL);
status_t Find(const uint8 *key, uint16 keyLength);
status_t Rewind();
status_t GetNextEntry(void *key,uint16 *keyLength,uint16 maxLength,off_t *value,uint16 *duplicate = NULL);
status_t GetPreviousEntry(void *key,uint16 *keyLength,uint16 maxLength,off_t *value,uint16 *duplicate = NULL);
status_t GetNextEntry(void *key, uint16 *keyLength, uint16 maxLength,
off_t *value, uint16 *duplicate = NULL);
status_t GetPreviousEntry(void *key, uint16 *keyLength, uint16 maxLength,
off_t *value, uint16 *duplicate = NULL);
void SkipDuplicates();
#ifdef DEBUG
@@ -269,6 +282,14 @@ class TreeIterator {
// BPlusTree's inline functions (most of them may not be needed)
inline status_t
BPlusTree::Remove(Transaction *transaction, const char *key, off_t value)
{
if (fHeader->data_type != BPLUSTREE_STRING_TYPE)
return B_BAD_TYPE;
return Remove(transaction, (uint8 *)key, strlen(key), value);
}
inline status_t
BPlusTree::Insert(Transaction *transaction, const char *key, off_t value)
{
@@ -336,13 +357,15 @@ TreeIterator::Rewind()
}
inline status_t
TreeIterator::GetNextEntry(void *key,uint16 *keyLength,uint16 maxLength,off_t *value,uint16 *duplicate)
TreeIterator::GetNextEntry(void *key, uint16 *keyLength, uint16 maxLength,
off_t *value, uint16 *duplicate)
{
return Traverse(BPLUSTREE_FORWARD, key, keyLength, maxLength, value, duplicate);
}
inline status_t
TreeIterator::GetPreviousEntry(void *key,uint16 *keyLength,uint16 maxLength,off_t *value,uint16 *duplicate)
TreeIterator::GetPreviousEntry(void *key, uint16 *keyLength, uint16 maxLength,
off_t *value, uint16 *duplicate)
{
return Traverse(BPLUSTREE_BACKWARD, key, keyLength, maxLength, value, duplicate);
}