* Added assignment operators.
* Some automatic whitespace cleanup. git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@34783 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright 2008, Ingo Weinhold <[email protected]>.
|
* Copyright 2008-2009, Ingo Weinhold <[email protected]>.
|
||||||
* Distributed under the terms of the MIT License.
|
* Distributed under the terms of the MIT License.
|
||||||
*
|
*
|
||||||
* Original Java implementation:
|
* Original Java implementation:
|
||||||
@@ -23,12 +23,12 @@
|
|||||||
struct SplayTreeDefinition {
|
struct SplayTreeDefinition {
|
||||||
typedef xxx KeyType;
|
typedef xxx KeyType;
|
||||||
typedef yyy NodeType;
|
typedef yyy NodeType;
|
||||||
|
|
||||||
static const KeyType& GetKey(const NodeType* node);
|
static const KeyType& GetKey(const NodeType* node);
|
||||||
static SplayTreeLink<NodeType>* GetLink(NodeType* node);
|
static SplayTreeLink<NodeType>* GetLink(NodeType* node);
|
||||||
|
|
||||||
static int Compare(const KeyType& key, const NodeType* node);
|
static int Compare(const KeyType& key, const NodeType* node);
|
||||||
|
|
||||||
// for IteratableSplayTree only
|
// for IteratableSplayTree only
|
||||||
static NodeType** GetListLink(NodeType* node);
|
static NodeType** GetListLink(NodeType* node);
|
||||||
};
|
};
|
||||||
@@ -255,16 +255,22 @@ public:
|
|||||||
return closestNode;
|
return closestNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SplayTree& operator=(const SplayTree& other)
|
||||||
|
{
|
||||||
|
fRoot = other.fRoot;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
/*!
|
/*!
|
||||||
Internal method to perform a top-down splay.
|
Internal method to perform a top-down splay.
|
||||||
|
|
||||||
_Splay(key) does the splay operation on the given key.
|
_Splay(key) does the splay operation on the given key.
|
||||||
If key is in the tree, then the node containing
|
If key is in the tree, then the node containing
|
||||||
that key becomes the root. If key is not in the tree,
|
that key becomes the root. If key is not in the tree,
|
||||||
then after the splay, key.root is either the greatest key
|
then after the splay, key.root is either the greatest key
|
||||||
< key in the tree, or the least key > key in the tree.
|
< key in the tree, or the least key > key in the tree.
|
||||||
|
|
||||||
This means, among other things, that if you splay with
|
This means, among other things, that if you splay with
|
||||||
a key that's larger than any in the tree, the rightmost
|
a key that's larger than any in the tree, the rightmost
|
||||||
node of the tree becomes the root. This property is used
|
node of the tree becomes the root. This property is used
|
||||||
@@ -587,6 +593,13 @@ public:
|
|||||||
return ConstIterator(this, FindClosest(key, greater, orEqual));
|
return ConstIterator(this, FindClosest(key, greater, orEqual));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
IteratableSplayTree& operator=(const IteratableSplayTree& other)
|
||||||
|
{
|
||||||
|
fTree = other.fTree;
|
||||||
|
fFirst = other.fFirst;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
friend class Iterator;
|
friend class Iterator;
|
||||||
friend class ConstIterator;
|
friend class ConstIterator;
|
||||||
|
|||||||
Reference in New Issue
Block a user