Start or continue a hash calculation with the given data,
starting at the given position, for the given length.
@param data input
@param pos start position
@param len length
169214
public void update( byte[] data, int pos, int len ) {
  	update( ByteBuffer.wrap( data, pos, len ));
  }
373015
public boolean position(long pos)
    throws IOException
  {
    if (pos < 0) {
      // Return error on seek to negative stream position

      return false;
    }
    
    long delta = pos - position();
    
    long newOffset = _readOffset + delta;
    
    if (newOffset >= 0 && newOffset < _readLength) {
      _readOffset = (int) newOffset;
      
      return true;
    }
    
    if (delta < 0) {
      // Seek backwards in the stream

      _position = pos;
      _readLength = _readOffset = 0;

      if (_source != null) {
        _source.seekStart(pos);

        return true;
      }
      else {
        return false;
      }
    }
    else {
      // Seek forward in the stream, skip any buffered bytes

      long n = pos - position();

      return (skip(n) == n);
    }
  }
426161
public void setData(byte[] data) {
        // There are always two bytes of payload in the message -- the
        // slave ID and the run status indicator.
        if (data == null) {
            m_length = 2;
            m_data = new byte[0];

            return;
        }

        if (data.length > 249) {
            throw new IllegalArgumentException("data length limit exceeded");
        }

        m_length = data.length + 2;

        m_data = new byte[data.length];
        System.arraycopy(data, 0, m_data, 0, data.length);
    }
737329
public int read(long pos, ByteBuffer buf) {
    // since max is buf.remaining() (an int), result is guaranteed to be an int
    int bytesToRead = (int) bytesToRead(pos, buf.remaining());

    if (bytesToRead > 0) {
      int remaining = bytesToRead;

      int blockIndex = blockIndex(pos);
      byte[] block = blocks[blockIndex];
      int off = offsetInBlock(pos);

      remaining -= get(block, off, buf, length(off, remaining));

      while (remaining > 0) {
        int index = ++blockIndex;
        block = blocks[index];
        remaining -= get(block, 0, buf, length(remaining));
      }
    }

    return bytesToRead;
  }
1113227
public void write(final char[] data,
                      final int start,
                      final int count) throws IOException {
        write(new String(data, start, count));
    }
911452
public static void writeShort(byte[] buf, int pos, short v) {
    checkBoundary(buf, pos, 2);
    buf[pos++] = (byte) (0xff & (v >> 8));
    buf[pos] = (byte) (0xff & v);
  }
734612
protected void putShort(short data)
    {
        if (tc.isEntryEnabled()) Tr.entry(tc, "putShort", new Object[] { this, new Short(data)});

        if (tc.isDebugEnabled()) Tr.debug(tc, "Writing at position " + _buffer.position());
        _buffer.putShort(data);

        if (tc.isEntryEnabled()) Tr.exit(tc, "putShort");
    }
849653
private void positionDirect(long p) throws IOException {
        long newBlockStart = p / buffer.length * buffer.length;
        input.position(newBlockStart);
        buffer();
        offset = (int)(p % buffer.length);        
    }
234028
public int read(long pos) {
    if (pos >= size) {
      return -1;
    }

    byte[] block = blocks[blockIndex(pos)];
    int off = offsetInBlock(pos);
    return UnsignedBytes.toInt(block[off]);
  }
738070
public void set(final byte[] utf8, final int start, final int len) {
		setCapacity(len, false);
		System.arraycopy(utf8, start, bytes, 0, len);
		this.length = len;
		this.hash = 0;
	}
247896
public void init(int startPosition, byte[] payload) throws IOException {
    byteStream = new MtasBitInputStream(payload);
    mtasStartPosition = startPosition;
    // analyse initial bits - position
    Boolean getOffset;
    Boolean getRealOffset;
    if (byteStream.readBit() == 1) {
      if (byteStream.readBit() == 1) {
        mtasPositionType = null;
      } else {
        mtasPositionType = MtasPosition.POSITION_RANGE;
      }
    } else {
      if (byteStream.readBit() == 1) {
        mtasPositionType = MtasPosition.POSITION_SET;
      } else {
        mtasPositionType = MtasPosition.POSITION_SINGLE;
      }
    }
    // analyze initial bits - offset
    if (byteStream.readBit() == 1) {
      getOffset = true;
    } else {
      getOffset = false;
    }
    // analyze initial bits - realOffset
    if (byteStream.readBit() == 1) {
      getRealOffset = true;
    } else {
      getRealOffset = false;
    }
    // analyze initial bits - parent
    if (byteStream.readBit() == 1) {
      mtasParent = true;
    } else {
      mtasParent = false;
    }
    // analyse initial bits - payload
    if (byteStream.readBit() == 1) {
      mtasPayload = true;
    } else {
      mtasPayload = false;
    }
    if (byteStream.readBit() == 0) {
      // string
    } else {
      // other
    }
    // get id
    mtasId = byteStream.readEliasGammaCodingNonNegativeInteger();
    // get position info
    if (mtasPositionType != null
        && mtasPositionType.equals(MtasPosition.POSITION_SINGLE)) {
      mtasPosition = new MtasPosition(mtasStartPosition);
    } else if (mtasPositionType != null
        && mtasPositionType.equals(MtasPosition.POSITION_RANGE)) {
      mtasPosition = new MtasPosition(mtasStartPosition, (mtasStartPosition
          + byteStream.readEliasGammaCodingPositiveInteger() - 1));
    } else if (mtasPositionType != null
        && mtasPositionType.equals(MtasPosition.POSITION_SET)) {
      mtasPositions = new TreeSet<>();
      mtasPositions.add(mtasStartPosition);
      int numberOfPoints = byteStream.readEliasGammaCodingPositiveInteger();
      int[] positionList = new int[numberOfPoints];
      positionList[0] = mtasStartPosition;
      int previousPosition = 0;
      int currentPosition = mtasStartPosition;
      for (int i = 1; i < numberOfPoints; i++) {
        previousPosition = currentPosition;
        currentPosition = previousPosition
            + byteStream.readEliasGammaCodingPositiveInteger();
        positionList[i] = currentPosition;
      }
      mtasPosition = new MtasPosition(positionList);
    } else {
      mtasPosition = null;
    }
    // get offset and realOffset info
    if (getOffset) {
      int offsetStart = byteStream.readEliasGammaCodingNonNegativeInteger();
      int offsetEnd = offsetStart
          + byteStream.readEliasGammaCodingPositiveInteger() - 1;
      mtasOffset = new MtasOffset(offsetStart, offsetEnd);
      if (getRealOffset) {
        int realOffsetStart = byteStream.readEliasGammaCodingInteger()
            + offsetStart;
        int realOffsetEnd = realOffsetStart
            + byteStream.readEliasGammaCodingPositiveInteger() - 1;
        mtasRealOffset = new MtasOffset(realOffsetStart, realOffsetEnd);
      }
    } else if (getRealOffset) {
      int realOffsetStart = byteStream.readEliasGammaCodingNonNegativeInteger();
      int realOffsetEnd = realOffsetStart
          + byteStream.readEliasGammaCodingPositiveInteger() - 1;
      mtasRealOffset = new MtasOffset(realOffsetStart, realOffsetEnd);
    }
    if (mtasParent) {
      mtasParentId = byteStream.readEliasGammaCodingInteger() + mtasId;
    }
    if (mtasPayload) {
      mtasPayloadValue = byteStream.readRemainingBytes();
    }
  }
399056
def _setbitpos(self, pos):
        """"""
        if pos < 0:
            raise ValueError("Bit position cannot be negative.")
        if pos > self.len:
            raise ValueError("Cannot seek past the end of the data.")
        self._pos = pos
744545
public void setPosition(Long pos) {
        Interval interval = getInterval();
        if (interval != null) {
            resetInterval(pos, interval.getStartGranularity());
        } else {
            resetInterval(pos, null);
        }
    }
82904
public static int hash32(byte[] data, int length, int seed) {
        int hash = seed;
        final int nblocks = length >> 2;

        // body
        for (int i = 0; i < nblocks; i++) {
            int i_4 = i << 2;
            int k = (data[i_4] & 0xff)
                | ((data[i_4 + 1] & 0xff) << 8)
                | ((data[i_4 + 2] & 0xff) << 16)
                | ((data[i_4 + 3] & 0xff) << 24);

            // mix functions
            k *= C1_32;
            k = Integer.rotateLeft(k, R1_32);
            k *= C2_32;
            hash ^= k;
            hash = Integer.rotateLeft(hash, R2_32) * M_32 + N_32;
        }

        // tail
        int idx = nblocks << 2;
        int k1 = 0;
        switch (length - idx) {
            case 3:
                k1 ^= data[idx + 2] << 16;
            case 2:
                k1 ^= data[idx + 1] << 8;
            case 1:
                k1 ^= data[idx];

                // mix functions
                k1 *= C1_32;
                k1 = Integer.rotateLeft(k1, R1_32);
                k1 *= C2_32;
                hash ^= k1;
        }

        // finalization
        hash ^= length;
        hash ^= (hash >>> 16);
        hash *= 0x85ebca6b;
        hash ^= (hash >>> 13);
        hash *= 0xc2b2ae35;
        hash ^= (hash >>> 16);

        return hash;
    }
982025
private void percolateDown(int pos) {
    int p = pos;
    int y = this.heap.get(p);
    while (left(p) < this.heap.size()) {
      int child = right(p) < this.heap.size() && this.s.lt(this.heap.get(right(p)), this.heap.get(left(p))) ? right(p) : left(p);
      if (!this.s.lt(this.heap.get(child), y))
        break;
      this.heap.set(p, this.heap.get(child));
      this.indices.set(this.heap.get(p), p);
      p = child;
    }
    this.heap.set(p, y);
    this.indices.set(y, p);
  }
717674
public void append(final byte[] data, final int start, final int len) {
		final int oldLength = this.bytes.length;
		setCapacity(this.bytes.length + len, true);
		System.arraycopy(data, start, this.bytes, oldLength, len);
	}
631046
@Override
    public void position(long pos) {
        log.debug("position: {}", pos);
        currentFrame = getFrame(pos);
        log.debug("Setting current sample: {}", currentFrame);
    }