summaryrefslogtreecommitdiff
path: root/java/nio/DoubleBuffer.java
blob: 0273209222c516b0009ec74cddb49f2f1506f160 (plain)
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
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
package java.nio;
public abstract class DoubleBuffer extends Buffer
{
    private ByteOrder endian = ByteOrder.BIG_ENDIAN;
    public static DoubleBuffer allocateDirect(int capacity)
    {
        DoubleBuffer b = new gnu.java.nio. DoubleBufferImpl(capacity, 0, capacity);
        return b;
    }
    public static DoubleBuffer allocate(int capacity)
    {
        DoubleBuffer b = new gnu.java.nio. DoubleBufferImpl(capacity, 0, capacity);
        return b;
    }
   final public static DoubleBuffer wrap(double[] array,
                              int offset,
                              int length)
    {
        gnu.java.nio.DoubleBufferImpl b = new gnu.java.nio. DoubleBufferImpl(array, offset, length);
        return b;
    }
  final public static DoubleBuffer wrap(String a)
    {
        int len = a.length();
        double[] buffer = new double[len];
        for (int i=0;i<len;i++)
            {
                buffer[i] = (double) a.charAt(i);
            }
        return wrap(buffer, 0, len);
    }
   final public static DoubleBuffer wrap(double[] array)
    {
        return wrap(array, 0, array.length);
    }
    final public DoubleBuffer get(double[] dst,
                      int offset,
                      int length)
    {
          for (int i = offset; i < offset + length; i++)
              {
                  dst[i] = get();
              }
          return this;
    }
  final public DoubleBuffer get(double[] dst)
    {
        return get(dst, 0, dst.length);
    }
  final public DoubleBuffer put(DoubleBuffer src)
    {
        while (src.hasRemaining())
            put(src.get());
        return this;
    }
  final public DoubleBuffer put(double[] src,
                          int offset,
                          int length)
    {
          for (int i = offset; i < offset + length; i++)
              put(src[i]);
          return this;
    }
public final DoubleBuffer put(double[] src)
    {
        return put(src, 0, src.length);
    }
public final boolean hasArray()
    {
        return false;
    }
    public final double[] array()
    {
        return null;
    }
    public final int arrayOffset()
    {
      return 0;
    }
    public int hashCode()
    {
        return super.hashCode();
    }
    public boolean equals(Object obj)
    {
        if (obj instanceof DoubleBuffer)
            {
                return compareTo(obj) == 0;
            }
        return false;
    }
    public int compareTo(Object ob)
    {
        DoubleBuffer a = (DoubleBuffer) ob;
        if (a.remaining() != remaining())
            return 1;
        if (! hasArray() ||
            ! a.hasArray())
          {
            return 1;
          }
        int r = remaining();
        int i1 = pos;
        int i2 = a.pos;
        for (int i=0;i<r;i++)
            {
                int t = (int) (get(i1)- a.get(i2));
                if (t != 0)
                    {
                        return (int) t;
                    }
            }
        return 0;
    }
    public final ByteOrder order()
    {
        return endian;
    }
    public final DoubleBuffer order(ByteOrder bo)
    {
        endian = bo;
        return this;
    }
    public abstract double get();
    public abstract java.nio. DoubleBuffer put(double b);
    public abstract double get(int index);
    public abstract java.nio. DoubleBuffer put(int index, double b);
    public abstract DoubleBuffer compact();
    public abstract boolean isDirect();
    public abstract DoubleBuffer slice();
    public abstract DoubleBuffer duplicate();
    public abstract DoubleBuffer asReadOnlyBuffer();
    public abstract ShortBuffer asShortBuffer();
    public abstract CharBuffer asCharBuffer();
    public abstract IntBuffer asIntBuffer();
    public abstract LongBuffer asLongBuffer();
    public abstract FloatBuffer asFloatBuffer();
    public abstract DoubleBuffer asDoubleBuffer();
    public abstract char getChar();
    public abstract DoubleBuffer putChar(char value);
    public abstract char getChar(int index);
    public abstract DoubleBuffer putChar(int index, char value);
    public abstract short getShort();
    public abstract DoubleBuffer putShort(short value);
    public abstract short getShort(int index);
    public abstract DoubleBuffer putShort(int index, short value);
    public abstract int getInt();
    public abstract DoubleBuffer putInt(int value);
    public abstract int getInt(int index);
    public abstract DoubleBuffer putInt(int index, int value);
    public abstract long getLong();
    public abstract DoubleBuffer putLong(long value);
    public abstract long getLong(int index);
    public abstract DoubleBuffer putLong(int index, long value);
    public abstract float getFloat();
    public abstract DoubleBuffer putFloat(float value);
    public abstract float getFloat(int index);
    public abstract DoubleBuffer putFloat(int index, float value);
    public abstract double getDouble();
    public abstract DoubleBuffer putDouble(double value);
    public abstract double getDouble(int index);
    public abstract DoubleBuffer putDouble(int index, double value);
}