/
DataBuffer.java
131 lines (115 loc) · 3.38 KB
/
DataBuffer.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
package org.nd4j.linalg.api.buffer;
import java.io.Serializable;
/**
* A data buffer is an interface
* for handling storage and retrieval of data
* @author Adam Gibson
*/
public interface DataBuffer extends Serializable {
public final static String DOUBLE = "double";
public final static String FLOAT = "float";
/**
* Raw byte array storage
* @return the data represented as a raw byte array
*/
byte[] asBytes();
/**
* The data type of the buffer
* @return the data type of the buffer
*/
public String dataType();
/**
* Return the buffer as a float array
* Relative to the datatype, this will either be a copy
* or a reference. The reference is preferred for
* faster access of data and no copying
* @return the buffer as a float
*/
public float[] asFloat();
/**
* Return the buffer as a double array
* Relative to the datatype, this will either be a copy
* or a reference. The reference is preferred for
* faster access of data and no copying
* @return the buffer as a float
*/
public double[] asDouble();
/**
* Return the buffer as an int array
* Relative to the datatype, this will either be a copy
* or a reference. The reference is preferred for
* faster access of data and no copying
* @return the buffer as a float
*/
public int[] asInt();
/**
* Returns the element buffer of the specified type.
* @param <E>
* @return the element buffer of the specified type
*/
public <E> E[] asType();
/**
* Get element i in the buffer as a double
* @param i the element to getFloat
* @return the element at this index
*/
public double getDouble(int i);
/**
* Get element i in the buffer as a double
* @param i the element to getFloat
* @return the element at this index
*/
public float getFloat(int i);
/**
* Get element i in the buffer as a double
* @param i the element to getFloat
* @return the element at this index
*/
public Number getNumber(int i);
/**
* Get element i in the buffer as a double
* @param i the element to getFloat
* @return the element at this index
*/
public <E> E getElement(int i);
/**
* Assign an element in the buffer to the specified index
* @param i the index
* @param element the element to assign
*/
void put(int i,float element);
/**
* Assign an element in the buffer to the specified index
* @param i the index
* @param element the element to assign
*/
void put(int i,double element);
/**
* Assign an element in the buffer to the specified index
* @param i the index
* @param element the element to assign
*/
void put(int i,int element);
/**
* Assign an element in the buffer to the specified index
* @param i the index
* @param element the element to assign
*/
<E> void put(int i,E element);
/**
* Returns the length of the buffer
* @return the length of the buffer
*/
int length();
/**
* Get the int at the specified index
* @param ix the int at the specified index
* @return the int at the specified index
*/
int getInt(int ix);
/**
* Return a copy of this buffer
* @return a copy of this buffer
*/
DataBuffer dup();
}