Factory method for creating a <tt>BitVector</tt> instance
wrapping the given byte data.

@param data a byte[] containing packed bits.
@param size Size to set the bit vector to

@return the newly created <tt>BitVector</tt> instance.
428365
public static BitVector createBitVector(byte[] data, int size) {
        BitVector bv = new BitVector(data.length * 8);
        bv.setBytes(data);
        bv.size = size;
        return bv;
    }
1290598
public JBBPDslBuilder CustomArray(final String type, final String size) {
    return this.CustomArray(type, null, size, null);
  }
781735
public static Integer[] createAndInitializeArray(int size, Integer start) {
		Integer[] result = new Integer[size];
		for (int i = 0; i < result.length; i++) {
			result[i] = start++;
		}
		return result;
	}
7912
public static byte[] parseBinary(InputStream inputStream, final int size) throws IOException {
        byte value[] = new byte[size];
        int i = value.length;
        while (i != 0) {
            i -= inputStream.read(value, value.length - i, i);
        }

        return value;
    }
510008
public static byte[] getByteArray(int size)
    {
        byte[][] pool = (byte[][])__pools.get();
        boolean full=true;
        for (int i=pool.length;i-->0;)
        {
            if (pool[i]!=null && pool[i].length==size)
            {
                byte[]b = pool[i];
                pool[i]=null;
                return b;
            }
            else
                full=false;
        }

        if (full)
            for (int i=pool.length;i-->0;)
                pool[i]=null;
        
        return new byte[size];
    }
1077126
public BitArray resize(long size) {
    bytes.resize(Math.max(size / 8 + 8, 8));
    this.size = size;
    return this;
  }
248621
public static byte[] getBytes(long val, long size) {
        byte[] res = new byte[(int) size];
        long bv = val;
        for (int i = (int) size - 1; i >= 0; --i) {
            res[i] = (byte) (bv & 0xFF);
            bv >>= BIT_IN_BYTE;
        }
        return res;
    }
1267101
public static IntArray getInstance(int size, int bitCount, ByteOrder order)
    {
        switch (bitCount)
        {
            case 8:
                return getInstance(new byte[size], bitCount, order);
            case 16:
                return getInstance(new byte[2*size], bitCount, order);
            case 32:
                return new InArray(size);
            default:
                throw new UnsupportedOperationException(bitCount+" not supported");
        }
    }
825437
public VectorSize readVectorCoordinateSize() throws IOException {
        int size = getInt(), numEntries = getInt();

        return new VectorSize(size, numEntries);
    }
1233343
public static BufferedImage ByteBufferImage( byte[] data, int width, int height ) {
        int[] bandoffsets = {0, 1, 2, 3};
        DataBufferByte dbb = new DataBufferByte(data, data.length);
        WritableRaster wr = Raster.createInterleavedRaster(dbb, width, height, width * 4, 4, bandoffsets, null);
        int[] bitfield = {8, 8, 8, 8};

        ColorSpace cs = ColorSpace.getInstance(ColorSpace.CS_sRGB);
        ColorModel cm = new ComponentColorModel(cs, bitfield, true, false, Transparency.TRANSLUCENT, DataBuffer.TYPE_BYTE);

        return new BufferedImage(cm, wr, false, null);
    }
1120572
public static <E> Matcher<Iterable<E>> hasSize(final int size) {
        checkArgument(size >= 0, "Size cannot be negative");

        return new IsIterableWithSize(size);
    }
160430
@Benchmark
  @BenchmarkMode(Mode.SampleTime)
  @OutputTimeUnit(TimeUnit.NANOSECONDS)
  public byte[] toBinarySpanContext(Data data) {
    return data.binaryFormat.toByteArray(data.spanContext);
  }
959090
public static BinaryValue create(byte[] data)
    {
        if (data != null)
        {
           data = Arrays.copyOf(data, data.length);
        }
        return new BinaryValue(data);
    }
1038250
def BitVecVal(value: int, size: int, annotations: Annotations = None) -> BitVec:
        """"""
        raw = z3.BitVecVal(value, size)
        return BitVec(raw, annotations)
145025
@SuppressWarnings("unchecked")
    public static ByteBuffer allocateDirectBuffer(int size) {
        try {
            Class<?> cls = Class.forName("java.nio.DirectByteBuffer");
            Constructor<?> constructor = cls.getDeclaredConstructor(Long.TYPE, Integer.TYPE);
            constructor.setAccessible(true);
            Field cleanerField = cls.getDeclaredField("cleaner");
            cleanerField.setAccessible(true);
            final long memory = allocateMemory(size);
            ByteBuffer buffer = (ByteBuffer) constructor.newInstance(memory, size);
            Cleaner cleaner = Cleaner.create(buffer, new Runnable() {
                @Override
                public void run() {
                    freeMemory(memory);
                }
            });
            cleanerField.set(buffer, cleaner);
            return buffer;
        } catch (Exception e) {
            throwException(e);
        }
        throw new IllegalStateException("unreachable");
    }
1179388
public static BasicVector fromMap(Map<Integer, ? extends Number> map, int length) {
        return Vector.fromMap(map, length).to(Vectors.BASIC);
    }
894608
public byte[] readRawBytes(final int size) throws IOException
    {
        if (size < 0)
        {
            throw ProtobufException.negativeSize();
        }

        if (totalBytesRetired + bufferPos + size > currentLimit)
        {
            // Read to the end of the stream anyway.
            skipRawBytes(currentLimit - totalBytesRetired - bufferPos);
            // Then fail.
            throw ProtobufException.truncatedMessage();
        }

        if (size <= bufferSize - bufferPos)
        {
            // We have all the bytes we need already.
            final byte[] bytes = new byte[size];
            System.arraycopy(buffer, bufferPos, bytes, 0, size);
            bufferPos += size;
            return bytes;
        }
        else if (size < buffer.length)
        {
            // Reading more bytes than are in the buffer, but not an excessive number
            // of bytes. We can safely allocate the resulting array ahead of time.

            // First copy what we have.
            final byte[] bytes = new byte[size];
            int pos = bufferSize - bufferPos;
            System.arraycopy(buffer, bufferPos, bytes, 0, pos);
            bufferPos = bufferSize;

            // We want to use refillBuffer() and then copy from the buffer into our
            // byte array rather than reading directly into our byte array because
            // the input may be unbuffered.
            refillBuffer(true);

            while (size - pos > bufferSize)
            {
                System.arraycopy(buffer, 0, bytes, pos, bufferSize);
                pos += bufferSize;
                bufferPos = bufferSize;
                refillBuffer(true);
            }

            System.arraycopy(buffer, 0, bytes, pos, size - pos);
            bufferPos = size - pos;

            return bytes;
        }
        else
        {
            // The size is very large. For security reasons, we can't allocate the
            // entire byte array yet. The size comes directly from the input, so a
            // maliciously-crafted message could provide a bogus very large size in
            // order to trick the app into allocating a lot of memory. We avoid this
            // by allocating and reading only a small chunk at a time, so that the
            // malicious message must actually *be* extremely large to cause
            // problems. Meanwhile, we limit the allowed size of a message elsewhere.

            // Remember the buffer markers since we'll have to copy the bytes out of
            // it later.
            final int originalBufferPos = bufferPos;
            final int originalBufferSize = bufferSize;

            // Mark the current buffer consumed.
            totalBytesRetired += bufferSize;
            bufferPos = 0;
            bufferSize = 0;

            // Read all the rest of the bytes we need.
            int sizeLeft = size - (originalBufferSize - originalBufferPos);
            final List<byte[]> chunks = new ArrayList<byte[]>();

            while (sizeLeft > 0)
            {
                final byte[] chunk = new byte[Math.min(sizeLeft, buffer.length)];
                int pos = 0;
                while (pos < chunk.length)
                {
                    final int n = (input == null) ? -1 :
                            input.read(chunk, pos, chunk.length - pos);
                    if (n == -1)
                    {
                        throw ProtobufException.truncatedMessage();
                    }
                    totalBytesRetired += n;
                    pos += n;
                }
                sizeLeft -= chunk.length;
                chunks.add(chunk);
            }

            // OK, got everything. Now concatenate it all into one buffer.
            final byte[] bytes = new byte[size];

            // Start by copying the leftover bytes from this.buffer.
            int pos = originalBufferSize - originalBufferPos;
            System.arraycopy(buffer, originalBufferPos, bytes, 0, pos);

            // And now all the chunks.
            for (final byte[] chunk : chunks)
            {
                System.arraycopy(chunk, 0, bytes, pos, chunk.length);
                pos += chunk.length;
            }

            // Done.
            return bytes;
        }
    }