Class SegmentedConcurrentMap.SizeAction

java.lang.Object
com.tangosol.util.SegmentedHashMap.EntryActionAdapter
com.tangosol.util.SegmentedConcurrentMap.SizeAction
All Implemented Interfaces:
SegmentedHashMap.EntryAction, SegmentedHashMap.IterableEntryAction
Enclosing class:
SegmentedConcurrentMap

protected static class SegmentedConcurrentMap.SizeAction extends SegmentedHashMap.EntryActionAdapter
Action support for size(). The action is invoked on each Entry in the map to determine the number of key-value mappings contained in the map. SizeAction is not required to run while holding any segment-locks.

The context object for a SizeAction is an opaque context created by instantiateContext.

The result of invoking a SizeAction is the number of key-value mappings found in the map.

  • Constructor Details

    • SizeAction

      protected SizeAction()
  • Method Details

    • invokeFound

      public Object invokeFound(Object oKey, Object oContext, SegmentedHashMap.Entry[] aeBucket, int nBucket, SegmentedHashMap.Entry entryPrev, SegmentedHashMap.Entry entryCur)
      Invoke some action, holding the segment lock, when a matching Entry is found.
      Specified by:
      invokeFound in interface SegmentedHashMap.EntryAction
      Overrides:
      invokeFound in class SegmentedHashMap.EntryActionAdapter
      Parameters:
      oKey - the key to which the action is applied
      oContext - opaque context specific to the action
      aeBucket - the bucket array
      nBucket - the index into the bucket array
      entryPrev - the Entry object immediately preceding the Entry that was found, or null
      entryCur - the Entry object that was found
      Returns:
      an opaque result value
    • isComplete

      public boolean isComplete(Object oContext)
      Return true iff further key evaluations for the given context are known to be unnecessary.
      Specified by:
      isComplete in interface SegmentedHashMap.IterableEntryAction
      Overrides:
      isComplete in class SegmentedHashMap.EntryActionAdapter
      Parameters:
      oContext - the action context
      Returns:
      true iff further evaluations are unnecessary
    • size

      public int size(Object oContext)
      Return the number of Entry objects found while applying this action.
      Parameters:
      oContext - the action context
      Returns:
      the number of Entry objects found
    • instantiateContext

      public Object instantiateContext(boolean fEmptyCheck)
      Instantiate a context appropriate for applying SizeAction to count the number of entries in the map.
      Parameters:
      fEmptyCheck - if true, only test for emptiness
      Returns:
      a context to use with a SizeAction