# bTree Class Reference

`#include <btree.h>`

## Public Member Functions

| bTree (UbixFS *, fileDescriptor *)
| bTree (const char *, ubixfsInode *)
bool | Delete (const char *)
ubixfsInode * | Find (const char *)
ubixfsInode * | GetFirstNode (bNode *)
ubixfsInode * | GetFirstNode (void)
void | Info (const bNode *)
void | Info (void)
bool | Insert (const char *, ubixfsInode *)
bool | Load (const char *)
void | Print (void)
void | PrintWholeTree (void)
bool | Save (const char *)
bool | Verify (void)
| ~bTree (void)

## Protected Member Functions

bNode * | allocEmptyNode (void)
bNode * | findLeafNode (bNode *, const char *)
ubixfsInode * | inodeSearch (ubixfsInode *, const char *)
void | insertNode (bNode *, const char *, bNode *)
void | Print (bNode *)
void | saveNode (FILE *, bNode *, void *)
void | splitNode (bNode *)
ubixfsInode * | treeSearch (bNode *, const char *)

## Protected Attributes

fileDescriptor * | fd
UbixFS * | fs
bTreeHeader * | header
bNode * | root
uInt32 | tag

## Friends

class | UbixFS

## Detailed Description

Definition at line 37 of file btree.h.

## Constructor & Destructor Documentation

bTree::bTree | ( | const char * | ,
|  | ubixfsInode * |  |
| ) |  |  |

Definition at line 39 of file btree.cpp.

References allocEmptyNode(), assert, B_MAX_NAME_LENGTH, bTreeHeader::firstDeleted, bTreeHeader::firstNodeOffset, header, memset(), NULL, root, strncpy(), tag, bTreeHeader::treeDepth, bTreeHeader::treeLeafCount, and bTreeHeader::treeWidth.

bTree::bTree | ( | UbixFS * | ,
|  | fileDescriptor * |  |
| ) |  |  |

Definition at line 14 of file btree.cpp.

References assert, fd, bTreeHeader::firstNodeOffset, header, memset(), NULL, root, tag, and bTreeHeader::treeLeafCount.

bTree::~bTree | ( | void |  | ) |

Definition at line 763 of file btree.cpp.

References header, bTreeHeader::treeDepth, bTreeHeader::treeLeafCount, and bTreeHeader::treeWidth.

## Member Function Documentation

bNode * bTree::allocEmptyNode | ( | void |  | ) | `[protected]`

Definition at line 444 of file btree.cpp.

References B_NODE_MAGIC_1, B_NODE_MAGIC_2, memset(), NULL, and tag.

Referenced by bTree(), Insert(), and splitNode().

bool bTree::Delete | ( | const char * |  | ) |

Definition at line 726 of file btree.cpp.

References NULL.

ubixfsInode * bTree::Find | ( | const char * |  | ) |

Definition at line 545 of file btree.cpp.

References root, and treeSearch().

Referenced by Insert().

bNode * bTree::findLeafNode | ( | bNode * | ,
|  | const char * |  |
| ) |  |  | `[protected]`

Definition at line 629 of file btree.cpp.

References assert, NULL, and strcmp().

ubixfsInode * bTree::GetFirstNode | ( | bNode * |  | ) |

Definition at line 608 of file btree.cpp.

References NULL.

ubixfsInode * bTree::GetFirstNode | ( | void |  | ) |

Definition at line 603 of file btree.cpp.

References root.

Referenced by main(), Print(), splitNode(), treeSearch(), and Verify().

void bTree::Info | ( | const bNode * |  | ) |

Definition at line 456 of file btree.cpp.

References assert, NULL, and root.

void bTree::Info | ( | void |  | ) |

Definition at line 491 of file btree.cpp.

References assert, header, NULL, root, tag, bTreeHeader::treeDepth, bTreeHeader::treeLeafCount, and bTreeHeader::treeWidth.

Referenced by Print().

ubixfsInode * bTree::inodeSearch | ( | ubixfsInode * | ,
|  | const char * |  |
| ) |  |  | `[protected]`

Definition at line 558 of file btree.cpp.

References NULL, and strcmp().

Referenced by treeSearch().

bool bTree::Insert | ( | const char * | ,
|  | ubixfsInode * |  |
| ) |  |  |

Definition at line 74 of file btree.cpp.

References allocEmptyNode(), assert, B_MAX_NAME_LENGTH, Find(), bTreeHeader::firstDeleted, bTreeHeader::firstNodeOffset, header, memset(), NULL, root, strcmp(), strncpy(), bTreeHeader::treeDepth, bTreeHeader::treeLeafCount, and bTreeHeader::treeWidth.

Referenced by main().

void bTree::insertNode | ( | bNode * | ,
|  | const char * | ,
|  | bNode * |  |
| ) |  |  | `[protected]`

Definition at line 389 of file btree.cpp.

References B_MAX_KEYS, B_MAX_NAME_LENGTH, memset(), NULL, splitNode(), strcmp(), and strncpy().

Referenced by splitNode().

bool bTree::Load | ( | const char * |  | ) |

Definition at line 720 of file btree.cpp.

References NULL.

void bTree::Print | ( | void |  | ) |

Definition at line 536 of file btree.cpp.

References GetFirstNode(), and NULL.

Referenced by Print(), and PrintWholeTree().

void bTree::Print | ( | bNode * |  | ) | `[protected]`

Definition at line 749 of file btree.cpp.

References Info(), NULL, and Print().

void bTree::PrintWholeTree | ( | void |  | ) |

Definition at line 759 of file btree.cpp.

References Print(), and root.

bool bTree::Save | ( | const char * |  | ) |

Definition at line 696 of file btree.cpp.

References assert, fclose(), bTreeHeader::firstDeleted, bTreeHeader::firstNodeOffset, fopen(), fwrite(), header, memset(), NULL, root, saveNode(), and tag.

Referenced by main().

void bTree::saveNode | ( | FILE * | ,
|  | bNode * | ,
|  | void * |  |
| ) |  |  | `[protected]`

Definition at line 651 of file btree.cpp.

References assert, memcpy(), and NULL.

Referenced by Save().

void bTree::splitNode | ( | bNode * |  | ) | `[protected]`

Definition at line 288 of file btree.cpp.

References allocEmptyNode(), assert, B_MAX_KEYS, B_MAX_NAME_LENGTH, GetFirstNode(), header, insertNode(), memcpy(), memset(), NULL, root, strncpy(), and bTreeHeader::treeDepth.

Referenced by insertNode().

ubixfsInode * bTree::treeSearch | ( | bNode * | ,
|  | const char * |  |
| ) |  |  | `[protected]`

Definition at line 578 of file btree.cpp.

References GetFirstNode(), inodeSearch(), NULL, and strcmp().

Referenced by Find().

bool bTree::Verify | ( | void |  | ) |

Definition at line 733 of file btree.cpp.

References GetFirstNode(), fileSystem::next, NULL, and strcmp().

## Friends And Related Function Documentation

friend class UbixFS `[friend]`

Definition at line 68 of file btree.h.

## Field Documentation

fileDescriptor* bTree::fd `[protected]`

Definition at line 42 of file btree.h.

Referenced by bTree().

UbixFS* bTree::fs `[protected]`

Definition at line 40 of file btree.h.

bTreeHeader* bTree::header `[protected]`

Definition at line 41 of file btree.h.

Referenced by bTree(), Info(), Insert(), Save(), splitNode(), and ~bTree().

bNode* bTree::root `[protected]`

Definition at line 39 of file btree.h.

Referenced by bTree(), Find(), GetFirstNode(), Info(), Insert(), PrintWholeTree(), Save(), and splitNode().

uInt32 bTree::tag `[protected]`

Definition at line 43 of file btree.h.

Referenced by allocEmptyNode(), bTree(), Info(), and Save().

The documentation for this class was generated from the following files:

- src/sys/ubixfsv2/btree.h
- src/sys/ubixfsv2/btree.cpp