|
Copyright © 2006 BEA Systems, Inc. All Rights Reserved | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.AbstractMap
com.compoze.collab.util.ArrayMap
public class ArrayMap
Implements a Map
that's backed by an array. This implementation
provides all of the optional Map
operations and permits
null
values but does not permit the null
key.
This implementation is not thread safe, so use of it from multiple
threads without external synchronization will result in undefined
behavior.
This Map
implementation may provide improved performance over
HashMap
when used for fewer than 5 mappings. It also consumes
less of the Java heap than HashMap
. You should test this class
with the keys and values that you're using to truly evaluate the performance
of both heap and CPU in your real-world scenario, and use it only when the
benefit is clear.
Constructor Summary | |
---|---|
ArrayMap()
Constructs an empty ArrayMap with the default initial capacity (5). |
|
ArrayMap(int iInitialCapacity)
Constructs an empty ArrayMap with the specified initial capacity. |
|
ArrayMap(Map map)
Constructs an empty ArrayMap with the same mappings as the
specified Map . |
Method Summary | |
---|---|
void |
clear()
Removes all mappings from this map. |
boolean |
containsKey(Object key)
Returns true if this map contains a mapping for the
specified key. |
boolean |
containsValue(Object value)
Returns true if this map contains at least one value that is
the same as the specified value. |
Set |
entrySet()
Returns a set view of the mappings contained in this map. |
Object |
get(Object key)
Returns the value to which this map maps the specified key. |
boolean |
isEmpty()
Determines if the map is empty. |
Set |
keySet()
Returns a set view of the keys contained in this map. |
static void |
main(String[] args)
Exerciser. |
Object |
put(Object key,
Object value)
Associates the specified value with the specified key in this map. |
void |
putUnique(Object key,
Object value)
Associates the specified value with the specified key in this map, assuming that the specified key is known to be unique. |
Object |
remove(Object key)
Removes the mapping for this key from this map if it is present. |
int |
size()
Gets the number of mappings in the map. |
Collection |
values()
Returns a collection view of the values contained in this map. |
Methods inherited from class java.util.AbstractMap |
---|
clone, equals, hashCode, putAll, toString |
Methods inherited from class java.lang.Object |
---|
finalize, getClass, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
public ArrayMap()
ArrayMap
with the default initial capacity (5).
public ArrayMap(int iInitialCapacity)
ArrayMap
with the specified initial capacity.
iInitialCapacity
- the initial capacitypublic ArrayMap(Map map)
ArrayMap
with the same mappings as the
specified Map
.
map
- the Map
whose mappings are to be
placed in this Map (must not be null
)
Method Detail |
---|
public void clear()
clear
in interface Map
clear
in class AbstractMap
Map.clear()
public boolean containsKey(Object key)
true
if this map contains a mapping for the
specified key.
containsKey
in interface Map
containsKey
in class AbstractMap
true
if there is a mapping, false
otherwise
(must not be null
)Map.containsKey(Object)
public boolean containsValue(Object value)
true
if this map contains at least one value that is
the same as the specified value.
containsValue
in interface Map
containsValue
in class AbstractMap
true
if it contains the value, false
otherwise
(may be null
)Map.containsValue(Object)
public Set entrySet()
entrySet
in interface Map
entrySet
in class AbstractMap
Set
(each element in the set is a
Map.Entry
)Map.entrySet()
public Object get(Object key)
get
in interface Map
get
in class AbstractMap
the
- key (must not be null
)
Map.get(Object)
public boolean isEmpty()
isEmpty
in interface Map
isEmpty
in class AbstractMap
true
if the map is empty, false
otherwiseMap.isEmpty()
public Set keySet()
keySet
in interface Map
keySet
in class AbstractMap
Map.keySet()
public Object put(Object key, Object value)
put
in interface Map
put
in class AbstractMap
key
- the key (must not be null
)value
- the value (may be null
)
null
if
the value was not already in the Map
Map.put(Object, Object)
public void putUnique(Object key, Object value)
Map
operations will be undefined after this method is called.
key
- the key (must not be null
)value
- the value (may be null
)Map.put(Object, Object)
public Object remove(Object key)
remove
in interface Map
remove
in class AbstractMap
key
- the key of the mapping to remove
(must not be null
)
null
if there was no valueMap.remove(Object)
public int size()
size
in interface Map
size
in class AbstractMap
Map.size()
public Collection values()
values
in interface Map
values
in class AbstractMap
public static void main(String[] args)
|
Copyright © 2006 BEA Systems, Inc. All Rights Reserved | ||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |