!7 // not tested on null values sclass FieldIndex implements IConceptIndex { //Concepts concepts; Class cc; S field; new HashMap objectToValue; new MultiMap valueToObject; *() {} *(Concepts concepts, Class *cc, S *field) { concepts.conceptIndices.add(this); for (A c : list(concepts, cc)) update(c); } public synchronized void update(Concept c) { Val newValue = cast cget(c, field); Val oldValue = objectToValue.get(c); if (newValue != oldValue) { valueToObject.remove(oldValue, (A) c); valueToObject.put(newValue, (A) c); objectToValue.put((A) c, newValue); } } public synchronized void remove(Concept c) { Val value = cast cget(c, field); objectToValue.remove(c); valueToObject.remove(value, (A) c); } synchronized A get(Val value) { ret first(valueToObject.get(value)); } synchronized L getAll(Val value) { ret valueToObject.get(value); } } concept CC { S a, b; } p { nu(CC, a := "hello", b := "world"); FieldIndex index = new(mainConcepts, CC, "a"); assertEquals("world", index.get("hello").b); assertNull(index.get("Hello")); print("OK"); }