| Method from org.apache.commons.collections.map.MultiKeyMap Detail: |
protected void checkKey(Object key) {
if (key == null) {
throw new NullPointerException("Key must not be null");
}
if (key instanceof MultiKey == false) {
throw new ClassCastException("Key must be a MultiKey");
}
}
Check to ensure that input keys are valid MultiKey objects. |
public void clear() {
map.clear();
}
|
public Object clone() {
return new MultiKeyMap((AbstractHashedMap) map.clone());
}
Clones the map without cloning the keys or values. |
public boolean containsKey(Object key) {
return map.containsKey(key);
}
|
public boolean containsKey(Object key1,
Object key2) {
int hashCode = hash(key1, key2);
AbstractHashedMap.HashEntry entry = map.data[map.hashIndex(hashCode, map.data.length)];
while (entry != null) {
if (entry.hashCode == hashCode && isEqualKey(entry, key1, key2)) {
return true;
}
entry = entry.next;
}
return false;
}
Checks whether the map contains the specified multi-key. |
public boolean containsKey(Object key1,
Object key2,
Object key3) {
int hashCode = hash(key1, key2, key3);
AbstractHashedMap.HashEntry entry = map.data[map.hashIndex(hashCode, map.data.length)];
while (entry != null) {
if (entry.hashCode == hashCode && isEqualKey(entry, key1, key2, key3)) {
return true;
}
entry = entry.next;
}
return false;
}
Checks whether the map contains the specified multi-key. |
public boolean containsKey(Object key1,
Object key2,
Object key3,
Object key4) {
int hashCode = hash(key1, key2, key3, key4);
AbstractHashedMap.HashEntry entry = map.data[map.hashIndex(hashCode, map.data.length)];
while (entry != null) {
if (entry.hashCode == hashCode && isEqualKey(entry, key1, key2, key3, key4)) {
return true;
}
entry = entry.next;
}
return false;
}
Checks whether the map contains the specified multi-key. |
public boolean containsKey(Object key1,
Object key2,
Object key3,
Object key4,
Object key5) {
int hashCode = hash(key1, key2, key3, key4, key5);
AbstractHashedMap.HashEntry entry = map.data[map.hashIndex(hashCode, map.data.length)];
while (entry != null) {
if (entry.hashCode == hashCode && isEqualKey(entry, key1, key2, key3, key4, key5)) {
return true;
}
entry = entry.next;
}
return false;
}
Checks whether the map contains the specified multi-key. |
public boolean containsValue(Object value) {
return map.containsValue(value);
}
|
public static MultiKeyMap decorate(AbstractHashedMap map) {
//-----------------------------------------------------------------------
if (map == null) {
throw new IllegalArgumentException("Map must not be null");
}
if (map.size() > 0) {
throw new IllegalArgumentException("Map must be empty");
}
return new MultiKeyMap(map);
}
Decorates the specified map to add the MultiKeyMap API and fast query.
The map must not be null and must be empty. |
public Set entrySet() {
return map.entrySet();
}
|
public boolean equals(Object obj) {
if (obj == this) {
return true;
}
return map.equals(obj);
}
|
public Object get(Object key) {
return map.get(key);
}
|
public Object get(Object key1,
Object key2) {
int hashCode = hash(key1, key2);
AbstractHashedMap.HashEntry entry = map.data[map.hashIndex(hashCode, map.data.length)];
while (entry != null) {
if (entry.hashCode == hashCode && isEqualKey(entry, key1, key2)) {
return entry.getValue();
}
entry = entry.next;
}
return null;
}
Gets the value mapped to the specified multi-key. |
public Object get(Object key1,
Object key2,
Object key3) {
int hashCode = hash(key1, key2, key3);
AbstractHashedMap.HashEntry entry = map.data[map.hashIndex(hashCode, map.data.length)];
while (entry != null) {
if (entry.hashCode == hashCode && isEqualKey(entry, key1, key2, key3)) {
return entry.getValue();
}
entry = entry.next;
}
return null;
}
Gets the value mapped to the specified multi-key. |
public Object get(Object key1,
Object key2,
Object key3,
Object key4) {
int hashCode = hash(key1, key2, key3, key4);
AbstractHashedMap.HashEntry entry = map.data[map.hashIndex(hashCode, map.data.length)];
while (entry != null) {
if (entry.hashCode == hashCode && isEqualKey(entry, key1, key2, key3, key4)) {
return entry.getValue();
}
entry = entry.next;
}
return null;
}
Gets the value mapped to the specified multi-key. |
public Object get(Object key1,
Object key2,
Object key3,
Object key4,
Object key5) {
int hashCode = hash(key1, key2, key3, key4, key5);
AbstractHashedMap.HashEntry entry = map.data[map.hashIndex(hashCode, map.data.length)];
while (entry != null) {
if (entry.hashCode == hashCode && isEqualKey(entry, key1, key2, key3, key4, key5)) {
return entry.getValue();
}
entry = entry.next;
}
return null;
}
Gets the value mapped to the specified multi-key. |
protected int hash(Object key1,
Object key2) {
int h = 0;
if (key1 != null) {
h ^= key1.hashCode();
}
if (key2 != null) {
h ^= key2.hashCode();
}
h += ~(h < < 9);
h ^= (h > > > 14);
h += (h < < 4);
h ^= (h > > > 10);
return h;
}
Gets the hash code for the specified multi-key. |
protected int hash(Object key1,
Object key2,
Object key3) {
int h = 0;
if (key1 != null) {
h ^= key1.hashCode();
}
if (key2 != null) {
h ^= key2.hashCode();
}
if (key3 != null) {
h ^= key3.hashCode();
}
h += ~(h < < 9);
h ^= (h > > > 14);
h += (h < < 4);
h ^= (h > > > 10);
return h;
}
Gets the hash code for the specified multi-key. |
protected int hash(Object key1,
Object key2,
Object key3,
Object key4) {
int h = 0;
if (key1 != null) {
h ^= key1.hashCode();
}
if (key2 != null) {
h ^= key2.hashCode();
}
if (key3 != null) {
h ^= key3.hashCode();
}
if (key4 != null) {
h ^= key4.hashCode();
}
h += ~(h < < 9);
h ^= (h > > > 14);
h += (h < < 4);
h ^= (h > > > 10);
return h;
}
Gets the hash code for the specified multi-key. |
protected int hash(Object key1,
Object key2,
Object key3,
Object key4,
Object key5) {
int h = 0;
if (key1 != null) {
h ^= key1.hashCode();
}
if (key2 != null) {
h ^= key2.hashCode();
}
if (key3 != null) {
h ^= key3.hashCode();
}
if (key4 != null) {
h ^= key4.hashCode();
}
if (key5 != null) {
h ^= key5.hashCode();
}
h += ~(h < < 9);
h ^= (h > > > 14);
h += (h < < 4);
h ^= (h > > > 10);
return h;
}
Gets the hash code for the specified multi-key. |
public int hashCode() {
return map.hashCode();
}
|
public boolean isEmpty() {
return map.isEmpty();
}
|
protected boolean isEqualKey(AbstractHashedMap.HashEntry entry,
Object key1,
Object key2) {
MultiKey multi = (MultiKey) entry.getKey();
return
multi.size() == 2 &&
(key1 == null ? multi.getKey(0) == null : key1.equals(multi.getKey(0))) &&
(key2 == null ? multi.getKey(1) == null : key2.equals(multi.getKey(1)));
}
Is the key equal to the combined key. |
protected boolean isEqualKey(AbstractHashedMap.HashEntry entry,
Object key1,
Object key2,
Object key3) {
MultiKey multi = (MultiKey) entry.getKey();
return
multi.size() == 3 &&
(key1 == null ? multi.getKey(0) == null : key1.equals(multi.getKey(0))) &&
(key2 == null ? multi.getKey(1) == null : key2.equals(multi.getKey(1))) &&
(key3 == null ? multi.getKey(2) == null : key3.equals(multi.getKey(2)));
}
Is the key equal to the combined key. |
protected boolean isEqualKey(AbstractHashedMap.HashEntry entry,
Object key1,
Object key2,
Object key3,
Object key4) {
MultiKey multi = (MultiKey) entry.getKey();
return
multi.size() == 4 &&
(key1 == null ? multi.getKey(0) == null : key1.equals(multi.getKey(0))) &&
(key2 == null ? multi.getKey(1) == null : key2.equals(multi.getKey(1))) &&
(key3 == null ? multi.getKey(2) == null : key3.equals(multi.getKey(2))) &&
(key4 == null ? multi.getKey(3) == null : key4.equals(multi.getKey(3)));
}
Is the key equal to the combined key. |
protected boolean isEqualKey(AbstractHashedMap.HashEntry entry,
Object key1,
Object key2,
Object key3,
Object key4,
Object key5) {
MultiKey multi = (MultiKey) entry.getKey();
return
multi.size() == 5 &&
(key1 == null ? multi.getKey(0) == null : key1.equals(multi.getKey(0))) &&
(key2 == null ? multi.getKey(1) == null : key2.equals(multi.getKey(1))) &&
(key3 == null ? multi.getKey(2) == null : key3.equals(multi.getKey(2))) &&
(key4 == null ? multi.getKey(3) == null : key4.equals(multi.getKey(3))) &&
(key5 == null ? multi.getKey(4) == null : key5.equals(multi.getKey(4)));
}
Is the key equal to the combined key. |
public Set keySet() {
return map.keySet();
}
|
public MapIterator mapIterator() {
return map.mapIterator();
}
|
public Object put(Object key,
Object value) {
checkKey(key);
return map.put(key, value);
}
Puts the key and value into the map, where the key must be a non-null
MultiKey object. |
public Object put(Object key1,
Object key2,
Object value) {
int hashCode = hash(key1, key2);
int index = map.hashIndex(hashCode, map.data.length);
AbstractHashedMap.HashEntry entry = map.data[index];
while (entry != null) {
if (entry.hashCode == hashCode && isEqualKey(entry, key1, key2)) {
Object oldValue = entry.getValue();
map.updateEntry(entry, value);
return oldValue;
}
entry = entry.next;
}
map.addMapping(index, hashCode, new MultiKey(key1, key2), value);
return null;
}
Stores the value against the specified multi-key. |
public Object put(Object key1,
Object key2,
Object key3,
Object value) {
int hashCode = hash(key1, key2, key3);
int index = map.hashIndex(hashCode, map.data.length);
AbstractHashedMap.HashEntry entry = map.data[index];
while (entry != null) {
if (entry.hashCode == hashCode && isEqualKey(entry, key1, key2, key3)) {
Object oldValue = entry.getValue();
map.updateEntry(entry, value);
return oldValue;
}
entry = entry.next;
}
map.addMapping(index, hashCode, new MultiKey(key1, key2, key3), value);
return null;
}
Stores the value against the specified multi-key. |
public Object put(Object key1,
Object key2,
Object key3,
Object key4,
Object value) {
int hashCode = hash(key1, key2, key3, key4);
int index = map.hashIndex(hashCode, map.data.length);
AbstractHashedMap.HashEntry entry = map.data[index];
while (entry != null) {
if (entry.hashCode == hashCode && isEqualKey(entry, key1, key2, key3, key4)) {
Object oldValue = entry.getValue();
map.updateEntry(entry, value);
return oldValue;
}
entry = entry.next;
}
map.addMapping(index, hashCode, new MultiKey(key1, key2, key3, key4), value);
return null;
}
Stores the value against the specified multi-key. |
public Object put(Object key1,
Object key2,
Object key3,
Object key4,
Object key5,
Object value) {
int hashCode = hash(key1, key2, key3, key4, key5);
int index = map.hashIndex(hashCode, map.data.length);
AbstractHashedMap.HashEntry entry = map.data[index];
while (entry != null) {
if (entry.hashCode == hashCode && isEqualKey(entry, key1, key2, key3, key4, key5)) {
Object oldValue = entry.getValue();
map.updateEntry(entry, value);
return oldValue;
}
entry = entry.next;
}
map.addMapping(index, hashCode, new MultiKey(key1, key2, key3, key4, key5), value);
return null;
}
Stores the value against the specified multi-key. |
public void putAll(Map mapToCopy) {
for (Iterator it = mapToCopy.keySet().iterator(); it.hasNext();) {
Object key = it.next();
checkKey(key);
}
map.putAll(mapToCopy);
}
Copies all of the keys and values from the specified map to this map.
Each key must be non-null and a MultiKey object. |
public Object remove(Object key) {
return map.remove(key);
}
|
public Object remove(Object key1,
Object key2) {
int hashCode = hash(key1, key2);
int index = map.hashIndex(hashCode, map.data.length);
AbstractHashedMap.HashEntry entry = map.data[index];
AbstractHashedMap.HashEntry previous = null;
while (entry != null) {
if (entry.hashCode == hashCode && isEqualKey(entry, key1, key2)) {
Object oldValue = entry.getValue();
map.removeMapping(entry, index, previous);
return oldValue;
}
previous = entry;
entry = entry.next;
}
return null;
}
Removes the specified multi-key from this map. |
public Object remove(Object key1,
Object key2,
Object key3) {
int hashCode = hash(key1, key2, key3);
int index = map.hashIndex(hashCode, map.data.length);
AbstractHashedMap.HashEntry entry = map.data[index];
AbstractHashedMap.HashEntry previous = null;
while (entry != null) {
if (entry.hashCode == hashCode && isEqualKey(entry, key1, key2, key3)) {
Object oldValue = entry.getValue();
map.removeMapping(entry, index, previous);
return oldValue;
}
previous = entry;
entry = entry.next;
}
return null;
}
Removes the specified multi-key from this map. |
public Object remove(Object key1,
Object key2,
Object key3,
Object key4) {
int hashCode = hash(key1, key2, key3, key4);
int index = map.hashIndex(hashCode, map.data.length);
AbstractHashedMap.HashEntry entry = map.data[index];
AbstractHashedMap.HashEntry previous = null;
while (entry != null) {
if (entry.hashCode == hashCode && isEqualKey(entry, key1, key2, key3, key4)) {
Object oldValue = entry.getValue();
map.removeMapping(entry, index, previous);
return oldValue;
}
previous = entry;
entry = entry.next;
}
return null;
}
Removes the specified multi-key from this map. |
public Object remove(Object key1,
Object key2,
Object key3,
Object key4,
Object key5) {
int hashCode = hash(key1, key2, key3, key4, key5);
int index = map.hashIndex(hashCode, map.data.length);
AbstractHashedMap.HashEntry entry = map.data[index];
AbstractHashedMap.HashEntry previous = null;
while (entry != null) {
if (entry.hashCode == hashCode && isEqualKey(entry, key1, key2, key3, key4, key5)) {
Object oldValue = entry.getValue();
map.removeMapping(entry, index, previous);
return oldValue;
}
previous = entry;
entry = entry.next;
}
return null;
}
Removes the specified multi-key from this map. |
public boolean removeAll(Object key1) {
boolean modified = false;
MapIterator it = mapIterator();
while (it.hasNext()) {
MultiKey multi = (MultiKey) it.next();
if (multi.size() >= 1 &&
(key1 == null ? multi.getKey(0) == null : key1.equals(multi.getKey(0)))) {
it.remove();
modified = true;
}
}
return modified;
}
Removes all mappings where the first key is that specified.
This method removes all the mappings where the MultiKey
has one or more keys, and the first matches that specified. |
public boolean removeAll(Object key1,
Object key2) {
boolean modified = false;
MapIterator it = mapIterator();
while (it.hasNext()) {
MultiKey multi = (MultiKey) it.next();
if (multi.size() >= 2 &&
(key1 == null ? multi.getKey(0) == null : key1.equals(multi.getKey(0))) &&
(key2 == null ? multi.getKey(1) == null : key2.equals(multi.getKey(1)))) {
it.remove();
modified = true;
}
}
return modified;
}
Removes all mappings where the first two keys are those specified.
This method removes all the mappings where the MultiKey
has two or more keys, and the first two match those specified. |
public boolean removeAll(Object key1,
Object key2,
Object key3) {
boolean modified = false;
MapIterator it = mapIterator();
while (it.hasNext()) {
MultiKey multi = (MultiKey) it.next();
if (multi.size() >= 3 &&
(key1 == null ? multi.getKey(0) == null : key1.equals(multi.getKey(0))) &&
(key2 == null ? multi.getKey(1) == null : key2.equals(multi.getKey(1))) &&
(key3 == null ? multi.getKey(2) == null : key3.equals(multi.getKey(2)))) {
it.remove();
modified = true;
}
}
return modified;
}
Removes all mappings where the first three keys are those specified.
This method removes all the mappings where the MultiKey
has three or more keys, and the first three match those specified. |
public boolean removeAll(Object key1,
Object key2,
Object key3,
Object key4) {
boolean modified = false;
MapIterator it = mapIterator();
while (it.hasNext()) {
MultiKey multi = (MultiKey) it.next();
if (multi.size() >= 4 &&
(key1 == null ? multi.getKey(0) == null : key1.equals(multi.getKey(0))) &&
(key2 == null ? multi.getKey(1) == null : key2.equals(multi.getKey(1))) &&
(key3 == null ? multi.getKey(2) == null : key3.equals(multi.getKey(2))) &&
(key4 == null ? multi.getKey(3) == null : key4.equals(multi.getKey(3)))) {
it.remove();
modified = true;
}
}
return modified;
}
Removes all mappings where the first four keys are those specified.
This method removes all the mappings where the MultiKey
has four or more keys, and the first four match those specified. |
public int size() {
return map.size();
}
|
public String toString() {
return map.toString();
}
|
public Collection values() {
return map.values();
}
|