private InternalCacheEntry<WrappedBytes, WrappedBytes> performRemove(long bucketHeadAddress, long actualAddress,
         WrappedBytes key, WrappedBytes value, boolean requireReturn) {
      long prevAddress = 0;
      // We only use the head pointer for the first iteration
      long address = bucketHeadAddress;
      InternalCacheEntry<WrappedBytes, WrappedBytes> ice = null;

      while (address != 0) {
         long nextAddress = offHeapEntryFactory.getNext(address);
         boolean removeThisAddress;
         // If the actualAddress was not known, check key equality otherwise just compare with the address
         removeThisAddress = actualAddress == 0 ? offHeapEntryFactory.equalsKey(address, key) : actualAddress == address;
         if (removeThisAddress) {
            if (value != null) {
               ice = offHeapEntryFactory.fromMemory(address);
               // If value doesn't match and was provided then don't remove it
               if (!value.equalsWrappedBytes(ice.getValue())) {
                  ice = null;
                  break;
               }
            }
            if (requireReturn && ice == null) {
               ice = offHeapEntryFactory.fromMemory(address);
            }
            entryRemoved(address);
            if (prevAddress != 0) {
               offHeapEntryFactory.setNext(prevAddress, nextAddress);
            } else {
               memoryLookup.putMemoryAddress(key, nextAddress);
            }
            size.decrementAndGet();
            break;
         }
         prevAddress = address;
         address = nextAddress;
      }
      return ice;
   }
private InternalCacheEntry < WrappedBytes , WrappedBytes > performRemove ( long bucketHeadAddress , long actualAddress , WrappedBytes key , WrappedBytes value , boolean requireReturn ) { long prevAddress = 0 ; long address = bucketHeadAddress ; InternalCacheEntry < WrappedBytes , WrappedBytes > ice = null ; while ( address != 0 ) { long nextAddress = offHeapEntryFactory . getNext ( address ) ; boolean removeThisAddress ; removeThisAddress = actualAddress == 0 ? offHeapEntryFactory . equalsKey ( address , key ) : actualAddress == address ; if ( removeThisAddress ) { if ( value != null ) { ice = offHeapEntryFactory . fromMemory ( address ) ; if ( ! value . equalsWrappedBytes ( ice . getValue ( ) ) ) { ice = null ; break ; } } if ( requireReturn && ice == null ) { ice = offHeapEntryFactory . fromMemory ( address ) ; } entryRemoved ( address ) ; if ( prevAddress != 0 ) { offHeapEntryFactory . setNext ( prevAddress , nextAddress ) ; } else { memoryLookup . putMemoryAddress ( key , nextAddress ) ; } size . decrementAndGet ( ) ; break ; } prevAddress = address ; address = nextAddress ; } return ice ; }
Performs the actual remove operation removing the new address from the memory lookups.  The write lock for the given
key <b>must</b> be held before calling this method.
@param bucketHeadAddress the starting address of the address hash
@param actualAddress the actual address if it is known or 0. By passing this != 0 equality checks can be bypassed.
If a value of 0 is provided this will use key equality. key is not required when this != 0
@param key the key of the entry
@param value the value to match if present
@param requireReturn whether this method is forced to return the entry removed (optimizations can be done if
the entry is not needed)