Skip navigation links

Oracle® Fusion Middleware Java API Reference for Oracle Coherence
12c (12.1.3.0.0)

E47890-01


com.tangosol.util
Class MultiBinaryLongMap.SafeBinaryLongMap

java.lang.Object
  extended by com.tangosol.util.MultiBinaryLongMap.WrapperBinaryLongMap
      extended by com.tangosol.util.MultiBinaryLongMap.SafeBinaryLongMap

All Implemented Interfaces:
BinaryLongMap
Direct Known Subclasses:
MultiBinaryLongMap.PrimaryBinaryLongMap.CompressedPrimaryBinaryLongMap
Enclosing class:
MultiBinaryLongMap

public static class MultiBinaryLongMap.SafeBinaryLongMap
extends MultiBinaryLongMap.WrapperBinaryLongMap

The SafeBinaryLongMap is a BinaryLongMap implementation that wraps an underlying BinaryLongMap in order to add thread safety.


Nested Class Summary

 

Nested classes/interfaces inherited from class com.tangosol.util.MultiBinaryLongMap.WrapperBinaryLongMap
MultiBinaryLongMap.WrapperBinaryLongMap.WrapperIterator

 

Nested classes/interfaces inherited from interface com.tangosol.util.BinaryLongMap
BinaryLongMap.Entry, BinaryLongMap.EntryVisitor, BinaryLongMap.SimpleMapImpl

 

Field Summary
protected  java.util.concurrent.locks.Lock f_lockExclusive
          The exclusive lock.
protected  java.util.concurrent.locks.Lock f_lockShared
          The shared lock.

 

Fields inherited from class com.tangosol.util.MultiBinaryLongMap.WrapperBinaryLongMap
m_blm

 

Constructor Summary
MultiBinaryLongMap.SafeBinaryLongMap(BinaryLongMap blm, java.util.concurrent.locks.Lock lockShared, java.util.concurrent.locks.Lock lockExclusive)
          Construct a SafeBinaryLongMap around the specified map, protected by the specified locks.

 

Method Summary
 void clear()
          Initialize the map to an empty state.
 long get(Binary binKey)
          Find the specified key in the map and return the value associated with it.
 BinaryLongMap getMap()
          Return the underlying BinaryLongMap.
 void internKeys(java.lang.Object o)
          Internal opaque method: De-duplicate keys.
 java.util.Iterator keys()
          Obtain an iterator of the keys stored in the map.
 java.util.Iterator keys(com.oracle.common.base.Predicate predicate)
          Obtain an iterator of the keys stored in the map whose corresponding Entry matches the passed Predicate<Entry>.
 void put(Binary binKey, long lValue)
          Blindly store the passed value for the specified key, adding the key if it is not already in the map, or replacing the current value if the key is in the map.
 boolean putIfAbsent(Binary binKey, long lValue)
          Store the passed value for the specified key, only if the key does not currently exist in the map.
 void release()
          Release the SafeBinaryLongMap.
 void remove(Binary binKey)
          Blindly remove the specified Binary key from the map.
 boolean remove(Binary binKey, long lValue)
          Remove the specified Binary key from the map iff it exists in the map and is associated with the specified value.
 boolean replace(Binary binKey, long lValueOld, long lValueNew)
          Store the passed "new" value for the specified key, only if the current value associated with the specified key is the same as the specified "old" value.
 int size()
          Determine the size of the map.
 void visit(Binary binKey, BinaryLongMap.EntryVisitor visitor)
          Apply the specified visitor to the entry associated with the specified key, if the entry exists or may be added.
 void visitAll(BinaryLongMap.EntryVisitor visitor)
          Apply the specified visitor to all entries in the BinaryLongMap.

 

Methods inherited from class com.tangosol.util.MultiBinaryLongMap.WrapperBinaryLongMap
setMap

 

Field Detail

f_lockShared

protected final java.util.concurrent.locks.Lock f_lockShared
The shared lock.

f_lockExclusive

protected final java.util.concurrent.locks.Lock f_lockExclusive
The exclusive lock.

Constructor Detail

MultiBinaryLongMap.SafeBinaryLongMap

public MultiBinaryLongMap.SafeBinaryLongMap(BinaryLongMap blm,
                                            java.util.concurrent.locks.Lock lockShared,
                                            java.util.concurrent.locks.Lock lockExclusive)
Construct a SafeBinaryLongMap around the specified map, protected by the specified locks.

It is assumed that the specified locks have the following reentrant properties:

Parameters:
blm - the underlying BinaryLongMap
lockShared - the lock to acquire for shared access
lockExclusive - the lock to acquire for exclusive access

Method Detail

getMap

public BinaryLongMap getMap()
Return the underlying BinaryLongMap.
Overrides:
getMap in class MultiBinaryLongMap.WrapperBinaryLongMap
Returns:
the underlying BinaryLongMap

release

public void release()
Release the SafeBinaryLongMap. Any future operations against this map will result in an exception.

get

public long get(Binary binKey)
Find the specified key in the map and return the value associated with it.
Specified by:
get in interface BinaryLongMap
Overrides:
get in class MultiBinaryLongMap.WrapperBinaryLongMap
Parameters:
binKey - a Binary key
Returns:
the value associated with the specified key, or 0L if the specified key is not in the map

put

public void put(Binary binKey,
                long lValue)
Blindly store the passed value for the specified key, adding the key if it is not already in the map, or replacing the current value if the key is in the map.

Note that associating the value zero with a key is analogous to removing the key.

Specified by:
put in interface BinaryLongMap
Overrides:
put in class MultiBinaryLongMap.WrapperBinaryLongMap
Parameters:
binKey - the Binary key to add or update
lValue - the value to associate with the key

putIfAbsent

public boolean putIfAbsent(Binary binKey,
                           long lValue)
Store the passed value for the specified key, only if the key does not currently exist in the map.

Note that associating the value zero with a key using this method will have no effect, since were that key already present, there would be no change, and were it not present, the value zero is analogous to removing the key, which again is no change (since it is not present).

Specified by:
putIfAbsent in interface BinaryLongMap
Overrides:
putIfAbsent in class MultiBinaryLongMap.WrapperBinaryLongMap
Parameters:
binKey - a Binary key
lValue - the new value to associate with the passed key
Returns:
true iff the key was not present in the map, and now it is present in the map associated with the passed value

replace

public boolean replace(Binary binKey,
                       long lValueOld,
                       long lValueNew)
Store the passed "new" value for the specified key, only if the current value associated with the specified key is the same as the specified "old" value.

Note that replacing the value of zero is analogous to putIfAbsent, and associating the value zero with a key using this method is the same as remove passing the old value to match.

Specified by:
replace in interface BinaryLongMap
Overrides:
replace in class MultiBinaryLongMap.WrapperBinaryLongMap
Parameters:
binKey - a Binary key
lValueOld - the assumed old value to replace
lValueNew - the new value to associate with the passed key
Returns:
true iff the key was associated with the passed "old" value, and now it is associated with the passed "new" value

remove

public void remove(Binary binKey)
Blindly remove the specified Binary key from the map.
Specified by:
remove in interface BinaryLongMap
Overrides:
remove in class MultiBinaryLongMap.WrapperBinaryLongMap
Parameters:
binKey - a Binary key

remove

public boolean remove(Binary binKey,
                      long lValue)
Remove the specified Binary key from the map iff it exists in the map and is associated with the specified value.

Note that removing an association whose value is zero has no effect.

Specified by:
remove in interface BinaryLongMap
Overrides:
remove in class MultiBinaryLongMap.WrapperBinaryLongMap
Parameters:
binKey - a Binary key
lValue - the value that the key must have in order to be removed
Returns:
true iff the map contained the key, it was associated with the specified value, and has now been removed

clear

public void clear()
Initialize the map to an empty state.
Specified by:
clear in interface BinaryLongMap
Overrides:
clear in class MultiBinaryLongMap.WrapperBinaryLongMap

size

public int size()
Determine the size of the map.
Specified by:
size in interface BinaryLongMap
Overrides:
size in class MultiBinaryLongMap.WrapperBinaryLongMap
Returns:
the number of unique keys stored in the map

keys

public java.util.Iterator keys()
Obtain an iterator of the keys stored in the map.
Specified by:
keys in interface BinaryLongMap
Overrides:
keys in class MultiBinaryLongMap.WrapperBinaryLongMap
Returns:
an Iterator of Binary keys

keys

public java.util.Iterator keys(com.oracle.common.base.Predicate predicate)
Obtain an iterator of the keys stored in the map whose corresponding Entry matches the passed Predicate<Entry>.

The entry passed to the predicate should be treated as read-only, and any attempt to modify the entry may have undefined behavior and/or throw an Exception. Modifications to entries should instead be performed using an BinaryLongMap.EntryVisitor via the BinaryLongMap.visit(com.tangosol.util.Binary, com.tangosol.util.BinaryLongMap.EntryVisitor) or BinaryLongMap.visitAll(com.tangosol.util.BinaryLongMap.EntryVisitor) methods.

Specified by:
keys in interface BinaryLongMap
Overrides:
keys in class MultiBinaryLongMap.WrapperBinaryLongMap
Parameters:
predicate - a Predicate<Entry> to apply to each Entry
Returns:
an Iterator of Binary keys

visit

public void visit(Binary binKey,
                  BinaryLongMap.EntryVisitor visitor)
Apply the specified visitor to the entry associated with the specified key, if the entry exists or may be added. The visited entry may or may not logically exist in the BinaryLongMap (e.g. it may be associated with a value of 0L) but is guaranteed to be safe to be added or removed (via BinaryLongMap.Entry.setValue(long)).
Specified by:
visit in interface BinaryLongMap
Overrides:
visit in class MultiBinaryLongMap.WrapperBinaryLongMap
Parameters:
binKey - the key to visit
visitor - the visitor to apply

visitAll

public void visitAll(BinaryLongMap.EntryVisitor visitor)
Apply the specified visitor to all entries in the BinaryLongMap.
Specified by:
visitAll in interface BinaryLongMap
Overrides:
visitAll in class MultiBinaryLongMap.WrapperBinaryLongMap
Parameters:
visitor - the visitor to apply

internKeys

public void internKeys(java.lang.Object o)
Internal opaque method: De-duplicate keys.
Specified by:
internKeys in interface BinaryLongMap
Overrides:
internKeys in class MultiBinaryLongMap.WrapperBinaryLongMap
Parameters:
o - some implementation-specific object

Skip navigation links

Oracle® Fusion Middleware Java API Reference for Oracle Coherence
12c (12.1.3.0.0)

E47890-01


Copyright © 2000, 2014, Oracle and/or its affiliates. All rights reserved.