Package com.ibm.icu.util
Class StringTrieBuilder.LinearMatchNode
java.lang.Object
com.ibm.icu.util.StringTrieBuilder.Node
com.ibm.icu.util.StringTrieBuilder.ValueNode
com.ibm.icu.util.StringTrieBuilder.LinearMatchNode
- Enclosing class:
StringTrieBuilder
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate int
private int
private StringTrieBuilder.Node
private int
private CharSequence
Fields inherited from class com.ibm.icu.util.StringTrieBuilder.ValueNode
hasValue, value
Fields inherited from class com.ibm.icu.util.StringTrieBuilder.Node
offset
-
Constructor Summary
ConstructorsConstructorDescriptionLinearMatchNode
(CharSequence builderStrings, int sOffset, int len, StringTrieBuilder.Node nextNode) -
Method Summary
Modifier and TypeMethodDescriptionadd
(StringTrieBuilder builder, CharSequence s, int start, int sValue) Recursive method for adding a new (string, value) pair.boolean
int
hashCode()
int
markRightEdgesFirst
(int edgeNumber) Traverses the Node graph and numbers branch edges, with rightmost edges first.register
(StringTrieBuilder builder) Recursive method for registering unique nodes, after all (string, value) pairs have been added.private void
void
write
(StringTrieBuilder builder) Methods inherited from class com.ibm.icu.util.StringTrieBuilder.ValueNode
setValue
Methods inherited from class com.ibm.icu.util.StringTrieBuilder.Node
getOffset, writeUnlessInsideRightEdge
-
Field Details
-
strings
-
stringOffset
private int stringOffset -
length
private int length -
next
-
hash
private int hash
-
-
Constructor Details
-
LinearMatchNode
public LinearMatchNode(CharSequence builderStrings, int sOffset, int len, StringTrieBuilder.Node nextNode)
-
-
Method Details
-
hashCode
public int hashCode()- Overrides:
hashCode
in classStringTrieBuilder.ValueNode
-
equals
- Overrides:
equals
in classStringTrieBuilder.ValueNode
-
add
Description copied from class:StringTrieBuilder.Node
Recursive method for adding a new (string, value) pair. Matches the remaining part of s from start, and adds a new node where there is a mismatch.- Overrides:
add
in classStringTrieBuilder.ValueNode
- Returns:
- this or a replacement Node
-
register
Description copied from class:StringTrieBuilder.Node
Recursive method for registering unique nodes, after all (string, value) pairs have been added. Final-value nodes are pre-registered while add()ing (string, value) pairs. Other nodes created while add()ing registerNode() themselves later and might replace themselves with new types of nodes for write()ing.- Overrides:
register
in classStringTrieBuilder.Node
- Returns:
- The registered version of this node which implements write().
-
markRightEdgesFirst
public int markRightEdgesFirst(int edgeNumber) Description copied from class:StringTrieBuilder.Node
Traverses the Node graph and numbers branch edges, with rightmost edges first. This is to avoid writing a duplicate node twice. Branch nodes in this trie data structure are not symmetric. Most branch edges "jump" to other nodes but the rightmost branch edges just continue without a jump. Therefore, write() must write the rightmost branch edge last (trie units are written backwards), and must write it at that point even if it is a duplicate of a node previously written elsewhere. This function visits and marks right branch edges first. Edges are numbered with increasingly negative values because we share the offset field which gets positive values when nodes are written. A branch edge also remembers the first number for any of its edges. When a further-left branch edge has a number in the range of the rightmost edge's numbers, then it will be written as part of the required right edge and we can avoid writing it first. After root.markRightEdgesFirst(-1) the offsets of all nodes are negative edge numbers.- Overrides:
markRightEdgesFirst
in classStringTrieBuilder.Node
- Parameters:
edgeNumber
- The first edge number for this node and its sub-nodes.- Returns:
- An edge number that is at least the maximum-negative of the input edge number and the numbers of this node and all of its sub-nodes.
-
write
- Overrides:
write
in classStringTrieBuilder.ValueNode
-
setHashCode
private void setHashCode()
-