net.openhft.collect.map
Interface ByteByteMap

All Superinterfaces:
Container, Map<Byte,Byte>
All Known Subinterfaces:
HashByteByteMap

public interface ByteByteMap
extends Map<Byte,Byte>, Container

A Map specialization with byte keys and byte values.

See Also:
ByteByteMapFactory

Nested Class Summary
 
Nested classes/interfaces inherited from interface java.util.Map
Map.Entry<K,V>
 
Method Summary
 byte addValue(byte key, byte addition)
          Adds the given addition value to the value associated with the specified key, or default value if this map contains no mapping for the key, and associates the resulting value with the key.
 byte addValue(byte key, byte addition, byte defaultValue)
          Adds the given addition value to the value associated with the specified key, or defaultValue if this map contains no mapping for the key, and associates the resulting value with the key.
 byte compute(byte key, ByteByteToByteFunction remappingFunction)
          Attempts to compute a mapping for the specified key and its current mapped value (or default value if there is no current mapping).
 byte computeIfAbsent(byte key, ByteUnaryOperator mappingFunction)
          If the specified key is not already associated with a value, attempts to compute its value using the given mapping function and enters it into this map .
 byte computeIfPresent(byte key, ByteByteToByteFunction remappingFunction)
          If the value for the specified key is present, attempts to compute a new mapping given the key and its current mapped value.
 boolean containsKey(byte key)
          Returns true if this map contains a mapping for the specified key.
 boolean containsKey(Object key)
          Deprecated. Use specialization containsKey(byte) instead
 boolean containsValue(byte value)
          Returns true if this map maps one or more keys to the specified value.
 boolean containsValue(Object value)
          Deprecated. Use specialization containsValue(byte) instead
 ByteByteCursor cursor()
          Returns a new cursor over the entries of this map.
 byte defaultValue()
          Returns the default value of this map, which is used instead of null in primitive specialization methods, when the key is absent in the map.
 ObjSet<Map.Entry<Byte,Byte>> entrySet()
          
 void forEach(ByteByteConsumer action)
          Performs the given action on each entry in this map until all entries have been processed or the action throws an Exception.
 boolean forEachWhile(ByteBytePredicate predicate)
          Checks the given predicate on each entry in this map until all entries have been processed or the predicate returns false for some entry, or throws an Exception.
 byte get(byte key)
          Returns the value to which the specified key is mapped, or default value if this map contains no mapping for the key.
 Byte get(Object key)
          Deprecated. Use specialization get(byte) instead
 byte getOrDefault(byte key, byte defaultValue)
          Returns the value to which the specified key is mapped, or defaultValue if this map contains no mapping for the key.
 Byte getOrDefault(Object key, Byte defaultValue)
          Deprecated. Use specialization getOrDefault(byte, byte) instead
 ByteSet keySet()
          
 byte merge(byte key, byte value, ByteBinaryOperator remappingFunction)
          If the specified key is not already associated with a value, associates it with the given value, otherwise, replaces the value with the results of the given remapping function.
 byte put(byte key, byte value)
          Associates the specified value with the specified key in this map (optional operation).
 Byte put(Byte key, Byte value)
          Deprecated. Use specialization put(byte, byte) instead
 byte putIfAbsent(byte key, byte value)
          If the specified key is not already associated with a value, associates it with the given value and returns default value, else returns the current value.
 Byte putIfAbsent(Byte key, Byte value)
          Deprecated. Use specialization putIfAbsent(byte, byte) instead
 byte remove(byte key)
          Removes the mapping for a key from this map if it is present (optional operation).
 boolean remove(byte key, byte value)
          Removes the entry for the specified key only if it is currently mapped to the specified value.
 Byte remove(Object key)
          Deprecated. Use specialization remove(byte) instead
 boolean remove(Object key, Object value)
          Deprecated. Use specialization remove(byte, byte) instead
 boolean removeIf(ByteBytePredicate filter)
          Removes all of the entries of this collection that satisfy the given predicate.
 byte replace(byte key, byte value)
          Replaces the entry for the specified key only if it is currently mapped to some value.
 Byte replace(Byte key, Byte value)
          Deprecated. Use specialization replace(byte, byte) instead
 boolean replace(byte key, byte oldValue, byte newValue)
          Replaces the entry for the specified key only if currently mapped to the specified value.
 boolean replace(Byte key, Byte oldValue, Byte newValue)
          Deprecated. Use specialization replace(byte, byte, byte) instead
 void replaceAll(ByteByteToByteFunction function)
          Replaces each entry's value with the result of invoking the given function on that entry, in the order entries are returned by an entry set iterator, until all entries have been processed or the function throws an exception.
 ByteCollection values()
          
 
Methods inherited from interface java.util.Map
clear, equals, hashCode, isEmpty, putAll, size
 
Methods inherited from interface net.openhft.collect.Container
clear, ensureCapacity, isEmpty, shrink, size, sizeAsLong
 

Method Detail

defaultValue

byte defaultValue()
Returns the default value of this map, which is used instead of null in primitive specialization methods, when the key is absent in the map.

Returns:
the default value of this map
See Also:
ByteByteMapFactory.withDefaultValue(byte)

containsKey

@Deprecated
boolean containsKey(Object key)
Deprecated. Use specialization containsKey(byte) instead

Specified by:
containsKey in interface Map<Byte,Byte>

containsKey

boolean containsKey(byte key)
Returns true if this map contains a mapping for the specified key.

Parameters:
key - the byte key whose presence in this map is to be tested
Returns:
true if this map contains a mapping for the specified key

containsValue

@Deprecated
boolean containsValue(Object value)
Deprecated. Use specialization containsValue(byte) instead

Specified by:
containsValue in interface Map<Byte,Byte>

containsValue

boolean containsValue(byte value)
Returns true if this map maps one or more keys to the specified value. This operation will probably require time linear in the map size for most implementations of the ByteByteMap interface.

Parameters:
value - the byte value whose presence in this map is to be tested
Returns:
true if this map maps one or more keys to the specified value

get

@Nullable
@Deprecated
Byte get(Object key)
Deprecated. Use specialization get(byte) instead

Specified by:
get in interface Map<Byte,Byte>

get

byte get(byte key)
Returns the value to which the specified key is mapped, or default value if this map contains no mapping for the key.

Parameters:
key - the key whose associated value is to be returned
Returns:
the value to which the specified key is mapped, or default value if this map contains no mapping for the key

getOrDefault

@Deprecated
Byte getOrDefault(Object key,
                             Byte defaultValue)
Deprecated. Use specialization getOrDefault(byte, byte) instead

Returns the value to which the specified key is mapped, or defaultValue if this map contains no mapping for the key.

Parameters:
key - the key whose associated value is to be returned
defaultValue - the default mapping of the key
Returns:
the value to which the specified key is mapped, or defaultValue if this map contains no mapping for the key

getOrDefault

byte getOrDefault(byte key,
                  byte defaultValue)
Returns the value to which the specified key is mapped, or defaultValue if this map contains no mapping for the key.

Parameters:
key - the key whose associated value is to be returned
Returns:
the value to which the specified key is mapped, or defaultValue if this map contains no mapping for the key

forEach

void forEach(@Nonnull
             ByteByteConsumer action)
Performs the given action on each entry in this map until all entries have been processed or the action throws an Exception. Exceptions thrown by the action are relayed to the caller. The entries will be processed in the same order as the entry set iterator unless that order is unspecified in which case implementations may use an order which differs from the entry set iterator.

Parameters:
action - The action to be performed for each entry
See Also:
Comparison of iteration options in the library

forEachWhile

boolean forEachWhile(@Nonnull
                     ByteBytePredicate predicate)
Checks the given predicate on each entry in this map until all entries have been processed or the predicate returns false for some entry, or throws an Exception. Exceptions thrown by the predicate are relayed to the caller.

The entries will be processed in the same order as the entry set iterator unless that order is unspecified in which case implementations may use an order which differs from the entry set iterator.

If the map is empty, this method returns true immediately.

Parameters:
predicate - the predicate to be checked for each entry
Returns:
true if the predicate returned true for all entries of the map, false if it returned false for the entry
See Also:
Comparison of iteration options in the library

cursor

@Nonnull
ByteByteCursor cursor()
Returns a new cursor over the entries of this map. It's order is always correspond to the entry set iterator order.

Returns:
a new cursor over the entries of this map
See Also:
Comparison of iteration options in the library

keySet

@Nonnull
ByteSet keySet()

Specified by:
keySet in interface Map<Byte,Byte>

values

@Nonnull
ByteCollection values()

Specified by:
values in interface Map<Byte,Byte>

entrySet

@Nonnull
ObjSet<Map.Entry<Byte,Byte>> entrySet()

Specified by:
entrySet in interface Map<Byte,Byte>

put

@Deprecated
Byte put(Byte key,
                    Byte value)
Deprecated. Use specialization put(byte, byte) instead

Specified by:
put in interface Map<Byte,Byte>

put

byte put(byte key,
         byte value)
Associates the specified value with the specified key in this map (optional operation). If the map previously contained a mapping for the key, the old value is replaced by the specified value. (A map m is said to contain a mapping for a key k if and only if m.containsKey(k) would return true.)

Parameters:
key - key with which the specified value is to be associated
value - value to be associated with the specified key
Returns:
the previous value associated with key, or default value if there was no mapping for key. (A default value return can also indicate that the map previously associated default value with key.)
Throws:
UnsupportedOperationException - if the put operation is not supported by this map
IllegalArgumentException - if some property of a specified key or value prevents it from being stored in this map

putIfAbsent

@Nullable
@Deprecated
Byte putIfAbsent(Byte key,
                                     Byte value)
Deprecated. Use specialization putIfAbsent(byte, byte) instead

If the specified key is not already associated with a value, associates it with the given value and returns null, else returns the current value.

Parameters:
key - key with which the specified value is to be associated
value - value to be associated with the specified key
Returns:
the previous value associated with the specified key, or null if there was no mapping for the key. (A null return can also indicate that the map previously associated null with the key, if the implementation supports null values.)
Throws:
UnsupportedOperationException - if the put operation is not supported by this map
ClassCastException - if the key or value is of an inappropriate type for this map
NullPointerException - if the specified key or value is null
IllegalArgumentException - if some property of the specified key or value prevents it from being stored in this map

putIfAbsent

byte putIfAbsent(byte key,
                 byte value)
If the specified key is not already associated with a value, associates it with the given value and returns default value, else returns the current value.

Parameters:
key - key with which the specified value is to be associated
value - value to be associated with the specified key
Returns:
the previous value associated with the specified key, or default value if there was no mapping for the key. (A default value return can also indicate that the map previously associated default value with the key, if the implementation supports such values.)
Throws:
UnsupportedOperationException - if the put operation is not supported by this map
IllegalArgumentException - if some property of a specified key or value prevents it from being stored in this map

compute

byte compute(byte key,
             @Nonnull
             ByteByteToByteFunction remappingFunction)
Attempts to compute a mapping for the specified key and its current mapped value (or default value if there is no current mapping).

If the function itself throws an (unchecked) exception, the exception is rethrown, and the current mapping is left unchanged.

Parameters:
key - key with which the specified value is to be associated
remappingFunction - the function to compute a value
Returns:
the new value associated with the specified key
Throws:
UnsupportedOperationException - if the put operation is not supported by this map

computeIfAbsent

byte computeIfAbsent(byte key,
                     @Nonnull
                     ByteUnaryOperator mappingFunction)
If the specified key is not already associated with a value, attempts to compute its value using the given mapping function and enters it into this map . The most common usage is to construct a new object serving as an initial mapped value or memoized result.

If the function itself throws an (unchecked) exception, the exception is rethrown, and no mapping is recorded.

Parameters:
key - key with which the specified value is to be associated
mappingFunction - the function to compute a value
Returns:
the current (existing or computed) value associated with the specified key
Throws:
UnsupportedOperationException - if the put operation is not supported by this map

computeIfPresent

byte computeIfPresent(byte key,
                      @Nonnull
                      ByteByteToByteFunction remappingFunction)
If the value for the specified key is present, attempts to compute a new mapping given the key and its current mapped value.

If the function itself throws an (unchecked) exception, the exception is rethrown, and the current mapping is left unchanged.

Parameters:
key - key with which the specified value is to be associated
remappingFunction - the function to compute a value
Returns:
the new value associated with the specified key, or "no entry" value
Throws:
UnsupportedOperationException - if the put operation is not supported by this map

merge

byte merge(byte key,
           byte value,
           @Nonnull
           ByteBinaryOperator remappingFunction)
If the specified key is not already associated with a value, associates it with the given value, otherwise, replaces the value with the results of the given remapping function. This method may be of use when combining multiple mapped values for a key.

If the remappingFunction itself throws an (unchecked) exception, the exception is rethrown, and the current mapping is left unchanged.

Parameters:
key - key with which the specified value is to be associated
value - the value to use if absent
remappingFunction - the function to recompute a value if present
Returns:
the new value associated with the specified key
Throws:
NullPointerException - if the remappingFunction is null
UnsupportedOperationException - if the put operation is not supported by this map

addValue

byte addValue(byte key,
              byte addition)
Adds the given addition value to the value associated with the specified key, or default value if this map contains no mapping for the key, and associates the resulting value with the key.

Parameters:
key - the key to which value add the given value
addition - the value to add
Returns:
the new value associated with the specified key
Throws:
UnsupportedOperationException - if the put operation is not supported by this map

addValue

byte addValue(byte key,
              byte addition,
              byte defaultValue)
Adds the given addition value to the value associated with the specified key, or defaultValue if this map contains no mapping for the key, and associates the resulting value with the key.

This version of addValue(byte, byte) is useful if you want to count values from the different initial value, than the default value of this map.

Parameters:
key - the key to which value add the given value
addition - the value to add
defaultValue - the value to be used if the map contains no mapping for the given key
Returns:
the new value associated with the specified key
Throws:
UnsupportedOperationException - if the put operation is not supported by this map

replace

@Nullable
@Deprecated
Byte replace(Byte key,
                                 Byte value)
Deprecated. Use specialization replace(byte, byte) instead

Replaces the entry for the specified key only if it is currently mapped to some value.

Parameters:
key - key with which the specified value is associated
value - value to be associated with the specified key
Returns:
the previous value associated with the specified key, or null if there was no mapping for the key.
Throws:
UnsupportedOperationException - if the put operation is not supported by this map
NullPointerException - if the specified key or value is null
IllegalArgumentException - if some property of the specified value prevents it from being stored in this map

replace

byte replace(byte key,
             byte value)
Replaces the entry for the specified key only if it is currently mapped to some value.

Parameters:
key - key with which the specified value is associated
value - value to be associated with the specified key
Returns:
the previous value associated with the specified key, or default value if there was no mapping for the key. (A default value return can also indicate that the map previously associated default value with the key, if the implementation supports such values.)
Throws:
IllegalArgumentException - if some property of a specified key or value prevents it from being stored in this map
UnsupportedOperationException - if the put operation is not supported by this map

replace

@Deprecated
boolean replace(Byte key,
                           Byte oldValue,
                           Byte newValue)
Deprecated. Use specialization replace(byte, byte, byte) instead

Replaces the entry for the specified key only if currently mapped to the specified value.

Parameters:
key - key with which the specified value is associated
oldValue - value expected to be associated with the specified key
newValue - value to be associated with the specified key
Returns:
true if the value was replaced
Throws:
UnsupportedOperationException - if the put operation is not supported by this map
NullPointerException - if the specified key or value is null
IllegalArgumentException - if some property of the specified value prevents it from being stored in this map

replace

boolean replace(byte key,
                byte oldValue,
                byte newValue)
Replaces the entry for the specified key only if currently mapped to the specified value.

Parameters:
key - key with which the specified value is associated
oldValue - value expected to be associated with the specified key
newValue - value to be associated with the specified key
Returns:
true if the value was replaced
Throws:
IllegalArgumentException - if some property of a specified key or value prevents it from being stored in this map
UnsupportedOperationException - if the put operation is not supported by this map

replaceAll

void replaceAll(@Nonnull
                ByteByteToByteFunction function)
Replaces each entry's value with the result of invoking the given function on that entry, in the order entries are returned by an entry set iterator, until all entries have been processed or the function throws an exception.

Parameters:
function - the function to apply to each entry
Throws:
UnsupportedOperationException - if the set operation is not supported by this map's entry set iterator
IllegalArgumentException - if some property of a replacement value prevents it from being stored in this map (optional restriction)

remove

@Nullable
@Deprecated
Byte remove(Object key)
Deprecated. Use specialization remove(byte) instead

Specified by:
remove in interface Map<Byte,Byte>

remove

byte remove(byte key)
Removes the mapping for a key from this map if it is present (optional operation).

Returns the value to which this map previously associated the key, or default value if the map contained no mapping for the key.

A return value of default value does not necessarily indicate that the map contained no mapping for the key; it's also possible that the map explicitly mapped the key to default value.

The map will not contain a mapping for the specified key once the call returns.

Parameters:
key - key whose mapping is to be removed from the map
Returns:
the previous value associated with key, or default value if there was no mapping for key
Throws:
UnsupportedOperationException - if the remove operation is not supported by this map

remove

@Deprecated
boolean remove(Object key,
                          Object value)
Deprecated. Use specialization remove(byte, byte) instead

Removes the entry for the specified key only if it is currently mapped to the specified value.

Parameters:
key - key with which the specified value is associated
value - value expected to be associated with the specified key
Returns:
true if the value was removed
Throws:
NullPointerException - if the specified key or value is null
UnsupportedOperationException - if the remove operation is not supported by this map

remove

boolean remove(byte key,
               byte value)
Removes the entry for the specified key only if it is currently mapped to the specified value.

Parameters:
key - key with which the specified value is associated
value - value expected to be associated with the specified key
Returns:
true if the value was removed
Throws:
UnsupportedOperationException - if the remove operation is not supported by this map

removeIf

boolean removeIf(@Nonnull
                 ByteBytePredicate filter)
Removes all of the entries of this collection that satisfy the given predicate. Errors or runtime exceptions thrown during iteration or by the predicate are relayed to the caller.

Parameters:
filter - a predicate which returns true for elements to be removed
Returns:
true if any elements were removed
Throws:
NullPointerException - if the specified filter is null
UnsupportedOperationException - if elements cannot be removed from this collection. Implementations may throw this exception if a matching element cannot be removed or if, in general, removal is not supported.
See Also:
Comparison of iteration options in the library