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,
49 const SplayBinaryNode< Element >& e);
53 template <
typename Element >
54 INLINE std::ostream& operator<<(std::ostream& out,
55 const SplayTree< Element >& s);
71 template <
class Element >
72 class SplayBinaryNode {
89 const Element& getElement()
const;
96 const SplayBinaryNode< Element >* getFg()
const;
103 const SplayBinaryNode< Element >* getFd()
const;
122 SplayBinaryNode(
const Element& e,
123 HashTable< Element, SplayBinaryNode< Element >* >& addr,
124 SplayBinaryNode* g = 0,
125 SplayBinaryNode* d = 0,
126 SplayBinaryNode* p = 0);
133 SplayBinaryNode(
const SplayBinaryNode< Element >& from,
134 HashTable< Element, SplayBinaryNode< Element >* >& addr);
141 void copy_(
const SplayBinaryNode< Element >& from,
142 HashTable< Element, SplayBinaryNode< Element >* >& addr);
159 SplayBinaryNode< Element >* zig();
165 SplayBinaryNode< Element >* zag();
171 SplayBinaryNode< Element >* splay();
179 SplayBinaryNode< Element >*
180 join(
const SplayBinaryNode< Element >* e,
181 HashTable< Element, SplayBinaryNode< Element >* >& addr);
202 SplayBinaryNode* pere;
207 friend class SplayTree< Element >;
210 friend std::ostream& operator<<<>(std::ostream& out,
211 const SplayBinaryNode< Element >&);
260 template <
class Element >
277 SplayTree(
const Element& e);
283 SplayTree(
const SplayTree& from);
301 SplayTree< Element >& operator=(
const SplayTree< Element >& from);
315 Element& operator[](
const unsigned int i);
323 const Element& operator[](
const unsigned int i)
const;
352 void pushFront(
const Element& e);
358 void pushBack(
const Element& e);
364 void insert(
const Element& e);
370 void join(
const SplayTree< Element >& s);
382 SplayTree< Element > split(
const int i);
393 SplayTree< Element > split_by_val(
const Element& e);
406 bool contains(
const Element& e)
const;
417 SplayBinaryNode< Element >* root;
420 HashTable< Element, SplayBinaryNode< Element >* > addr;
425 void copy_(
const SplayTree< Element >&);
428 friend std::ostream& operator<<<>(std::ostream& out,
429 const SplayTree< Element >&);
435 #include <agrum/tools/core/splay_tpl.h>