private Node Register(StringTrieBuilder builder, int start, int limit) { int length = limit - start; #pragma warning disable 612, 618 if (length > builder.MaxBranchLinearSubNodeLength) #pragma warning restore 612, 618 { // Branch on the middle unit. int middle = start + length / 2; return(builder.RegisterNode( new SplitBranchNode( chars[middle], Register(builder, start, middle), Register(builder, middle, limit)))); } ListBranchNode listNode = new ListBranchNode(length); do { char c = chars[start]; Node node = equal[start]; if (node.GetType() == typeof(ValueNode)) { // Final value. listNode.Add(c, ((ValueNode)node).Value); } else { listNode.Add(c, node.Register(builder)); } } while (++start < limit); return(builder.RegisterNode(listNode)); }
public override bool Equals(object other) { if (this == other) { return(true); } if (!base.Equals(other)) { return(false); } ListBranchNode o = (ListBranchNode)other; for (int i = 0; i < length; ++i) { if (units[i] != o.units[i] || values[i] != o.values[i] || equal[i] != o.equal[i]) { return(false); } } return(true); }