asclass ConceptFieldIndexBase<A extends Concept, Val> implements IConceptIndex, IFieldIndex<A, Val>, IConceptCounter { Concepts concepts; Class<A> cc; S field; new HashMap<A, Val> objectToValue; MultiSetMap<Val, A> valueToObject; // initialized in subclass *() { init(); } *(Class<A> cc, S field) { this(db_mainConcepts(), cc, field); } *(Concepts *concepts, Class<A> *cc, S *field) { this(); concepts.addConceptIndex(this); for (A c : list(concepts, cc)) updateImpl(c); register(); } abstract void init(); abstract void register(); 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); syncPut(objectToValue, (A) c, newValue); } } public synchronized void remove(Concept c) { if (!isInstance(cc, c)) ret; Val value = cast cget(c, field); syncRemove(objectToValue, (A) c); valueToObject.remove(value, (A) c); } synchronized A get(Val value) { ret valueToObject.getFirst(value); } public synchronized Cl<A> getAll(Val value) { ret valueToObject.get(value); } public synchronized L<Val> allValues() { ret cloneKeys_noSync(valueToObject.data); } IterableIterator<A> objectIterator() { ret navigableMultiSetMapValuesIterator_concurrent(valueToObject, this); } public synchronized MultiSet<Val> allValues_multiSet() { ret multiSetMapToMultiSet(valueToObject); } public Class<? extends Concept> conceptClass() { ret cc; } public int countConcepts() { ret l(objectToValue); } public Cl<Concept> allConcepts() { ret (Cl) keys(objectToValue); } O mutex() { this; } }
Began life as a copy of #1031103
download show line numbers debug dex old transpilations
Travelled to 4 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, vouqrxazstgt
No comments. add comment
Snippet ID: | #1031515 |
Snippet name: | ConceptFieldIndexBase (backup) |
Eternal ID of this version: | #1031515/1 |
Text MD5: | 67a2f0c6b2c05d4d4be4a0a5724043f1 |
Author: | stefan |
Category: | javax / concepts |
Type: | JavaX fragment (include) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2021-06-17 07:15:08 |
Source code size: | 1976 bytes / 66 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 138 / 170 |
Referenced in: | [show references] |