Package java.nio

Examples of java.nio.ByteBuffer.capacity()


                {
                    ref.clear();
                    _pool.remove( i );
                    _currentSize -= buffer.capacity();
                    buffer.limit( capacity );
                    LOG.log( Level.FINEST, "Borrowed buffer with capacity of " + buffer.capacity() + "(limit="
                            + capacity + "). Pool max size: " + _sizeB + " Current pool size: " + _currentSize );
                    return buffer;
                }
               
                i++;
View Full Code Here


            ByteBuffer buffer = (ByteBuffer) ref.get();
            _pool.remove( ref );

            if ( buffer != null )
            {
                LOG.log( Level.FINEST, "Collecting Buffer with capacity of " + buffer.capacity() );
                _currentSize -= buffer.capacity();
            }
            else
            {
                LOG.log( Level.FINEST, "Clearing cache..." );
View Full Code Here

            _pool.remove( ref );

            if ( buffer != null )
            {
                LOG.log( Level.FINEST, "Collecting Buffer with capacity of " + buffer.capacity() );
                _currentSize -= buffer.capacity();
            }
            else
            {
                LOG.log( Level.FINEST, "Clearing cache..." );
                _pool.clear();
View Full Code Here

            int pos = bb.position();
            bb.position(bb.limit());
            bb.limit(bb.limit() + len);
            bb.put(b, off, len);
            bb.position(pos);
            writable = bb.capacity() - bb.limit();
            return;
        }

        if(writable > 0) {
            int pos = bb.position();
View Full Code Here

            int pos = bb.position();
            bb.position(bb.limit());
            bb.limit(bb.limit() + rem);
            bb.put(buf);
            bb.position(pos);
            writable = bb.capacity() - bb.limit();
            return;
        }

        if(writable > 0) {
            int pos = bb.position();
View Full Code Here

            ByteBuffer bb = link.getLast();
            link.clear();
            bb.position(0);
            bb.limit(0);
            link.addLast(bb);
            writable = bb.capacity();
        } else {
            link.clear();
            writable = -1;
        }
    }
View Full Code Here

                    width  = roi.width();
                    height = roi.height();
                }
                int srcLine = srcBuf.position(), dstLine = dstBuf.position();
                for (int y = 0; y < height && srcLine < srcBuf.capacity() &&
                        dstLine < dstBuf.capacity(); y++) {
                    for (int x = 0; x < width; x++) {
                        int a = 128, a2 = 128, b = 0, g = 0, r = 0;
                        switch (srcChannels) {
                            default: assert false;
                            case 4: a = srcBuf.get()&0xFF; a2 = 255-a;
View Full Code Here

        // cvDiv() doesn't support division by zero...
        FloatBuffer fb1 = float1.getFloatBuffer();
        FloatBuffer fb2 = float2.getFloatBuffer();
        ByteBuffer  rmb = roiMask.getByteBuffer();
        assert(fb1.capacity() == fb2.capacity()/3);
        assert(fb1.capacity() == rmb.capacity()/3);
        int[] nPixels = new int[channels];
        for (int i = 0, j = 0; j < fb1.capacity(); i++, j+=channels) {
            for (int z = 0; z < channels; z++) {
                float ra = fb1.get(j+z);
                float r  = fb2.get(j+z);
View Full Code Here

      while (index < src.length)
      {
        buf.rewind();
        int remaining = src.length - index;
        int size = Math.min(nio_segment_size, remaining);
        if (size != buf.capacity())
        {
          // System.out.println("reallocating segment_size: " +
          // segment_size + " remaining: " + remaining +
          // " buf.capacity(): " + buf.capacity());
          buf = ByteBuffer.allocate(size);
View Full Code Here

    return utf8;
  }

  private static ByteBuffer randomBytes(Random rand, int maxLength) {
    ByteBuffer bytes = ByteBuffer.allocate(rand.nextInt(maxLength));
    bytes.limit(bytes.capacity());
    rand.nextBytes(bytes.array());
    return bytes;
  }

  public static void main(String[] args) throws Exception {
View Full Code Here

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.