|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectjava.util.AbstractMap<K,V>
java.util.HashMap<K,int[]>
com.samskivert.util.CountHashMap<K>
public class CountHashMap<K>
A hashmap that maintains a count for each key. This implementation should change so that we extend AbstractMap, do our own hashing, and can use our own Entry class.
| Nested Class Summary | |
|---|---|
protected static class |
CountHashMap.CountEntryImpl<K>
|
protected class |
CountHashMap.CountEntrySet<E>
|
static interface |
CountHashMap.Entry<K>
|
| Constructor Summary | |
|---|---|
CountHashMap()
|
|
| Method Summary | |
|---|---|
void |
compress()
Compress the count map- remove entries for which the value is 0. |
Set<CountHashMap.Entry<K>> |
countEntrySet()
Returns a set of CountHashMap.Entry records which can be used to easily obtain our count. |
Set<Map.Entry<K,int[]>> |
entrySet()
|
int |
getCount(K key)
Get the count associated with the specified key. |
int |
getTotalCount()
Get the total count for all keys in the map. |
int |
incrementCount(K key,
int amount)
Increment the value associated with the specified key, return the new value. |
int |
setCount(K key,
int count)
Set the count for the specified key. |
| Methods inherited from class java.util.HashMap |
|---|
clear, clone, containsKey, containsValue, get, isEmpty, keySet, put, putAll, remove, size, values |
| Methods inherited from class java.util.AbstractMap |
|---|
equals, hashCode, toString |
| Methods inherited from class java.lang.Object |
|---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.Map |
|---|
equals, hashCode |
| Constructor Detail |
|---|
public CountHashMap()
| Method Detail |
|---|
public int incrementCount(K key,
int amount)
public int getCount(K key)
public int setCount(K key,
int count)
public int getTotalCount()
public void compress()
public Set<Map.Entry<K,int[]>> entrySet()
entrySet in interface Map<K,int[]>entrySet in class HashMap<K,int[]>public Set<CountHashMap.Entry<K>> countEntrySet()
CountHashMap.Entry records which can be used to easily obtain our count.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||