Publish a B-Tree Code
Code download: http://bluedog.download.csdn.net
B-MSO-ascii-font-family: "> there are not many codes on the tree network. I think there is no need to talk about its principles. There are too many books on the Internet. I spent a few days writing one here. If you think it is useful, you can use it. There have been a lot of tests and there should be no major problems. It is defined by two files: binaryminustree. H "> and binaryminustree. INC ">, you only need to include binaryminustree. H "> just fine.
# Include
"Binaryminustree. H"
These two files define several classes, but the only thing you need to know is cbinaryminustree. The definition of this class is as follows:
"Lang =" En-us "> template <typename TK, typename
TV, size_t thd = 10>
Class9.0pt; font-family: "lang =" En-us "> binaryminustreekey
Tk mso-ascii-font-family: "> key"> value type,
Tvmso-ascii-font-family: "> is Val"> value type,
Thd MSO-ascii-font-family: "> half of the node degree, meaning that if your node degree is 21"> there is a font-family: "lang =" En-us "> 21 font-family:" lang = "En-us"> key value, then font-family: "lang =" En-us "> thd should be font-family:" lang = "En-us"> 10
"Lang =" En-us ">
MSO-ascii-font-family: "> There are several methods:
"Lang =" En-us "> bool add (TK
Key, TV Val); // 9.0pt; font-family:; MSO-ascii-font-family: "> Add a keyfont-family:; MSO-ascii-font-family: "> Value
"Lang =" En-us "> bool
Remove (TK key );
// Font-family:; MSO-ascii-font-family: "> delete a key
"Lang =" En-us "> void
Print (); yes "> // MSO; MSO-ascii-font-family:"> Print tree
Void9.0pt; font-family: "lang =" En-us "> clear ();
// Font-family:; MSO-ascii-font-family: "> delete all data
"Lang =" En-us ">
MSO-ascii-font-family: "> there are several other public members:
"Lang =" En-us "> lpbmtn root; yes"> // MSO-ascii-font-family: "> root node
"Lang =" En-us "> size_t keycount; // Number of keywords
"Lang =" En-us "> size_t level; // number of layers in the tree
Size_t nodecount; // Number of Tree nodes
Other functions are not provided. If you have other users who need them, complete them. Haha.
Note: in fact, the principle of B-tree is very simple, and the algorithm description provided in the book is also very clear. However, it is still a bit difficult to write it well. There are many points to pay attention, the tree goes down accidentally.