// as long as you don't access the by-numeral-index functions, // you can add and remove elements quickly. // upon accessing the list, it is updated once to fit the new data sclass ProbabilisticList extends AbstractRandomAccessList> { // these are the 2 main data structures we update Map probabilities = hashMap(); MultiSetMap byProbability = multiSetMap_outerDescTreeMap_innerLinkedHashSet(); L> renderedAsList; // this is only updated when requested public WithProbability get(int idx) { makeListUpToIndex(idx); ret renderedAsList.get(idx); } public int size() { ret l(probabilities); } }