!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) { O newValue = cget(c, field); O oldValue = objectToValue.get(c); if (newValue != oldValue) { valueToObject.remove(oldValue, c); valueToObject.add(newValue, c); objectToValue.put(c, value); } } public synchronized void remove(Concept c) { O value = cget(c, field); objectToValue.remove(c); valueToObject.remove(value, c); } synchronized A get(Val value) { ret first(valuesToObject.get(value)); } synchronized L getAll(Val value) { ret valuesToObject.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"); }