Skip to content

Commit 4965c9c

Browse files
committed
Added documentation
1 parent 5521d01 commit 4965c9c

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

Ternary Search Tree/TSTNode.swift

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,42 @@
88

99
import Foundation
1010

11+
/**
12+
This class represents a node in the Ternary Search Tree.
13+
A node has two main data members, the key and the data.
14+
All nodes in a TST must have keys, but only some will have data.
15+
This can be seen in the way the data variable is of Optional type.
16+
*/
1117
class TSTNode<Element> {
1218
//Member properties of a particular node.
19+
20+
/// The key that identifies this node.
1321
var key: Character
22+
/// The data stored in this node. May be `nil`
1423
var data: Element?
24+
/// Boolean flag to depict whether this node holds data or not.
1525
var hasData: Bool
1626

17-
//Children
27+
/// The children of this node
1828
var left: TSTNode?, right: TSTNode?, middle: TSTNode?
1929

20-
30+
/**
31+
Initializer for key and/or data
32+
33+
- parameter key: The key to set for this node.
34+
- parameter data: The optional data to set in this node.
35+
*/
2136
init(key: Character, data: Element?) {
2237
self.key = key
2338
self.data = data
2439
self.hasData = (data != nil)
2540
}
2641

42+
/**
43+
Make a node that only has a key
44+
45+
- parameter key: The key to ascribe to this node.
46+
*/
2747
init(key:Character) {
2848
self.key = key
2949
self.data = nil

0 commit comments

Comments
 (0)