asIntBuffer() public method

public asIntBuffer ( ) : IntBuffer
return IntBuffer
Ejemplo n.º 1
0
        public void putData(int[,] data)
        {
            int nSamples = data.GetLength(0);

            if (nSamples == 0)
            {
                return;
            }
            int nChans = data.GetLength(1);

            if (nChans == 0)
            {
                return;
            }

            ByteBuffer buf = preparePutData(nChans, nSamples, DataType.INT32);

            int[] rowData;
            for (int i = 0; i < nSamples; i++)
            {
                rowData = getRow <int>(data, i);
                buf.asIntBuffer().put(rowData);
            }
            buf.rewind();
            writeAll(buf);
            readResponse(PUT_OK);
        }
Ejemplo n.º 2
0
        public int[,] getIntData(int first, int last)
        {
            DataDescription dd  = new DataDescription();
            ByteBuffer      buf = getRawData(first, last, dd);

            int nSamples = dd.nSamples;
            int nChans   = dd.nChans;

            int[,] data = new int[nSamples, nChans];

            switch (dd.dataType)
            {
            case DataType.INT8:
                for (int i = 0; i < nSamples; i++)
                {
                    for (int j = 0; j < nChans; j++)
                    {
                        data[i, j] = (int)buf.get();
                    }
                }
                break;

            case DataType.INT16:
                for (int i = 0; i < nSamples; i++)
                {
                    for (int j = 0; j < nChans; j++)
                    {
                        data[i, j] = (int)buf.getShort();
                    }
                }
                break;

            case DataType.INT32:
                IntBuffer iBuf = buf.asIntBuffer();
                int[]     rowData;
                for (int n = 0; n < nSamples; n++)
                {
                    rowData = getRow <int>(data, n);
                    iBuf.get(rowData);
                }
                break;

            default:
                throw new IOException("Not supported yet - returning zeros.");
                break;
            }

            return(data);
        }
Ejemplo n.º 3
0
        public void serialize(ByteBuffer buf)
        {
            switch (type)
            {
            case DataType.CHAR:
                buf.putString(array.ToString());
                break;

            case DataType.UINT8:
            case DataType.INT8:
                buf.put((byte[])array);
                break;

            case DataType.UINT16:
            case DataType.INT16:
                buf.asShortBuffer().put((short[])array);
                break;

            case DataType.UINT32:
            case DataType.INT32:
                buf.asIntBuffer().put((int[])array);
                break;

            case DataType.UINT64:
            case DataType.INT64:
                buf.asLongBuffer().put((long[])array);
                break;

            case DataType.FLOAT32:
                buf.asFloatBuffer().put((float[])array);
                break;

            case DataType.FLOAT64:
                buf.asDoubleBuffer().put((double[])array);
                break;
            }
        }
Ejemplo n.º 4
0
 public void serialize(ByteBuffer buf)
 {
     switch(type) {
         case DataType.CHAR:
             buf.putString(array.ToString());
             break;
         case DataType.UINT8:
         case DataType.INT8:
             buf.put((byte[]) array);
             break;
         case DataType.UINT16:
         case DataType.INT16:
             buf.asShortBuffer().put((short[]) array);
             break;
         case DataType.UINT32:
         case DataType.INT32:
             buf.asIntBuffer().put((int[]) array);
             break;
         case DataType.UINT64:
         case DataType.INT64:
             buf.asLongBuffer().put((long[]) array);
             break;
         case DataType.FLOAT32:
             buf.asFloatBuffer().put((float[]) array);
             break;
         case DataType.FLOAT64:
             buf.asDoubleBuffer().put((double[]) array);
             break;
     }
 }