public void build(InputIterator iterator) throws IOException {if (iterator.hasPayloads()) {throw new IllegalArgumentException("this suggester doesn't support payloads");}if (iterator.hasContexts()) {throw new IllegalArgumentException("this suggester doesn't support contexts");}root = new TernaryTreeNode();iterator = new SortedInputIterator(tempDir, tempFileNamePrefix, iterator, utf8SortedAsUTF16SortOrder);count = 0;ArrayList<String> tokens = new ArrayList<>();ArrayList<Number> vals = new ArrayList<>();BytesRef spare;CharsRefBuilder charsSpare = new CharsRefBuilder();while ((spare = iterator.next()) != null) {charsSpare.copyUTF8Bytes(spare);tokens.add(charsSpare.toString());vals.add(Long.valueOf(iterator.weight()));count++;}autocomplete.balancedTree(tokens.toArray(), vals.toArray(), 0, tokens.size() - 1, root);}

public override void Build(IInputIterator tfit){if (tfit.HasPayloads){throw new System.ArgumentException("this suggester doesn't support payloads");}if (tfit.HasContexts){throw new System.ArgumentException("this suggester doesn't support contexts");}root = new TernaryTreeNode();#pragma warning disable 612, 618if (tfit.Comparer != BytesRef.UTF8SortedAsUTF16Comparer){tfit = new SortedInputIterator(tfit, BytesRef.UTF8SortedAsUTF16Comparer);}#pragma warning restore 612, 618List<string> tokens = new List<string>();List<object> vals = new List<object>();BytesRef spare;CharsRef charsSpare = new CharsRef();while ((spare = tfit.Next()) != null){charsSpare.Grow(spare.Length);UnicodeUtil.UTF8toUTF16(spare.Bytes, spare.Offset, spare.Length, charsSpare);tokens.Add(charsSpare.ToString());vals.Add(tfit.Weight);}autocomplete.BalancedTree(tokens.ToArray(), vals.ToArray(), 0, tokens.Count - 1, root);}
