addChild method

  1. @override
TrieNode<K, P, V> addChild(
  1. P part
)
override

Adds a new node with the provided part, or returns the existing one.

Implementation

@override
TrieNode<K, P, V> addChild(P part) {
  final index = _binarySearch(part);
  if (index < 0) {
    final node = TrieNodeList<K, P, V>();
    parts.insert(-index - 1, part);
    children.insert(-index - 1, node);
    return node;
  } else {
    return children[index];
  }
}