dictionary.go
func (dict *Dictionary) Remove(word string) (wasRemoved bool) {
	lastPos := len(word) - 1
	parent := dict.root.Navigate(word[:lastPos])
	if parent == nil {
		return
	}

	lastLetter := rune(word[lastPos])

	subject, ok := parent.Children[lastLetter]
	if !ok {
		return
	}

	wasRemoved = subject.IsWord

	if wasRemoved {
		dict.size--
	}

	subject.IsWord = false
	if subject.Population() == 0 {
		delete(parent.Children, lastLetter)
	}
	return
}
func (dict *Dictionary) Remove(word string) (wasRemoved bool) {
	lastPos := len(word) - 1
	parent := dict.root.Navigate(word[:lastPos])
	if parent == nil {
		return
	}

	lastLetter := rune(word[lastPos])

	subject, ok := parent.Children[lastLetter]
	if !ok {
		return
	}

	wasRemoved = subject.IsWord

	if wasRemoved {
		dict.size--
	}

	subject.IsWord = false
	if subject.Population() == 0 {
		delete(parent.Children, lastLetter)
	}
	return
}
func ( dict * Dictionary ) Remove ( word string ) ( wasRemoved bool ) { lastPos := len ( word ) - 1 parent := dict . root . Navigate ( word [ : lastPos ] ) if parent == nil { return } lastLetter := rune ( word [ lastPos ] ) subject , ok := parent . Children [ lastLetter ] if ! ok { return } wasRemoved = subject . IsWord if wasRemoved { dict . size -- } subject . IsWord = false if subject . Population ( ) == 0 { delete ( parent . Children , lastLetter ) } return }
// Remove ensures that `word` is not in the Dictionary. Returns whether or not an item was removed.
//
// Time complexity: O(m) where 'm' is the length of word.
Remove ensures that word is not in the Dictionary . Returns whether or not an item was removed . Time complexity : O ( m ) where m is the length of word .