public Trie optimize(Trie orig) {List<CharSequence> cmds = orig.cmds;List<Row> rows = new ArrayList<>();List<Row> orows = orig.rows;int remap[] = new int[orows.size()];Arrays.fill(remap, 1);for (int j = orows.size() - 1; j >= 0; j--) {if (eat(orows.get(j), remap)) {remap[j] = 0;}}Arrays.fill(remap, -1);rows = removeGaps(orig.root, orows, new ArrayList<Row>(), remap);return new Trie(orig.forward, remap[orig.root], cmds, rows);}
public override Trie Optimize(Trie orig){IList<string> cmds = orig.cmds;IList<Row> rows = new List<Row>();IList<Row> orows = orig.rows;int[] remap = new int[orows.Count];Arrays.Fill(remap, 1);for (int j = orows.Count - 1; j >= 0; j--){if (Eat(orows[j], remap)){remap[j] = 0;}}Arrays.Fill(remap, -1);rows = RemoveGaps(orig.root, orows, new List<Row>(), remap);return new Trie(orig.forward, remap[orig.root], cmds, rows);}