public static Automaton build(Collection<BytesRef> input) {final DaciukMihovAutomatonBuilder builder = new DaciukMihovAutomatonBuilder();char[] chars = new char[0];CharsRef ref = new CharsRef();for (BytesRef b : input) {chars = ArrayUtil.grow(chars, b.length);final int len = UnicodeUtil.UTF8toUTF16(b, chars);ref.chars = chars;ref.length = len;builder.add(ref);}Automaton.Builder a = new Automaton.Builder();convert(a,builder.complete(),new IdentityHashMap<State,Integer>());return a.finish();}

public static Automaton Build(ICollection<BytesRef> input){DaciukMihovAutomatonBuilder builder = new DaciukMihovAutomatonBuilder();CharsRef scratch = new CharsRef();foreach (BytesRef b in input){UnicodeUtil.UTF8toUTF16(b, scratch);builder.Add(scratch);}return new Automaton{initial = Convert(builder.Complete(), new JCG.Dictionary<State, Lucene.Net.Util.Automaton.State>(IdentityEqualityComparer<State>.Default)),deterministic = true};}
