sclass ConceptFieldIndexDesc implements IConceptIndex, IFieldIndex { Class cc; S field; new HashMap objectToValue; MultiMap valueToObject; *() { valueToObject = treeMultiMap(reverseOrder()); } *(Class cc, S field) { this(mainConcepts, cc, field); } *(Concepts concepts, Class *cc, S *field) { this(); concepts.addConceptIndex(this); for (A c : list(concepts, cc)) updateImpl(c); concepts.addFieldIndex(cc, field, this); } public void update(Concept c) { if (!isInstance(cc, c)) ret; updateImpl(c); } synchronized void updateImpl(Concept c) { Val newValue = cast cget(c, field); Val oldValue = objectToValue.get(c); if (newValue == null || newValue != oldValue) { valueToObject.remove(oldValue, (A) c); valueToObject.put(newValue, (A) c); objectToValue.put((A) c, newValue); } } public synchronized void remove(Concept c) { if (!isInstance(cc, c)) ret; Val value = cast cget(c, field); objectToValue.remove(c); valueToObject.remove(value, (A) c); } synchronized A get(Val value) { ret valueToObject.getFirst(value); } public synchronized L getAll(Val value) { ret valueToObject.get(value); } public synchronized L allValues() { ret cloneKeys_noSync(valueToObject.data); } IterableIterator objectIterator() { ret navigableMultiMapValuesIterator(valueToObject); } public synchronized MultiSet allValues_multiSet() { ret multiMapToMultiSet(valueToObject); } }