GithubHelp home page GithubHelp logo

iamshubhamgupto / splay-tree-as-a-container Goto Github PK

View Code? Open in Web Editor NEW
7.0 3.0 0.0 351 KB

A custom container built in C++ which is compatible with the STL library

License: MIT License

C++ 89.99% Makefile 0.59% Python 9.41%
containers stl-containers stl-algorithms cpp11 splay-tree

splay-tree-as-a-container's Introduction

Splay-Tree as a Container

This project recreates the std::map class of C++ using the self-balancing tree data structure Splay Trees. The implementation is generic. Most functionality has been added to the container however there is room for improvements and additional functions.

How to Compile & Test

Linux & Mac

Compilation

git clone https://github.com/IamShubhamGupto/Splay-Tree-as-a-Container.git
cd Splay-Tree-as-a-Container
make clientfile=<ENTER PATH TO CLIENT FILE NAME HERE>
./bin/a.out

EXAMPLE

make clientfile=examples/client1.cpp
./bin/a.out

Testing

Prerequiste:

pip3 install matplotlib

EXAMPLE

python3 tests/run_test.py 

Clean Up

In order to clean the generated files, run make clean.

Member Types

Member Type Definition
key_type template type of the key in the pair
mapped_type template type of the value in the pair
root_ stores root node of the splay tree.
iterator a bidirectional iterator to mapped_type.
const_iterator a bidirectional iterator to constant mapped_type.
reverse_iterator a bidirectional iterator to mapped_type.
const_reverse_iterator a bidirectional iterator to constant mapped_type.

Member Functions

Member Function Definition
(constructor) Splay tree constuctor.
(destructor) Splay tree destructor.
operator= Copy container contents.
Iterators
begin Return iterator to first in-order element.
end Return iterator to beyond-the-last element.
cbegin Return a constant iterator to first in-order element. Read Only.
cend Return a constant iterator to beyond-the-last element. Read Only.
rbegin Return iterator to last in-order element.
rend Return iterator to beyond-the-first element.
crbegin Return a constant iterator to last in-order element. Read Only.
crend Return a constant iterator to beyond-the-first element. Read Only.
Element Access
operator[] Access element using key. If not present, (default) value is inserted.
at Access element using key. If not preseed, out_of_range exception is thrown.
Modifiers
insert Insert new key-value pair into the tree. Incase key already exists, update value and return an iterator to inserted element.
erase Delete a key-value pair based on key. If key does not exist, do nothing.
clear Free the entire splay tree.
Operations
find Search for a key-value pair based on a given key. Return an iterator to pair if found else return end()
printTree Visually print the splay tree.

By

Special thanks to Faraz , Reuben and Madhoolika for testing the container during the early stages of the project ๐Ÿ˜„

splay-tree-as-a-container's People

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

splay-tree-as-a-container's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.