Returns an array with the content between the position and limit of "buffer". This may be the buffer's backing
array itself. Does not modify position or limit of the buffer.
487842
private static byte[] toByteArray(final ByteBuffer buffer)
  {
    if (buffer.hasArray()
        && buffer.arrayOffset() == 0
        && buffer.position() == 0
        && buffer.array().length == buffer.limit()) {
      return buffer.array();
    } else {
      final byte[] retVal = new byte[buffer.remaining()];
      buffer.duplicate().get(retVal);
      return retVal;
    }
  }
1312490
private function parseArray()
    {
        $length = $this->parseUnsignedInt32();
        $stopAt = strlen($this->buffer) - $length;
        $array = [];

        while (strlen($this->buffer) > $stopAt) {
            $array[] = $this->parseField();
        }

        return $array;
    }
207360
def squeeze(self, array):
        
        if not self._squeeze:
            return array
        array = array.copy()
        array = array.squeeze()
        if array.ndim == 0:
            array = array[()]
        return array
457828
public String[] split(PushbackReader in, int bufferSize) throws IOException
    {
        return split(in, bufferSize, Integer.MAX_VALUE);
    }
526581
public ByteBuffer frameAndReturnBuffer ()
    {
        // flip the buffer which will limit it to its current position
        _buffer.flip();

        // then write the frame length and rewind back to the start of the
        // buffer so that all the data is available
        int count = _buffer.limit();
        _buffer.put((byte)((count >>> 24) & 0xFF));
        _buffer.put((byte)((count >>> 16) & 0xFF));
        _buffer.put((byte)((count >>>  8) & 0xFF));
        _buffer.put((byte)((count >>>  0) & 0xFF));
        _buffer.rewind();

        return _buffer;
    }
718135
public static byte[] readArray(ReadableBuffer buffer) {
    Preconditions.checkNotNull(buffer, "buffer");
    int length = buffer.readableBytes();
    byte[] bytes = new byte[length];
    buffer.readBytes(bytes, 0, length);
    return bytes;
  }
239150
def getLimits(locations, current, sortResults=True, verbose=False):
    
    limit = {}
    for l in locations:
        a, b = current.common(l)
        if a is None:
            continue
        for name, value in b.items():
            f = a[name]
            if name not in limit:
                limit[name] = {}
                limit[name]['<'] = {}
                limit[name]['='] = {}
                limit[name]['>'] = {}
                if f > 0:
                    limit[name]['>'] = {0: [Location()]}
                elif f<0:
                    limit[name]['<'] = {0: [Location()]}
                else:
                    limit[name]['='] = {0: [Location()]}
            if current[name] < value - _EPSILON:
                if value not in limit[name]["<"]:
                    limit[name]["<"][value] = []
                limit[name]["<"][value].append(l)
            elif current[name] > value + _EPSILON:
                if value not in limit[name][">"]:
                    limit[name][">"][value] = []
                limit[name][">"][value].append(l)
            else:
                if value not in limit[name]["="]:
                    limit[name]["="][value] = []
                limit[name]["="][value].append(l)
    if not sortResults:
        return limit
    # now we have all the data, let's sort to the relevant values
    l = {}
    for name, lims in  limit.items():
        less = []
        more = []
        if lims[">"].keys():
            less = sorted(lims[">"].keys())
            lim_min = less[-1]
        else:
            lim_min = None
        if lims["<"].keys():
            more = sorted(lims["<"].keys())
            lim_max = more[0]
        else:
            lim_max = None
        if lim_min is None and lim_max is not None:
            # extrapolation < min
            if len(limit[name]['='])>0:
                l[name] = (None, list(limit[name]['='].keys())[0], None)
            elif len(more) > 1 and len(limit[name]['='])==0:
                # extrapolation
                l[name] = (None,  more[0], more[1])
        elif lim_min is not None and lim_max is None:
            # extrapolation < max
            if len(limit[name]['='])>0:
                # less > 0, M > 0, more = None
                # -> end of a limit
                l[name] = (None, limit[name]['='], None)
            elif len(less) > 1 and len(limit[name]['='])==0:
                # less > 0, M = None, more = None
                # extrapolation
                l[name] = (less[-2], less[-1], None)
        else:
            if len(limit[name]['=']) > 0:
                l[name] = (None, list(limit[name]['='].keys())[0], None)
            else:
                l[name] = (lim_min,  None, lim_max)
    return l
1261919
public static long[] dataBufferToArray(DataBuffer buffer) {
        int rank = buffer.getInt(0);
        val ret = new long[Shape.shapeInfoLength(rank)];
        ret[0] = rank;
        for (int e = 1; e < Shape.shapeInfoLength(rank); e++) {
            ret[e] = buffer.getInt(e);
        }

        return ret;
    }
1275142
public static void getBufferLimits(WsByteBuffer[] buffers, int[] limits) {
        // Double check that the parameters are non null.
        if ((buffers != null) && (limits != null)) {
            // Loop through the buffers.
            // In case of errant parameters, protect from array out of bounds.
            for (int i = 0; i < buffers.length && i < limits.length; i++) {
                // Double check for null buffers.
                if (buffers[i] != null) {
                    // Save the limit.
                    limits[i] = buffers[i].limit();
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                        Tr.debug(tc, "getBufferLimits: buffer[" + i + "] limit of " + limits[i]);
                    }
                } else {
                    // When buffer is null, save a limit of 0.
                    limits[i] = 0;
                    if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                        Tr.debug(tc, "getBufferLimits: null buffer[" + i + "] limit of " + limits[i]);
                    }
                }
            }
        }
    }
162132
def _fill_buffer(self):
        
        # If we cannot fetch anymore from the server then we're done here.
        if self._all_results_fetched:
            self._eof()

        raw_results = self.result_fetcher(page=self._page, per_page=self.per_page)

        entities = []
        for raw in raw_results:
            entities.append(self.entity.deserialize(raw, bind_client=self.bind_client))

        self._buffer = collections.deque(entities)

        self.log.debug("Requested page {0} (got: {1} items)".format(self._page,
                                                                    len(self._buffer)))
        if len(self._buffer) < self.per_page:
            self._all_results_fetched = True

        self._page += 1
661875
function bufferToArrayBuffer(buf) {
  const arr = new ArrayBuffer(buf.length);
  const view = new Uint8Array(arr);
  for (let i = 0; i < buf.length; ++i) {
    view[i] = buf[i];
  }
  return arr;
}
1077397
public byte[] getContents() {

        byte[] contents = new byte[m_buffer.size()];
        m_buffer.readBytes(contents, 0, 0, m_buffer.size());
        return contents;
    }
440836
def readline(self, limit=-1, delim=b'\n'):
        
        self._check_readable()
        chunks = []
        while True:
            chunk = self._buffer.get_chunk(limit, delim)
            if not chunk:
                break
            chunks.append(chunk)
            if chunk.endswith(delim):
                break
            if limit >= 0:
                limit -= len(chunk)
                if limit == 0:
                    break
        if not chunks and not self._buffer.eof and self._buffer.error:
            raise compat.saved_exc(self._buffer.error)
        return b''.join(chunks)
544168
public OutputContext getSlice(int limit) {
        List<ByteBuffer> newBufs = new LinkedList<ByteBuffer>();
        ByteBuffer buf = ByteBuffer.allocate(limit);
        Iterator<ByteBuffer> iter = buffers.iterator();

        while (iter.hasNext() && buf.position() < buf.limit()) {
            ByteBuffer cur = iter.next();
            int diff = buf.limit() - buf.position();
            if (diff > cur.limit()) {
                buf.put(cur);
                iter.remove();
            } else {
                ByteBuffer slice = cur.duplicate();
                slice.limit(diff);
                buf.put(slice);
            }
        }
        return new OutputContext(newBufs);
    }
696183
public synchronized byte[] getBuffer() {
        byte[] dest = new byte[buf.length];
        System.arraycopy(buf, 0, dest, 0, dest.length);
        return dest;
    }
86781
def _get_content_range(start: Optional[int], end: Optional[int], total: int) -> str:
    
    start = start or 0
    end = (end or total) - 1
    return "bytes %s-%s/%s" % (start, end, total)
758214
public int[] get() {
		if (capacity < buffer.size()) {
			capacity = buffer.size();
		}
		int[] res = buffer.toArray();
		buffer.clear(capacity);
		return res;
	}