| java.lang.Object bak.pcj.map.AbstractByteKeyLongMap bak.pcj.adapter.MapToByteKeyLongMapAdapter
MapToByteKeyLongMapAdapter | public class MapToByteKeyLongMapAdapter extends AbstractByteKeyLongMap implements ByteKeyLongMap(Code) | | This class represents adaptions of Java Collections Framework
maps to primitive maps from byte values to long values.
The adapter is implemented as a wrapper around the map.
Thus, changes to the underlying map are reflected by this
map and vice versa.
Adapters from JCF maps to primitive map will
fail if the JCF collection contains null keys/values or
keys/values of the wrong class. However, adapters are not fast
failing in the case that the underlying map should
contain illegal keys or values. To implement fast failure would require
every operation to check every key and value of the underlying
map before doing anything. Instead validation methods
are provided. They can be called using the assertion facility
in the client code:
MapToByteKeyLongMapAdapter s;
...
assert s.validate();
or by letting the adapter throw an exception on illegal values:
MapToByteKeyLongMapAdapter s;
...
s.evalidate(); // Throws an exception on illegal values
Either way, validation must be invoked directly by the client
code.
author: Søren Bak version: 1.3 21-08-2003 19:09 since: 1.0 |
Field Summary | |
protected Long | lastValue The value corresponding to the last key found by containsKey(). | protected Map | map The underlying map. |
Constructor Summary | |
public | MapToByteKeyLongMapAdapter(Map map) Creates a new adaption to a map from byte
values to long values.
Parameters: map - the underlying map. | public | MapToByteKeyLongMapAdapter(Map map, boolean validate) Creates a new adaption to a map from byte
values to long values. |
lastValue | protected Long lastValue(Code) | | The value corresponding to the last key found by containsKey().
|
map | protected Map map(Code) | | The underlying map.
|
MapToByteKeyLongMapAdapter | public MapToByteKeyLongMapAdapter(Map map)(Code) | | Creates a new adaption to a map from byte
values to long values.
Parameters: map - the underlying map. This map mustconsist of keys of classByte Byte.values of classLong Long. Otherwise aClassCastException ClassCastExceptionwill be thrown by some methods. throws: NullPointerException - if map is null. |
MapToByteKeyLongMapAdapter | public MapToByteKeyLongMapAdapter(Map map, boolean validate)(Code) | | Creates a new adaption to a map from byte
values to long values. The map to adapt is optionally validated.
Parameters: map - the underlying map. This map mustconsist of keys of classByte Byte.values of classLong Long. Otherwise aClassCastException ClassCastExceptionwill be thrown by some methods. Parameters: validate - indicates whether map shouldbe checked for illegal values. throws: NullPointerException - if map is null. throws: IllegalStateException - if validate is true andmap contains a null key/value,a key that is not of classByte Byte,or a value that is not of classLong Long. |
clear | public void clear()(Code) | | |
containsKey | public boolean containsKey(byte key)(Code) | | |
containsValue | public boolean containsValue(long value)(Code) | | |
evalidate | public void evalidate()(Code) | | Validates the map underlying this adapter and throws
an exception if it is invalid. For the underlying map
to be valid, it
can only contain
Byte Byte keys, no null
keys/values, and only
Long Long values.
throws: IllegalStateException - if the underlying map is invalid. |
get | public long get(byte key)(Code) | | |
put | public long put(byte key, long value)(Code) | | |
remove | public long remove(byte key)(Code) | | |
tget | public long tget(byte key)(Code) | | |
validate | public boolean validate()(Code) | | Indicates whether the underlying map is valid for
this adapter. For the underlying map to be valid, it
can only contain
Byte Byte keys, no null
keys/values, and only
Long Long values.
true if the underlying map isvalid; returns false otherwise. |
|
|