Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Node ¶
type Node struct {
Val rune // The value of the node
Depth int // The depth of the node in the tree
Count int // Counts the number of branches
Payload interface{} // The payload associated with the node
Child map[rune]*Node // Children of the node, mapped by rune
IsWord bool // Flag indicating if this node marks the end of a complete string
}
type Trie ¶
type Trie struct {
Root *Node
}
func (*Trie) Del ¶
Del deletion of a node has the following cases:
- Prefix deletion: Check if Count is greater than 0, then set IsWord to false.
- String deletion: a. If there is no branching, delete the entire string. b. If there is branching, only delete the part that is not a common prefix.
Click to show internal directories.
Click to hide internal directories.