Git Product home page Git Product logo

b-tree's Introduction

b-tree

This is an efficient in-memory B+ tree implementation, supporting any type of keys and values (provided that the assignment function and compare function of the data types used exist or are implemented).

mkdir build
cd build

Generate the makefile by CMake:

cmake ..

Compile the source files:

make 

Make sure every thing is right by running test:

make test

After the compiling, two executables, b_tree and btree_test will be generated. b_tree runs performance benchmark and btree_test runs the tests.

How to use our B+tree

BPlusTree<long, int, 16> tree; // constrcut a B+ tree instance, in which the keys are of long type, the values are of int type and the fanout is 16.
tree.insert(16, 0); // insert key-value pair (16, 0) to the tree
tree.insert(17, 17); // insert key-value pair (17, 17) to the tree

tree.update(16, 16); // update the value associated with key 16
tree.delete_key(17); // remove key-value pair with key 17

int value;
if (tree.search(16, value)) // retrieve the value associated with key 16.
    std::cout << "value is " << value << std::endl;
else
    std::cout << "not found" << std::endl;
    
std::cout << "B+tree: " << tree << std::endl; // dump the tree

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.