| Modifier and Type | Class and Description |
|---|---|
| protected class | SegmentConstantPoolArrayCache.CachedArray
CachedArray keeps track of the last known size of an array as well as a HashMap that knows the mapping from element values to the indices of the array which contain that value. |
| Modifier and Type | Field and Description |
|---|---|
| protected IdentityHashMap | |
| protected String[] | |
| protected List | |
| protected String |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected boolean | Returns: boolean true if up-to-date cache, otherwise false.of String array)Given a String array, answer true if the array is correctly cached. |
| protected void | |
| public List | Returns: List collection of index positions in the arrayString[] array to search for the value array, final String String value for which to search key)Answer the indices for the given key in the given array. |
| knownArrays | back to summary |
|---|---|
| protected IdentityHashMap<String[], SegmentConstantPoolArrayCache. | |
| lastArray | back to summary |
|---|---|
| protected String[] lastArray | |
| lastIndexes | back to summary |
|---|---|
| protected List<Integer> lastIndexes | |
| lastKey | back to summary |
|---|---|
| protected String lastKey | |
| SegmentConstantPoolArrayCache | back to summary |
|---|---|
| public SegmentConstantPoolArrayCache() | |
| arrayIsCached | back to summary |
|---|---|
| protected boolean arrayIsCached(final String[] array) Given a String array, answer true if the array is correctly cached. Answer false if the array is not cached, or if the array cache is outdated.
| |
| cacheArray | back to summary |
|---|---|
| protected void cacheArray(final String[] array) Cache the array passed in as the argument
| |
| indexesForArrayKey | back to summary |
|---|---|
| public List Answer the indices for the given key in the given array. If no such key exists in the cached array, answer -1. | |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv int | |
| pack-priv String[] | |
| pack-priv HashMap |
| Access | Constructor and Description |
|---|---|
| public |
| Modifier and Type | Method and Description |
|---|---|
| protected void | cacheIndexes()
Given a primaryArray, cache its values in a HashMap to provide a backwards mapping from element values to element indexes. |
| public List | Returns: List of indexes containing that key in the array.String element of the array key)Given a particular key, answer a List of index locations in the array which contain that key. |
| public int | Returns: int last known size of the cached arrayAnswer the last known size of the array cached. |
| lastKnownSize | back to summary |
|---|---|
| pack-priv int lastKnownSize | |
| primaryArray | back to summary |
|---|---|
| pack-priv String[] primaryArray | |
| primaryTable | back to summary |
|---|---|
| pack-priv HashMap<String, List<Integer>> primaryTable | |
| CachedArray | back to summary |
|---|---|
| public CachedArray(final String[] array) | |
| cacheIndexes | back to summary |
|---|---|
| protected void cacheIndexes() Given a primaryArray, cache its values in a HashMap to provide a backwards mapping from element values to element indexes. For instance, a primaryArray of: {"Zero", "Foo", "Two", "Foo"} would yield a HashMap of: "Zero" -> 0 "Foo" -> 1, 3 "Two" -> 2 which is then cached. | |
| indexesForKey | back to summary |
|---|---|
| public List Given a particular key, answer a List of index locations in the array which contain that key. If no elements are found, answer an empty list. | |
| lastKnownSize | back to summary |
|---|---|
| public int lastKnownSize() Answer the last known size of the array cached. If the last known size is not the same as the current size, the array must have changed.
| |