Skip to content

Commit 6db2dd7

Browse files
authored
updated README.md
1 parent 7f71ac7 commit 6db2dd7

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

B-Tree/README.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,9 @@ A second order B-Tree with keys from 1 to 20 looks like this:
2020

2121
```swift
2222
class BTreeNode<Key: Comparable, Value> {
23-
unowned var ownerTree: BTree<Key, Value>
23+
unowned var owner: BTree<Key, Value>
2424

25-
private var keys = [Key]()
25+
fileprivate var keys = [Key]()
2626
var children: [BTreeNode]?
2727

2828
...
@@ -55,7 +55,7 @@ This is necessary because nodes have to know the order of the tree.
5555

5656
### The code
5757

58-
`valueForKey(_:)` method searches for the given key and if it's in the tree,
58+
`value(for:)` method searches for the given key and if it's in the tree,
5959
it returns the value associated with it, else it returns `nil`.
6060

6161
## Insertion
@@ -72,7 +72,7 @@ Keys can only be inserted to leaf nodes.
7272
After insertion we should check if the number of keys in the node is in the correct range.
7373
If there are more keys in the node than `order*2`, we need to split the node.
7474

75-
####Splitting a node
75+
#### Splitting a node
7676

7777
1. Move up the middle key of the node we want to split, to its parent (if it has one).
7878
2. If it hasn't got a parent(it is the root), then create a new root and insert to it.
@@ -90,9 +90,9 @@ An insertion to a first order tree looks like this:
9090

9191
### The code
9292

93-
The method `insertValue(_:forKey:)` does the insertion.
93+
The method `insert(_:for:)` does the insertion.
9494
After it has inserted a key, as the recursion goes up every node checks the number of keys in its child.
95-
if a node has too many keys, its parent calls the `splitChild(_:atIndex:)` method on it.
95+
if a node has too many keys, its parent calls the `split(child:atIndex:)` method on it.
9696

9797
The root node is checked by the tree itself.
9898
If the root has too many nodes after the insertion the tree calls the `splitRoot()` method.
@@ -112,7 +112,7 @@ After a key have been removed from a node we should check that the node has enou
112112
If a node has fewer keys than the order of the tree, then we should move a key to it,
113113
or merge it with one of its siblings.
114114

115-
####Moving a key to the child
115+
#### Moving a key to the child
116116

117117
If the problematic node has a nearest sibling that has more keys than the order of the tree,
118118
we should perform this operation on the tree, else we should merge the node with one of its siblings.
@@ -156,13 +156,13 @@ so in the worst case merging also can go up to the root, in which case the heigh
156156

157157
### The code
158158

159-
- `removeKey(_:)` method removes the given key from the tree. After a key has been deleted,
159+
- `remove(_:)` method removes the given key from the tree. After a key has been deleted,
160160
every node checks the number of keys in its child. If a child has less nodes than the order of the tree,
161-
it calls the `fixChildWithLessNodesThanOrder(_:atIndex:)` method.
161+
it calls the `fix(childWithTooFewKeys:atIndex:)` method.
162162

163-
- `fixChildWithLessNodesThanOrder(_:atIndex:)` method decides which way to fix the child (by moving a key to it,
164-
or by merging it), then calls `moveKeyAtIndex(keyIndex:toNode:fromNode:atPosition:)` or
165-
`mergeChild(_:withIndex:toNodeAtPosition:)` method according to its choice.
163+
- `fix(childWithTooFewKeys:atIndex:)` method decides which way to fix the child (by moving a key to it,
164+
or by merging it), then calls `move(keyAtIndex:to:from:at:)` or
165+
`merge(child:atIndex:to:)` method according to its choice.
166166

167167
## See also
168168

0 commit comments

Comments
 (0)