Class MultiBinaryLongMap.MaskedBinaryLongMap
- All Implemented Interfaces:
- BinaryLongMap
- Direct Known Subclasses:
- MultiBinaryLongMap.LeftoverLongMapHolder.LeftoverMaskedBinaryLongMap
- Enclosing class:
- MultiBinaryLongMap
MaskedBinaryLongMap is not thread-safe, and it is the caller's responsibility to ensure that any concurrent access to the MaskedBinaryLongMap is protected in a manner consistent with the underlying BinaryLongMap.
- 
Nested Class SummaryNested ClassesModifier and TypeClassDescriptionprotected classMaskedEntry represents an Entry in the MaskedBinaryLongMap.protected classMaskedEntryVisitor is a wrapper for an EntryVisitor that exposes the logical entries of this MaskedEntryVisitor.Nested classes/interfaces inherited from interface com.tangosol.util.BinaryLongMapBinaryLongMap.Entry, BinaryLongMap.EntryVisitor, BinaryLongMap.SimpleMapImpl
- 
Field SummaryFieldsModifier and TypeFieldDescriptionprotected final BinaryLongMapThe underlying BinaryLongMap.protected final intThe number of bits that the logical value represented by this MaskedBinaryLongMap is limited to in the underlying physical representation.protected final MultiBinaryLongMap.MaskedLongMapHolderThe MaskedLongMapHolder associated with this MaskedBinaryLongMap.protected longThe bit-mask representing the positions used to store values in the underlying physical representation.protected intThe number of bits that the logical value represented by this MaskedBinaryLongMap is shifted left in the underlying physical representation.
- 
Constructor SummaryConstructorsConstructorDescriptionMaskedBinaryLongMap(MultiBinaryLongMap.MaskedLongMapHolder holder, BinaryLongMap blm, int cShift, int cBits) Construct a MaskedBinaryLongMap based on the specified binary long map using the specified shift and bit-widths.
- 
Method SummaryModifier and TypeMethodDescriptionvoidclear()Initialize the map to an empty state.protected longdecode(long lEncoded) Decode the n-bit value from the specifiedencodedlong value.protected longencode(long lEncoded, long lValue) Encode the specified n-bit value into the possibly already encoded value, preserving any unrelated bits.longFind the specified key in the map and return the value associated with it.Return the MaskedLongMapHolder used to manage the lifecycle of this MaskedBinaryLongMap.instantiateMaskedEntryVisitor(BinaryLongMap.EntryVisitor visitor, boolean fExisting) Instantiate a MaskedEntryVisitor to use tovisit(com.tangosol.util.Binary, com.tangosol.util.BinaryLongMap.EntryVisitor)entries in this MaskedBinaryLongMap.voidinternKeys(Object o) Internal opaque method: De-duplicate keys.keys()Obtain an iterator of the keys stored in the map.keys(Predicate<BinaryLongMap.Entry> predicate) Obtain an iterator of the keys stored in the map whose correspondingEntrymatches the passedPredicate<Entry>.voidBlindly 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.booleanputIfAbsent(Binary binKey, long lValue) Store the passed value for the specified key, only if the key does not currently exist in the map.voidBlindly remove the specified Binary key from the map.booleanRemove the specified Binary key from the map iff it exists in the map and is associated with the specified value.booleanStore 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.intsize()Determine the size of the map.voidvisit(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.voidvisitAll(BinaryLongMap.EntryVisitor visitor) Apply the specified visitor to all entries in the BinaryLongMap.
- 
Field Details- 
f_holderThe MaskedLongMapHolder associated with this MaskedBinaryLongMap.
- 
f_blmThe underlying BinaryLongMap.
- 
m_cShiftprotected int m_cShiftThe number of bits that the logical value represented by this MaskedBinaryLongMap is shifted left in the underlying physical representation.
- 
f_cBitsprotected final int f_cBitsThe number of bits that the logical value represented by this MaskedBinaryLongMap is limited to in the underlying physical representation.
- 
f_nMaskprotected long f_nMaskThe bit-mask representing the positions used to store values in the underlying physical representation.
 
- 
- 
Constructor Details- 
MaskedBinaryLongMappublic MaskedBinaryLongMap(MultiBinaryLongMap.MaskedLongMapHolder holder, BinaryLongMap blm, int cShift, int cBits) Construct a MaskedBinaryLongMap based on the specified binary long map using the specified shift and bit-widths. More formally, the logical value stored by this MaskedBinaryLongMap is represented in the underlying physical BinaryLongMap as:lValueLogical = (lValuePhysical >> cShift) & ((1 << cBits) - 1)- Parameters:
- holder- the MaskedLongMapHolder associated with this MaskedBinaryLongMap
- blm- the underlying BinaryLongMap
- cShift- the number of positions to left-shift the values stored in this MaskedBinaryLongMap
- cBits- the number of bits in the values stored in this MaskedBinaryLongMap
 
 
- 
- 
Method Details- 
getHolderReturn the MaskedLongMapHolder used to manage the lifecycle of this MaskedBinaryLongMap.- Returns:
- the MaskedLongMapHolder
 
- 
getFind the specified key in the map and return the value associated with it.- Specified by:
- getin interface- BinaryLongMap
- Parameters:
- binKey- a Binary key
- Returns:
- the value associated with the specified key, or 0L if the specified key is not in the map
 
- 
putBlindly 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:
- putin interface- BinaryLongMap
- Parameters:
- binKey- the Binary key to add or update
- lValue- the value to associate with the key
 
- 
putIfAbsentStore 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:
- putIfAbsentin interface- BinaryLongMap
- 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
 
- 
replaceStore 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 asremovepassing the old value to match.- Specified by:
- replacein interface- BinaryLongMap
- 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
 
- 
removeBlindly remove the specified Binary key from the map.- Specified by:
- removein interface- BinaryLongMap
- Parameters:
- binKey- a Binary key
 
- 
removeRemove 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:
- removein interface- BinaryLongMap
- 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
 
- 
clearpublic void clear()Initialize the map to an empty state.- Specified by:
- clearin interface- BinaryLongMap
 
- 
sizepublic int size()Determine the size of the map.- Specified by:
- sizein interface- BinaryLongMap
- Returns:
- the number of unique keys stored in the map
 
- 
keysObtain an iterator of the keys stored in the map.- Specified by:
- keysin interface- BinaryLongMap
- Returns:
- an Iterator of Binary keys
 
- 
keysObtain an iterator of the keys stored in the map whose correspondingEntrymatches the passedPredicate<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.EntryVisitorvia theBinaryLongMap.visit(com.tangosol.util.Binary, com.tangosol.util.BinaryLongMap.EntryVisitor)orBinaryLongMap.visitAll(com.tangosol.util.BinaryLongMap.EntryVisitor)methods.- Specified by:
- keysin interface- BinaryLongMap
- Parameters:
- predicate- a Predicate<Entry> to apply to each Entry
- Returns:
- an Iterator of Binary keys
 
- 
visitApply 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 (viaBinaryLongMap.Entry.setValue(long)).- Specified by:
- visitin interface- BinaryLongMap
- Parameters:
- binKey- the key to visit
- visitor- the visitor to apply
 
- 
visitAllApply the specified visitor to all entries in the BinaryLongMap.- Specified by:
- visitAllin interface- BinaryLongMap
- Parameters:
- visitor- the visitor to apply
 
- 
internKeysInternal opaque method: De-duplicate keys.- Specified by:
- internKeysin interface- BinaryLongMap
- Parameters:
- o- some implementation-specific object
 
- 
instantiateMaskedEntryVisitorprotected MultiBinaryLongMap.MaskedBinaryLongMap.MaskedEntryVisitor instantiateMaskedEntryVisitor(BinaryLongMap.EntryVisitor visitor, boolean fExisting) Instantiate a MaskedEntryVisitor to use tovisit(com.tangosol.util.Binary, com.tangosol.util.BinaryLongMap.EntryVisitor)entries in this MaskedBinaryLongMap.- Parameters:
- visitor- the underlying visitor to wrap
- fExisting- true iff the underlying visitor is to visit only entries that logically exist in the MaskedBinaryLongMap
- Returns:
- a MaskedEntryVisitor
 
- 
decodeprotected long decode(long lEncoded) Decode the n-bit value from the specifiedencodedlong value.- Parameters:
- lEncoded- the 64-bit encoded value to decode
- Returns:
- the decoded value
 
- 
encodeprotected long encode(long lEncoded, long lValue) Encode the specified n-bit value into the possibly already encoded value, preserving any unrelated bits.- Parameters:
- lEncoded- the 64-bit value to encode into
- lValue- the value to encode
- Returns:
- the new encoded value
 
 
-