Package java.nio

Examples of java.nio.IntBuffer


        for (int i=0;i < buf.capacity();i++) {
            assertEquals("Bad value at index " + i, MAGIC, buf.get(i));
        }
    }
    public void testIntBufferArgument() {
        IntBuffer buf  = IntBuffer.allocate(1024);
        final int MAGIC = 0xABEDCF23;
        lib.fillInt32Buffer(buf, 1024, MAGIC);
        for (int i=0;i < buf.capacity();i++) {
            assertEquals("Bad value at index " + i, MAGIC, buf.get(i));
        }
    }
View Full Code Here


        }
    }
   
    public void testDirectIntBufferArgument() {
        ByteBuffer buf  = ByteBuffer.allocateDirect(1024*4).order(ByteOrder.nativeOrder());
        IntBuffer intBuf = buf.asIntBuffer();
        final int MAGIC = 0xABEDCF23;
        lib.fillInt32Buffer(intBuf, 1024, MAGIC);
        for (int i=0;i < intBuf.capacity();i++) {
            assertEquals("Bad value at index " + i, MAGIC, intBuf.get(i));
        }
    }
View Full Code Here

                         i < 512 ? 0 : MAGIC, array[i]);
        }
    }
    public void testWrappedIntArrayArgument() {
        int[] array = new int[1024];
        IntBuffer buf  = IntBuffer.wrap(array, 512, 512);
        final int MAGIC = 0xABEDCF23;
        lib.fillInt32Buffer(buf, 512, MAGIC);
        for (int i=0;i < array.length;i++) {
            assertEquals("Bad value at index " + i,
                         i < 512 ? 0 : MAGIC, array[i]);
View Full Code Here

    }
    public void testIntBufferPut() {
        final int MAGIC = 0xABEDCF23;
        Memory m = new Memory(8);
        ByteBuffer buf = m.getByteBuffer(0, m.size()).order(ByteOrder.nativeOrder());
        IntBuffer ib = buf.asIntBuffer();
        ib.put(MAGIC).flip();
        assertEquals("Int not written to memory", MAGIC,
                m.getInt(0));
    }
View Full Code Here

    }
    public void testIntBufferGet() {
        final int MAGIC = 0xABEDCF23;
        Memory m = new Memory(8);
        ByteBuffer buf = m.getByteBuffer(0, m.size()).order(ByteOrder.nativeOrder());
        IntBuffer ib = buf.asIntBuffer();
        m.setInt(0, MAGIC);
        assertEquals("Int not read from memory", MAGIC,
                ib.get(0));
    }
View Full Code Here

          ByteArrayInputStream bis = new ByteArrayInputStream( sb.toString().getBytes("UTF-8") );
          return bis;
        } else if (type.getName().equals(CAS.TYPE_NAME_INTEGER_ARRAY)) {
          arrayStart = getArrayStartAddress(fs.getAddress());
          buf = ByteBuffer.allocate(arraySize * 4);
          IntBuffer intbuf = buf.asIntBuffer();
          intbuf.put(this.getHeap().heap, arrayStart, arraySize);
          ByteArrayInputStream bis = new ByteArrayInputStream(buf.array());
          return bis;
        } else if (type.getName().equals(CAS.TYPE_NAME_FLOAT_ARRAY)) {
          arrayStart = getArrayStartAddress(fs.getAddress());
          buf = ByteBuffer.allocate(arraySize * 4);
 
View Full Code Here

    checkCompareTo(c, b, 1);
  }

  private void checkCompareTo(int[] buf1, int[] buf2, int expected)
  {
    IntBuffer b1 = IntBuffer.wrap(buf1);
    IntBuffer b2 = IntBuffer.wrap(buf2);

    int got = b1.compareTo(b2);
    int real_got = got;

    if (got > 1) got = 1;
View Full Code Here

            if (inChannel.read(chunkTypeBytes) < chunkTypeBytes.length) {
                throw new IllegalArgumentException();
            }

            IntBuffer lengthBuffer = ByteBuffer.wrap(lengthBytes).order(ByteOrder.BIG_ENDIAN).asIntBuffer();
            sectionLength = lengthBuffer.get(0);
            String chunkTypeString = new String(chunkTypeBytes, asciiCharset);

            if ("IHDR".equals(chunkTypeString)) {
                return new HeaderSection();
            } else if ("PLTE".equals(chunkTypeString)) {
View Full Code Here

      attribCount++;

    if ( attribCount == 0 )
      return null;

    final IntBuffer attribs = BufferUtils.createIntBuffer((attribCount * 2) + 1);

    if ( !(majorVersion == 1 && minorVersion == 0) ) {
      attribs.put(implementation.getMajorVersionAttrib()).put(majorVersion);
      attribs.put(implementation.getMinorVersionAttrib()).put(minorVersion);
    }
    if ( 0 < layerPlane )
      attribs.put(implementation.getLayerPlaneAttrib()).put(layerPlane);
    if ( 0 < flags )
      attribs.put(implementation.getFlagsAttrib()).put(flags);
    if ( 0 < profileMask )
      attribs.put(implementation.getProfileMaskAttrib()).put(profileMask);
    if ( loseContextOnReset )
      attribs.put(CONTEXT_RESET_NOTIFICATION_STRATEGY_ARB).put(LOSE_CONTEXT_ON_RESET_ARB);

    attribs.put(0);
    attribs.rewind();
    return attribs;
  }
View Full Code Here

      GLContext.loadOpenGLLibrary();
      try {
        this.peer_info = peer_info;
        this.contextAttribs = attribs;

        IntBuffer attribList;
        if ( attribs != null ) {
          attribList = attribs.getAttribList();
          forwardCompatible = attribs.isForwardCompatible();
        } else {
          attribList = null;
View Full Code Here

TOP

Related Classes of java.nio.IntBuffer

Copyright © 2018 www.massapicom. 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.