Skip to content

Latest commit

History

10 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Generic Splay Tree

Implementation of a Generic Splay Tree in C++.

What's a Splay Tree?

A splay tree is a self-balancing binary search tree with the additional property that recently accessed elements are quick to access again. It performs basic operations such as insertion, look-up and removal in O(log n) amortized time.

To see how splay trees work, check out this Splay Trees Visualization.

Member Functions

Iterators
beginReturn iterator to beginning (default traversal is inorder)
endReturn iterator to end (default traversal is inorder)
rbeginReturn reverse iterator to reverse beginning (default traversal is inorder)
rendReturn reverse iterator to reverse end (default traversal is inorder)
begin_inReturn iterator to beginning (inorder traversal)
end_inReturn iterator to end (inorder traversal)
rbegin_inReturn reverse iterator to reverse beginning (inorder traversal)
rend_inReturn reverse iterator to reverse end (inorder traversal)
begin_preReturn iterator to beginning (default inorder traversal)
end_preReturn iterator to end (default inorder traversal)
begin_postReturn iterator to beginning (default inorder traversal)
end_postReturn iterator to end (default inorder traversal)

Capacity
sizeReturn size
emptyTest whether splay tree is empty

Modifiers
insertInsert an element by value
eraseTest whether splay tree is empty
clearClear enitre contents of splay tree

Setup

  • Add splay.hpp to the same directory as where it is being used
  • Use #include "splay.h" preprocessing directive in the file where the splay tree is being used

Usage

  • Usage is similar and in line with other STL containers.
  • See examples.cpp for examples on how to use the splay class.

About

Implementation of a generic Splay Tree in C++

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages