| Method from org.apache.commons.collections.FastTreeMap Detail: |
public void clear() {
if (fast) {
synchronized (this) {
map = new TreeMap();
}
} else {
synchronized (map) {
map.clear();
}
}
}
Remove all mappings from this map. |
public Object clone() {
FastTreeMap results = null;
if (fast) {
results = new FastTreeMap(map);
} else {
synchronized (map) {
results = new FastTreeMap(map);
}
}
results.setFast(getFast());
return (results);
}
Return a shallow copy of this FastTreeMap instance.
The keys and values themselves are not copied. |
public Comparator comparator() {
if (fast) {
return (map.comparator());
} else {
synchronized (map) {
return (map.comparator());
}
}
}
Return the comparator used to order this map, or null
if this map uses its keys' natural order. |
public boolean containsKey(Object key) {
if (fast) {
return (map.containsKey(key));
} else {
synchronized (map) {
return (map.containsKey(key));
}
}
}
Return true if this map contains a mapping for the
specified key. |
public boolean containsValue(Object value) {
if (fast) {
return (map.containsValue(value));
} else {
synchronized (map) {
return (map.containsValue(value));
}
}
}
Return true if this map contains one or more keys mapping
to the specified value. |
public Set entrySet() {
return new EntrySet();
}
Return a collection view of the mappings contained in this map. Each
element in the returned collection is a Map.Entry. |
public boolean equals(Object o) {
// Simple tests that require no synchronization
if (o == this) {
return (true);
} else if (!(o instanceof Map)) {
return (false);
}
Map mo = (Map) o;
// Compare the two maps for equality
if (fast) {
if (mo.size() != map.size()) {
return (false);
}
Iterator i = map.entrySet().iterator();
while (i.hasNext()) {
Map.Entry e = (Map.Entry) i.next();
Object key = e.getKey();
Object value = e.getValue();
if (value == null) {
if (!(mo.get(key) == null && mo.containsKey(key))) {
return (false);
}
} else {
if (!value.equals(mo.get(key))) {
return (false);
}
}
}
return (true);
} else {
synchronized (map) {
if (mo.size() != map.size()) {
return (false);
}
Iterator i = map.entrySet().iterator();
while (i.hasNext()) {
Map.Entry e = (Map.Entry) i.next();
Object key = e.getKey();
Object value = e.getValue();
if (value == null) {
if (!(mo.get(key) == null && mo.containsKey(key))) {
return (false);
}
} else {
if (!value.equals(mo.get(key))) {
return (false);
}
}
}
return (true);
}
}
}
Compare the specified object with this list for equality. This
implementation uses exactly the code that is used to define the
list equals function in the documentation for the
Map.equals method. |
public Object firstKey() {
if (fast) {
return (map.firstKey());
} else {
synchronized (map) {
return (map.firstKey());
}
}
}
Return the first (lowest) key currently in this sorted map. |
public Object get(Object key) {
if (fast) {
return (map.get(key));
} else {
synchronized (map) {
return (map.get(key));
}
}
}
Return the value to which this map maps the specified key. Returns
null if the map contains no mapping for this key, or if
there is a mapping with a value of null. Use the
containsKey() method to disambiguate these cases. |
public boolean getFast() {
return (this.fast);
}
Returns true if this map is operating in fast mode. |
public int hashCode() {
if (fast) {
int h = 0;
Iterator i = map.entrySet().iterator();
while (i.hasNext()) {
h += i.next().hashCode();
}
return (h);
} else {
synchronized (map) {
int h = 0;
Iterator i = map.entrySet().iterator();
while (i.hasNext()) {
h += i.next().hashCode();
}
return (h);
}
}
}
Return the hash code value for this map. This implementation uses
exactly the code that is used to define the list hash function in the
documentation for the Map.hashCode method. |
public SortedMap headMap(Object key) {
if (fast) {
return (map.headMap(key));
} else {
synchronized (map) {
return (map.headMap(key));
}
}
}
Return a view of the portion of this map whose keys are strictly
less than the specified key. |
public boolean isEmpty() {
if (fast) {
return (map.isEmpty());
} else {
synchronized (map) {
return (map.isEmpty());
}
}
}
Return true if this map contains no mappings. |
public Set keySet() {
return new KeySet();
}
Return a set view of the keys contained in this map. |
public Object lastKey() {
if (fast) {
return (map.lastKey());
} else {
synchronized (map) {
return (map.lastKey());
}
}
}
Return the last (highest) key currently in this sorted map. |
public Object put(Object key,
Object value) {
if (fast) {
synchronized (this) {
TreeMap temp = (TreeMap) map.clone();
Object result = temp.put(key, value);
map = temp;
return (result);
}
} else {
synchronized (map) {
return (map.put(key, value));
}
}
}
Associate the specified value with the specified key in this map.
If the map previously contained a mapping for this key, the old
value is replaced and returned. |
public void putAll(Map in) {
if (fast) {
synchronized (this) {
TreeMap temp = (TreeMap) map.clone();
temp.putAll(in);
map = temp;
}
} else {
synchronized (map) {
map.putAll(in);
}
}
}
Copy all of the mappings from the specified map to this one, replacing
any mappings with the same keys. |
public Object remove(Object key) {
if (fast) {
synchronized (this) {
TreeMap temp = (TreeMap) map.clone();
Object result = temp.remove(key);
map = temp;
return (result);
}
} else {
synchronized (map) {
return (map.remove(key));
}
}
}
Remove any mapping for this key, and return any previously
mapped value. |
public void setFast(boolean fast) {
this.fast = fast;
}
Sets whether this map is operating in fast mode. |
public int size() {
if (fast) {
return (map.size());
} else {
synchronized (map) {
return (map.size());
}
}
}
Return the number of key-value mappings in this map. |
public SortedMap subMap(Object fromKey,
Object toKey) {
if (fast) {
return (map.subMap(fromKey, toKey));
} else {
synchronized (map) {
return (map.subMap(fromKey, toKey));
}
}
}
Return a view of the portion of this map whose keys are in the
range fromKey (inclusive) to toKey (exclusive). |
public SortedMap tailMap(Object key) {
if (fast) {
return (map.tailMap(key));
} else {
synchronized (map) {
return (map.tailMap(key));
}
}
}
Return a view of the portion of this map whose keys are greater than
or equal to the specified key. |
public Collection values() {
return new Values();
}
Return a collection view of the values contained in this map. |