@Test public void dictionaryContainTest() { ArrayList<String> str = new ArrayList<String>(); str.add("part"); str.add("part"); str.add("par"); str.add("partition"); str.add("party"); str.add("parties"); str.add("paint"); Collections.sort(str, new ByteComparator<String>(new StringBytesConverter())); int baseId = new Random().nextInt(100); TrieDictionaryForestBuilder<String> b = newDictBuilder(str, baseId); TrieDictionaryForest<String> dict = b.build(); str.add("py"); Collections.sort(str, new ByteComparator<String>(new StringBytesConverter())); b = newDictBuilder(str, baseId); baseId = new Random().nextInt(100); TrieDictionaryForest<String> dict2 = b.build(); assertEquals(true, dict2.contains(dict)); assertEquals(false, dict.contains(dict2)); }
@Override public boolean contains(Dictionary other) { if (other.getSize() > this.getSize()) { return false; } for (int i = other.getMinId(); i <= other.getMaxId(); ++i) { T v = (T) other.getValueFromId(i); if (!this.containsValue(v)) { return false; } } return true; }
TrieDictionaryForest extends CacheDictionary<T> { @Override public boolean contains(Dictionary other) { if (other.getSize() > this.getSize()) { return false; } for (int i = other.getMinId(); i <= other.getMaxId(); ++i) { T v = (T) other.getValueFromId(i); if (!this.containsValue(v)) { return false; } } return true; } }
TrieDictionaryForest extends CacheDictionary<T> { @Override public boolean contains(Dictionary other) { if (other.getSize() > this.getSize()) { return false; } for (int i = other.getMinId(); i <= other.getMaxId(); ++i) { T v = (T) other.getValueFromId(i); if (!this.containsValue(v)) { return false; } } return true; } TrieDictionaryForest();  TrieDictionaryForest(ArrayList<TrieDictionary<T>> trees, ArrayList<ByteArray> valueDivide, //
                                ArrayList<Integer> accuOffset, BytesConverter<T> bytesConverter, int baseId); }
TrieDictionaryForest extends CacheDictionary<T> { @Override public boolean contains(Dictionary other) { if (other.getSize() > this.getSize()) { return false; } for (int i = other.getMinId(); i <= other.getMaxId(); ++i) { T v = (T) other.getValueFromId(i); if (!this.containsValue(v)) { return false; } } return true; } TrieDictionaryForest();  TrieDictionaryForest(ArrayList<TrieDictionary<T>> trees, ArrayList<ByteArray> valueDivide, //
                                ArrayList<Integer> accuOffset, BytesConverter<T> bytesConverter, int baseId); @Override int getMinId(); @Override int getMaxId(); @Override int getSizeOfId(); @Override int getSizeOfValue(); @Override void dump(PrintStream out); @Override void write(DataOutput out); @Override void readFields(DataInput in); @Override boolean contains(Dictionary other); @Override int hashCode(); @Override boolean equals(Object obj); }
TrieDictionaryForest extends CacheDictionary<T> { @Override public boolean contains(Dictionary other) { if (other.getSize() > this.getSize()) { return false; } for (int i = other.getMinId(); i <= other.getMaxId(); ++i) { T v = (T) other.getValueFromId(i); if (!this.containsValue(v)) { return false; } } return true; } TrieDictionaryForest();  TrieDictionaryForest(ArrayList<TrieDictionary<T>> trees, ArrayList<ByteArray> valueDivide, //
                                ArrayList<Integer> accuOffset, BytesConverter<T> bytesConverter, int baseId); @Override int getMinId(); @Override int getMaxId(); @Override int getSizeOfId(); @Override int getSizeOfValue(); @Override void dump(PrintStream out); @Override void write(DataOutput out); @Override void readFields(DataInput in); @Override boolean contains(Dictionary other); @Override int hashCode(); @Override boolean equals(Object obj);  }