sinterface IMultiSet extends IntSize {
// returns new count
int add(A key);
/*void addAll(Iterable c) {
if (c != null) for (A a : c) add(a);
}
void addAll(MultiSet ms) {
for (A a : ms.keySet()) add(a, ms.get(a));
}*/
//int add(A key, int count);
//void put(A key, int count);
int get(A key);
//bool contains(A key);
//void remove(A key);
/*List topTen();
synchronized List getTopTen() { ret getTopTen(10); }
synchronized List getTopTen(int maxSize) {
List list = getSortedListDescending();
return list.size() > maxSize ? list.subList(0, maxSize) : list;
}
synchronized L highestFirst() {
ret getSortedListDescending();
}
synchronized L lowestFirst() {
ret reversedList(getSortedListDescending());
}
synchronized L getSortedListDescending() {
List list = new ArrayList(map.keySet());
Collections.sort(list, new Comparator() {
public int compare(A a, A b) {
return map.get(b).compareTo(map.get(a));
}
});
ret list;
}
synchronized int getNumberOfUniqueElements() {
return map.size();
}
synchronized int uniqueSize() {
ret map.size();
}
synchronized Set asSet() {
return map.keySet();
}
synchronized NavigableSet navigableSet() {
return navigableKeys((NavigableMap) map);
}
synchronized A getMostPopularEntry() {
int max = 0;
A a = null;
for (Map.Entry entry : map.entrySet()) {
if (entry.getValue() > max) {
max = entry.getValue();
a = entry.getKey();
}
}
return a;
}
synchronized void removeAll(A key) {
size -= get(key);
map.remove(key);
}
synchronized int size() {
ret size;
}
synchronized MultiSet mergeWith(MultiSet set) {
MultiSet result = new MultiSet();
for (A a : set.asSet()) {
result.add(a, set.get(a));
}
return result;
}
synchronized boolean isEmpty() {
return map.isEmpty();
}
synchronized public String toString() { // hmm. sync this?
return str(map);
}
synchronized void clear() {
map.clear();
size = 0;
}
synchronized Map asMap() {
ret cloneMap(map);
}*/
Set keySet();
}