Returns the order given the shape information
@param buffer the buffer
@return
160775
public static char order(IntBuffer buffer) {
        int length = Shape.shapeInfoLength(Shape.rank(buffer));
        return (char) buffer.get(length - 1);
    }
851631
public final T readBuffer(byte[] buffer) {
        if (buffer == null) {
            throw new InvalidArgument("buffer", buffer);
        } else if (buffer.length != recordSize) {
            final String fmt = "invalid buffer (%d bytes, expected %d)";
            final String msg = format(fmt, buffer.length, recordSize);
            throw new InvalidArgument(msg);
        }
        return read(buffer);
    }
78330
public static int size(DataBuffer buffer, int dimension) {
        int rank = rank(buffer);
        if (dimension >= rank)
            throw new IllegalArgumentException("Invalid dimension " + dimension + " for rank " + rank + " array");
        return buffer.getInt(1 + dimension);
    }
31674
public Graphics getBufferedGraphics() {
        Dimension dim = getSize();
        imageBuffer = createImage( dim.width, dim.height );
        if ( null == imageBuffer )
            throw new IllegalComponentStateException("Cannot create Image");
        return imageBuffer.getGraphics();
    }
951932
public static boolean isRowVectorShape(DataBuffer shapeInfo) {
        int rank = Shape.rank(shapeInfo);
        DataBuffer shape = Shape.shapeOf(shapeInfo);
        return (rank == 2 && shape.getInt(0) == 1) || rank == 1;

    }
991527
public String getTexCoordAttr(String texName)
    {
        GVRTexture tex = textures.get(texName);
        if (tex != null)
        {
            return tex.getTexCoordAttr();
        }
        return null;
    }
955361
public static final String nextLine(ByteBuffer buffer) {
    if (buffer == null) {
      return null;
    }

    int index = MemcachedDecoder.SPLIT_MATCHER
        .matchFirst(com.google.code.yanf4j.buffer.IoBuffer.wrap(buffer));
    if (index >= 0) {
      int limit = buffer.limit();
      buffer.limit(index);
      byte[] bytes = new byte[buffer.remaining()];
      buffer.get(bytes);
      buffer.limit(limit);
      buffer.position(index + ByteUtils.SPLIT.remaining());
      return getString(bytes);

    }
    return null;
  }
183425
@Override
    public DataBuffer getVectorCoordinates() {
        int idx;
        if (isRowVector()) {
            idx = 1;
        } else if (isColumnVector()) {
            idx = 0;
        } else {
            throw new UnsupportedOperationException();
        }

        // FIXME: int cast
        int[] temp = new int[(int) length()];
        for (int i = 0; i < length(); i++) {
            temp[i] = getUnderlyingIndicesOf(i).getInt(idx);
        }
        return Nd4j.createBuffer(temp);
    }
932949
@Override
    public void orderRows(final OrderBy ob) {
        if (ob != null) {
            ob.setMetaData(getMetaData());
            ob.setParser(parser);
            Collections.sort(rows, ob);
            goTop();
        }
    }
1204310
private int getStartingPoint(String buffer) {
    for (int i = 0; i < buffer.length(); i++) {
      if (!Character.isWhitespace(buffer.charAt(i))) {
        return i;
      }
    }
    return buffer.length();
  }
185533
public static Planar orderBandsIntoBuffered(Planar src, BufferedImage dst) {
		// see if no change is required
		if( dst.getType() == BufferedImage.TYPE_INT_RGB )
			return src;

		Planar tmp = new Planar(src.type, src.getNumBands());
		tmp.width = src.width;
		tmp.height = src.height;
		tmp.stride = src.stride;
		tmp.startIndex = src.startIndex;
		for( int i = 0; i < src.getNumBands(); i++ ) {
			tmp.bands[i] = src.bands[i];
		}
		ConvertRaster.orderBandsBufferedFromRgb(tmp, dst);
		return tmp;
	}
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);
    }
519800
public static char getOrder(int[] shape, int[] stride, int elementStride) {
        int sd;
        int dim;
        int i;
        boolean cContiguous = true;
        boolean isFortran = true;

        sd = 1;
        for (i = shape.length - 1; i >= 0; --i) {
            dim = shape[i];

            if (stride[i] != sd) {
                cContiguous = false;
                break;
            }
            /* contiguous, if it got this far */
            if (dim == 0) {
                break;
            }
            sd *= dim;

        }


        /* check if fortran contiguous */
        sd = elementStride;
        for (i = 0; i < shape.length; ++i) {
            dim = shape[i];
            if (stride[i] != sd) {
                isFortran = false;
            }
            if (dim == 0) {
                break;
            }
            sd *= dim;

        }

        if (isFortran && cContiguous)
            return 'a';
        else if (isFortran && !cContiguous)
            return 'f';
        else if (!isFortran && !cContiguous)
            return 'c';
        else
            return 'c';

    }
1097042
public static Slice wrappedBuffer(ByteBuffer buffer)
    {
        if (buffer.isDirect()) {
            long address = bufferAddress(buffer);
            return new Slice(null, address + buffer.position(), buffer.remaining(), buffer.capacity(), buffer);
        }

        if (buffer.hasArray()) {
            return new Slice(buffer.array(), buffer.arrayOffset() + buffer.position(), buffer.remaining());
        }

        throw new IllegalArgumentException("cannot wrap " + buffer.getClass().getName());
    }
775722
public static AllocationShape buildAllocationShape(DataBuffer buffer) {
        AllocationShape shape = new AllocationShape();
        shape.setDataType(buffer.dataType());
        shape.setLength(buffer.length());

        return shape;
    }
297726
public static int size(IntBuffer buffer, int dimension) {
        int rank = rank(buffer);
        if (dimension >= rank)
            throw new IllegalArgumentException("Invalid dimension " + dimension + " for rank " + rank + " array");
        return buffer.get(1 + dimension);
    }
1130265
public static long lengthOfBuffer(@NonNull long[] shape, @NonNull long[] stride){
        Preconditions.checkArgument(shape.length == stride.length, "Shape and strides must be same length: shape %s, stride %s",
                shape, stride);
        //Length is simply 1 + the buffer index of the last element
        long length = 1;
        for(int i=0; i<shape.length; i++ ){
            length += (shape[i]-1) * stride[i];
        }
        return length;
    }