Sets or clears a bit in the given memory (integer).

@param mem The memory to modify
@param mask The mask which defines to bit to be set/cleared
@param value Whether to set the bit (true) or clear the bit (false)
@return The modified memory
425751
private int setBit(final int mem, final int mask, final boolean value) {

		final int result;
		if (value) {
			result = mem | mask;  // set bit by using OR
		} else {
			result = mem & ~mask; // clear bit by using AND with the inverted mask
		}
		return result;

	}
368517
static final CouponHashSet heapifySet(final Memory mem) {
    final int lgConfigK = extractLgK(mem);
    final TgtHllType tgtHllType = extractTgtHllType(mem);

    final CurMode curMode = extractCurMode(mem);
    final int memArrStart = (curMode == CurMode.LIST) ? LIST_INT_ARR_START : HASH_SET_INT_ARR_START;
    final CouponHashSet set = new CouponHashSet(lgConfigK, tgtHllType);
    set.putOutOfOrderFlag(true);
    final boolean memIsCompact = extractCompactFlag(mem);
    final int couponCount = extractHashSetCount(mem);
    int lgCouponArrInts = extractLgArr(mem);
    if (lgCouponArrInts < LG_INIT_SET_SIZE) {
      lgCouponArrInts = computeLgArr(mem, couponCount, lgConfigK);
    }
    if (memIsCompact) {
      for (int i = 0; i < couponCount; i++) {
        set.couponUpdate(extractInt(mem, memArrStart + (i << 2)));
      }
    } else { //updatable
      set.couponCount = couponCount;
      set.lgCouponArrInts = lgCouponArrInts;
      final int couponArrInts = 1 << lgCouponArrInts;
      set.couponIntArr = new int[couponArrInts];
      mem.getIntArray(HASH_SET_INT_ARR_START, set.couponIntArr, 0, couponArrInts);
    }
    return set;
  }
954458
public void set(ShortBitMask mask, boolean value) {
        this.flag = LogicUtil.setBit(this.flag, mask.getMask(), value);
    }
306512
public boolean remove(final long value) {
        int index = longHash(value, mask);

        while (values[index] != missingValue) {
            if (values[index] == value) {
                values[index] = missingValue;
                compactChain(index);
                size--;
                return true;
            }

            index = next(index);
        }

        return false;
    }
155155
def set_bit(bitmask, bit, is_on):
    
    bitshift = bit - 1
    if is_on:
        return bitmask | (1 << bitshift)
    return bitmask & (0xff & ~(1 << bitshift))
788182
public void writeIntLenenc(final long value) {
        if (value < 0xfb) {
            byteBuf.writeByte((int) value);
            return;
        }
        if (value < Math.pow(2, 16)) {
            byteBuf.writeByte(0xfc);
            byteBuf.writeShortLE((int) value);
            return;
        }
        if (value < Math.pow(2, 24)) {
            byteBuf.writeByte(0xfd);
            byteBuf.writeMediumLE((int) value);
            return;
        }
        byteBuf.writeByte(0xfe);
        byteBuf.writeLongLE(value);
    }
1075800
public static int hash(final long value, final int mask)
    {
        long hash = value * 31;
        hash = (int)hash ^ (int)(hash >>> 32);

        return (int)hash & mask;
    }
1027368
public Collection<Range> getBits(boolean value) {
        int index=0;
        int start_range=0, end_range=0;
        int size=(int)((high - low) + 1);
        final Collection<Range> retval=new ArrayList<>(size);

        while(index < size) {
            start_range=value? bits.nextSetBit(index) : bits.nextClearBit(index);
            if(start_range < 0 || start_range >= size)
                break;
            end_range=value? bits.nextClearBit(start_range) : bits.nextSetBit(start_range);
            if(end_range < 0 || end_range >= size) {
                retval.add(new Range(start_range + low, size-1+low));
                break;
            }
            retval.add(new Range(start_range + low, end_range-1+low));
            index=end_range;
        }

        return retval;
    }
569560
static long checkPreambleSize(final Memory mem) {
    final long cap = mem.getCapacity();
    if (cap < 8) { throwNotBigEnough(cap, 8); }
    final long pre0 = mem.getLong(0);
    final int preLongs = (int) (pre0 & 0X3FL); //lower 6 bits
    final int required = Math.max(preLongs << 3, 8);
    if (cap < required) { throwNotBigEnough(cap, required); }
    return pre0;
  }
781149
private void calculate(String mask) {
        Matcher matcher = cidrPattern.matcher(mask);

        if (matcher.matches()) {
            address = matchAddress(matcher);

            /* Create a binary netmask from the number of bits specification /x */
            int cidrPart = rangeCheck(Integer.parseInt(matcher.group(5)), 0, NBITS);
            for (int j = 0; j < cidrPart; ++j) {
                netmask |= (1 << 31 - j);
            }

        } else {
            throw new IllegalArgumentException("Could not parse [" + mask + "]");
        }
    }
1227823
public boolean remove(Object mem){
        try {   
        	boolean result = false;
        	if(isCluster(groupName)){
        		result = getBinaryJedisClusterCommands(groupName).zrem(keyBytes,valueSerialize(mem)) >= 1;
        	}else{
        		result = getBinaryJedisCommands(groupName).zrem(keyBytes,valueSerialize(mem)) >= 1;
        	}
			return result;
    	} finally{
			getJedisProvider(groupName).release();
		}
	}
604594
public void setMask(byte[] mask) {
    if (mask == null) {
      throw new IllegalArgumentException("Transmitter mask cannot be null.");
    }
    if (mask.length != TRANSMITTER_ID_SIZE) {
      throw new IllegalArgumentException(String.format(
          "Transmitter mask must be %d bytes long.",
          Integer.valueOf(TRANSMITTER_ID_SIZE)));
    }
    this.mask = mask;
  }
1303125
def clear(bit)
      quotient = bit >> 3
      remainder = bit & 0x7
      mask = ~(0x80 >> remainder)
      
      raise "Bit #{bit} out of range of bitfield with length #{length}" if quotient >= @data.length
      @data[quotient] &= mask
    end
897761
public void update(final Memory mem) {
    if (mem == null) {
      return;
    }

    ReservoirLongsSketch rls = ReservoirLongsSketch.heapify(mem);

    rls = (rls.getK() <= maxK_ ? rls : rls.downsampledCopy(maxK_));

    if (gadget_ == null) {
      createNewGadget(rls, true);
    } else {
      twoWayMergeInternal(rls, true);
    }
  }
878464
protected static void unmask(ByteBuffer buf, int mask) {
        if (!buf.hasRemaining()) {
            return;
        }

        byte b;
        int start = buf.position();
        int remainder = buf.remaining() % 4;
        int remaining = buf.remaining() - remainder;
        int end = remaining + buf.position();

        // xor a 32bit word at a time as long as possible
        while (buf.position() < end) {
            int plaintext = buf.getInt(buf.position()) ^ mask;
            buf.putInt(plaintext);
        }

        // xor the remaining 3, 2, or 1 bytes
        switch (remainder) {
        case 3:
            b = (byte) (buf.get(buf.position()) ^ ((mask >> 24) & 0xff));
            buf.put(b);
            b = (byte) (buf.get(buf.position()) ^ ((mask >> 16) & 0xff));
            buf.put(b);
            b = (byte) (buf.get(buf.position()) ^ ((mask >> 8) & 0xff));
            buf.put(b);
            break;
        case 2:
            b = (byte) (buf.get(buf.position()) ^ ((mask >> 24) & 0xff));
            buf.put(b);
            b = (byte) (buf.get(buf.position()) ^ ((mask >> 16) & 0xff));
            buf.put(b);
            break;
        case 1:
            b = (byte) (buf.get(buf.position()) ^ (mask >> 24));
            buf.put(b);
            break;
        case 0:
        default:
                break;
        }
        buf.position(start);
    }
325608
public void set(long index) {
        int wordNum = expandingWordNum(index);
        int bit = (int)index & 0x3f;
        long bitmask = 1L << bit;
        bits[wordNum] |= bitmask;
    }
1070052
public synchronized int setNextBit(boolean value) {
        increaseLength();
        index = (index + 1) % size;

        int previous = bitSet.set(index, value);
        int current = value ? 1 : 0;
        cardinality = cardinality - previous + current;
        return cardinality;
    }