@Override
  UpdateReturnState hashUpdate(final long hash) {
    HashOperations.checkHashCorruption(hash);

    mem_.putByte(FLAGS_BYTE, (byte) (mem_.getByte(FLAGS_BYTE) & ~EMPTY_FLAG_MASK));
    final long thetaLong = getThetaLong();
    final int lgNomLongs = getLgNomLongs();
    //The over-theta test
    if (HashOperations.continueCondition(thetaLong, hash)) {
      return RejectedOverTheta; //signal that hash was rejected due to theta or zero.
    }

    final int lgArrLongs = getLgArrLongs();
    final int preambleLongs = mem_.getByte(PREAMBLE_LONGS_BYTE) & 0X3F;

    //The duplicate test
    final int index =
        HashOperations.fastHashSearchOrInsert(mem_, lgArrLongs, hash, preambleLongs << 3);
    if (index >= 0) {
      return RejectedDuplicate; //Duplicate, not inserted
    }
    //insertion occurred, increment curCount
    final int curCount = getRetainedEntries() + 1;
    mem_.putInt(RETAINED_ENTRIES_INT, curCount); //update curCount

    if (isOutOfSpace(curCount)) { //we need to do something, we are out of space

      if (lgArrLongs > lgNomLongs) { //at full size, rebuild
        //Assumes no dirty values, changes thetaLong, curCount_
        assert (lgArrLongs == (lgNomLongs + 1))
            : "lgArr: " + lgArrLongs + ", lgNom: " + lgNomLongs;
        //rebuild, refresh curCount based on # values in the hashtable.
        quickSelectAndRebuild(mem_, preambleLongs, lgNomLongs);
      } //end of rebuild, exit

      else { //Not at full size, resize. Should not get here if lgRF = 0 and memCap is too small.
        final int lgRF = getLgRF();
        final int actLgRF = actLgResizeFactor(mem_.getCapacity(), lgArrLongs, preambleLongs, lgRF);
        int tgtLgArrLongs = Math.min(lgArrLongs + actLgRF, lgNomLongs + 1);

        if (actLgRF > 0) { //Expand in current Memory
          //lgArrLongs will change; thetaLong, curCount will not
          resize(mem_, preambleLongs, lgArrLongs, tgtLgArrLongs);
          hashTableThreshold_ = setHashTableThreshold(lgNomLongs, tgtLgArrLongs);
        } //end of Expand in current memory, exit.

        else {
          //Request more memory, then resize. lgArrLongs will change; thetaLong, curCount will not
          final int preBytes = preambleLongs << 3;
          tgtLgArrLongs = Math.min(lgArrLongs + lgRF, lgNomLongs + 1);
          final int tgtArrBytes = 8 << tgtLgArrLongs;
          final int reqBytes = tgtArrBytes + preBytes;

          memReqSvr_ = (memReqSvr_ == null) ? mem_.getMemoryRequestServer() : memReqSvr_;

          final WritableMemory newDstMem = memReqSvr_.request(reqBytes);

          moveAndResize(mem_, preambleLongs, lgArrLongs, newDstMem, tgtLgArrLongs, thetaLong);

          memReqSvr_.requestClose(mem_, newDstMem);

          mem_ = newDstMem;
          hashTableThreshold_ = setHashTableThreshold(lgNomLongs, tgtLgArrLongs);

        } //end of Request more memory to resize
      } //end of resize
    }
    return InsertedCountIncremented;
  }
@ Override UpdateReturnState hashUpdate ( final long hash ) { HashOperations . checkHashCorruption ( hash ) ; mem_ . putByte ( FLAGS_BYTE , ( byte ) ( mem_ . getByte ( FLAGS_BYTE ) & ~ EMPTY_FLAG_MASK ) ) ; final long thetaLong = getThetaLong ( ) ; final int lgNomLongs = getLgNomLongs ( ) ; if ( HashOperations . continueCondition ( thetaLong , hash ) ) { return RejectedOverTheta ; } final int lgArrLongs = getLgArrLongs ( ) ; final int preambleLongs = mem_ . getByte ( PREAMBLE_LONGS_BYTE ) & 0X3F ; final int index = HashOperations . fastHashSearchOrInsert ( mem_ , lgArrLongs , hash , preambleLongs << 3 ) ; if ( index >= 0 ) { return RejectedDuplicate ; } final int curCount = getRetainedEntries ( ) + 1 ; mem_ . putInt ( RETAINED_ENTRIES_INT , curCount ) ; if ( isOutOfSpace ( curCount ) ) { if ( lgArrLongs > lgNomLongs ) { assert ( lgArrLongs == ( lgNomLongs + 1 ) ) : "lgArr: " + lgArrLongs + ", lgNom: " + lgNomLongs ; quickSelectAndRebuild ( mem_ , preambleLongs , lgNomLongs ) ; } else { final int lgRF = getLgRF ( ) ; final int actLgRF = actLgResizeFactor ( mem_ . getCapacity ( ) , lgArrLongs , preambleLongs , lgRF ) ; int tgtLgArrLongs = Math . min ( lgArrLongs + actLgRF , lgNomLongs + 1 ) ; if ( actLgRF > 0 ) { resize ( mem_ , preambleLongs , lgArrLongs , tgtLgArrLongs ) ; hashTableThreshold_ = setHashTableThreshold ( lgNomLongs , tgtLgArrLongs ) ; } else { final int preBytes = preambleLongs << 3 ; tgtLgArrLongs = Math . min ( lgArrLongs + lgRF , lgNomLongs + 1 ) ; final int tgtArrBytes = 8 << tgtLgArrLongs ; final int reqBytes = tgtArrBytes + preBytes ; memReqSvr_ = ( memReqSvr_ == null ) ? mem_ . getMemoryRequestServer ( ) : memReqSvr_ ; final WritableMemory newDstMem = memReqSvr_ . request ( reqBytes ) ; moveAndResize ( mem_ , preambleLongs , lgArrLongs , newDstMem , tgtLgArrLongs , thetaLong ) ; memReqSvr_ . requestClose ( mem_ , newDstMem ) ; mem_ = newDstMem ; hashTableThreshold_ = setHashTableThreshold ( lgNomLongs , tgtLgArrLongs ) ; } } } return InsertedCountIncremented ; }
restricted methods