Click here to Skip to main content
Licence CPOL
First Posted 15 Sep 2008
Views 9,091
Downloads 121
Bookmarked 6 times

I have developed a B+Tree using template. Please enjoy.

By | 15 Sep 2008 | Article
B+Tree

Introduction

This is a B+Tree implementation.

Background

Fundamentals of Database System. 5th Edition. Korean Translation.

Using the code

Include BPNode.h and BPTree.h.
You can use CBPTree<Key, Value, Degree> as follows.
Degree has 2 as default.

// using bptree
#include "BPNode.h"
#include "BPTree.h"

CBPTree<int, std::string> bpTree;
// Supports B+Tree Insert, Delete command.

bpTree.Insert(10, "This is a test");
std::string s;
if(bpTree.Search(10, s))
{
    cout << s;
}
else
{

    cerr << "Key not found" << endl;
} 
// Also support an iterator.
CBPTree<int, std::string>::iterator i;

for(i = bpTree.begin(); i != bpTree.end(); i++)

{
    cout << *i << " ";
}

Please refer to Source code how to use it.
I developed it with Visual Studio 2008. But, I tried to write it would work with any C++ compiler. I wanted to compile it on Linux. But I have no linux machine. If someone try, please let me know the result.
When you open the project with VS2008, You can see how Index(Intermediate) Nodes and Leaf Nodes splits. Please do not scold me for the crude painting. ;)

I shall improve it to support the [] operator. Like std::map.
And further improvement would support disk-based B+Tree, more generalized Node Class, etc.

Please let me know your comments, advices, test results or bugs..
It will be a greatly pleasure for me to receive any feedback.

Points of Interest

Making a cool-looking UI is always hard. ;)

History

2008. 9. 16. First upload.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Shin Jin



Korea (Republic Of) Korea (Republic Of)

Member



Sign Up to vote   Poor Excellent
Add a reason or comment to your vote: x
Votes of 3 or less require a comment

Comments and Discussions

 
You must Sign In to use this message board. (secure sign-in)
 
Search this forum  
 FAQ
    Noise  Layout  Per page   
  Refresh
Generalconvert to English Pinmembertvsankar17:24 6 Nov '08  
Questionimplementation ? Pinmemberemilio_grv20:33 16 Sep '08  
From your sources:
	bool Delete(Key k)
	{
		return true;
	}
Calling this an "implementation" seems IMHO excessive !
 
Cosidering also korean comments (completely useless in a site having english as official language) and some other library misconceptions
(like having iterators as member variable returned as references ... asking to have two independent of them is impossible) and some other gotcha...
There's very few to enjoy.
 

2 bugs found.
> recompile ...
65534 bugs found.
D'Oh! | :doh:


AnswerRe: implementation ? PinmemberShin Jin22:07 16 Sep '08  

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Mobile
Web04 | 2.5.120604.1 | Last Updated 16 Sep 2008
Article Copyright 2008 by Shin Jin
Everything else Copyright © CodeProject, 1999-2012
Terms of Use
Layout: fixed | fluid