35 #include <agrum/agrum.h> 36 #include <agrum/tools/core/hashTable.h> 40 template <
class Element >
41 class SplayBinaryNode;
42 template <
class Element >
47 template <
typename Element >
48 INLINE std::ostream& operator<<(std::ostream& out,
const SplayBinaryNode< Element >& e);
52 template <
typename Element >
53 INLINE std::ostream& operator<<(std::ostream& out,
const SplayTree< Element >& s);
69 template <
class Element >
70 class SplayBinaryNode {
87 const Element& getElement()
const;
94 const SplayBinaryNode< Element >* getFg()
const;
101 const SplayBinaryNode< Element >* getFd()
const;
120 SplayBinaryNode(
const Element& e,
121 HashTable< Element, SplayBinaryNode< Element >* >& addr,
122 SplayBinaryNode* g = 0,
123 SplayBinaryNode* d = 0,
124 SplayBinaryNode* p = 0);
131 SplayBinaryNode(
const SplayBinaryNode< Element >& from,
132 HashTable< Element, SplayBinaryNode< Element >* >& addr);
139 void copy_(
const SplayBinaryNode< Element >& from,
140 HashTable< Element, SplayBinaryNode< Element >* >& addr);
157 SplayBinaryNode< Element >* zig();
163 SplayBinaryNode< Element >* zag();
169 SplayBinaryNode< Element >* splay();
177 SplayBinaryNode< Element >* join(
const SplayBinaryNode< Element >* e,
178 HashTable< Element, SplayBinaryNode< Element >* >& addr);
199 SplayBinaryNode* pere;
204 friend class SplayTree< Element >;
207 friend std::ostream& operator<<<>(std::ostream& out,
const SplayBinaryNode< Element >&);
256 template <
class Element >
273 SplayTree(
const Element& e);
279 SplayTree(
const SplayTree& from);
297 SplayTree< Element >& operator=(
const SplayTree< Element >& from);
311 Element& operator[](
const unsigned int i);
319 const Element& operator[](
const unsigned int i)
const;
348 void pushFront(
const Element& e);
354 void pushBack(
const Element& e);
360 void insert(
const Element& e);
366 void join(
const SplayTree< Element >& s);
378 SplayTree< Element > split(
const int i);
389 SplayTree< Element > split_by_val(
const Element& e);
402 bool contains(
const Element& e)
const;
413 SplayBinaryNode< Element >* root;
416 HashTable< Element, SplayBinaryNode< Element >* > addr;
421 void copy_(
const SplayTree< Element >&);
424 friend std::ostream& operator<<<>(std::ostream& out,
const SplayTree< Element >&);
430 #include <agrum/tools/core/splay_tpl.h>