Click here to Skip to main content
6,629,885 members and growing! (21,143 online)
Email Password   helpLost your password?
Languages » C / C++ Language » Templates     Intermediate License: The Code Project Open License (CPOL)

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

By Shin Jin

B+Tree
C++ (VC6, VC7, VC7.1, VC8.0), C++/CLI, C, Windows (Vista), Visual Studio (VS2008), Dev
Posted:15 Sep 2008
Views:4,317
Bookmarked:4 times
Unedited contribution
Announcements
Loading...
 
Search    
Advanced Search
Add to IE Search
printPrint   add Share
      Discuss Discuss   Broken Article?Report  
6 votes for this article.
Popularity: 1.22 Rating: 1.57 out of 5
4 votes, 66.7%
1
1 vote, 16.7%
2

3

4
1 vote, 16.7%
5

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


Member

Location: Korea, Republic Of Korea, Republic Of

Other popular C / C++ Language articles:

Article Top
You must Sign In to use this message board.
FAQ FAQ 
 
Noise Tolerance  Layout  Per page   
 Msgs 1 to 3 of 3 (Total in Forum: 3) (Refresh)FirstPrevNext
Generalconvert to English Pinmembertvsankar18:24 6 Nov '08  
Generalimplementation ? Pinmemberemilio_grv21:33 16 Sep '08  
GeneralRe: implementation ? PinmemberShin Jin23:07 16 Sep '08  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 15 Sep 2008
Editor: Sean Ewington
Copyright 2008 by Shin Jin
Everything else Copyright © CodeProject, 1999-2009
Web21 | Advertise on the Code Project