/[classpath]/classpath/gnu/java/nio/FloatBufferImpl.java
ViewVC logotype

Diff of /classpath/gnu/java/nio/FloatBufferImpl.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.7 by mkoch, Wed Nov 13 09:19:39 2002 UTC revision 1.8 by mkoch, Sun Nov 17 12:21:36 2002 UTC
# Line 36  obligated to do so.  If you do not wish Line 36  obligated to do so.  If you do not wish
36  exception statement from your version. */  exception statement from your version. */
37    
38  package gnu.java.nio;  package gnu.java.nio;
39  import java.nio.*;  
40  public final class FloatBufferImpl extends java.nio. FloatBuffer  import java.nio.FloatBuffer;
41    
42    public final class FloatBufferImpl extends FloatBuffer
43  {  {
44      private int array_offset;    private int array_offset;
45      private boolean ro;    private boolean ro;
46      
47    public FloatBufferImpl(int cap, int off, int lim)    public FloatBufferImpl(int cap, int off, int lim)
48      {    {
49        this.backing_buffer = new float[cap];      this.backing_buffer = new float[cap];
50        this.cap = cap;      this.cap = cap;
51        this.position(off);      this.position(off);
52        this.limit(lim);      this.limit(lim);
53      }    }
54      
55    public FloatBufferImpl(float[] array, int off, int lim)    public FloatBufferImpl(float[] array, int off, int lim)
56      {    {
57        this.backing_buffer = array;      this.backing_buffer = array;
58        this.cap = array.length;      this.cap = array.length;
59        this.position(off);      this.position(off);
60        this.limit(lim);      this.limit(lim);
61      }    }
62      
63    public FloatBufferImpl(FloatBufferImpl copy)    public FloatBufferImpl(FloatBufferImpl copy)
64      {    {
65          backing_buffer = copy.backing_buffer;      backing_buffer = copy.backing_buffer;
66          ro = copy.ro;      ro = copy.ro;
67          position(copy.position());      position(copy.position());
68          limit(copy.limit());      limit(copy.limit());
69      }    }
70      void inc_pos(int a)    
71      {    void inc_pos(int a)
72        position(position() + a);    {
73      }      position(position() + a);
74      }
75      
76    private static native float[] nio_cast(byte[]copy);    private static native float[] nio_cast(byte[]copy);
77    private static native float[] nio_cast(char[]copy);    private static native float[] nio_cast(char[]copy);
78    private static native float[] nio_cast(short[]copy);    private static native float[] nio_cast(short[]copy);
# Line 73  public final class FloatBufferImpl exten Line 80  public final class FloatBufferImpl exten
80    private static native float[] nio_cast(int[]copy);    private static native float[] nio_cast(int[]copy);
81    private static native float[] nio_cast(float[]copy);    private static native float[] nio_cast(float[]copy);
82    private static native float[] nio_cast(double[]copy);    private static native float[] nio_cast(double[]copy);
83      
84    FloatBufferImpl(byte[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native byte nio_get_Byte(FloatBufferImpl b, int index, int limit); private static native void nio_put_Byte(FloatBufferImpl b, int index, int limit, byte value); public java.nio. ByteBuffer asByteBuffer() { gnu.java.nio. ByteBufferImpl res = new gnu.java.nio. ByteBufferImpl(backing_buffer); res.limit((limit()*1)/4); return res; }    FloatBufferImpl(byte[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native byte nio_get_Byte(FloatBufferImpl b, int index, int limit); private static native void nio_put_Byte(FloatBufferImpl b, int index, int limit, byte value); public java.nio. ByteBuffer asByteBuffer() { gnu.java.nio. ByteBufferImpl res = new gnu.java.nio. ByteBufferImpl(backing_buffer); res.limit((limit()*1)/4); return res; }
85    FloatBufferImpl(char[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native char nio_get_Char(FloatBufferImpl b, int index, int limit); private static native void nio_put_Char(FloatBufferImpl b, int index, int limit, char value); public java.nio. CharBuffer asCharBuffer() { gnu.java.nio. CharBufferImpl res = new gnu.java.nio. CharBufferImpl(backing_buffer); res.limit((limit()*2)/4); return res; }    FloatBufferImpl(char[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native char nio_get_Char(FloatBufferImpl b, int index, int limit); private static native void nio_put_Char(FloatBufferImpl b, int index, int limit, char value); public java.nio. CharBuffer asCharBuffer() { gnu.java.nio. CharBufferImpl res = new gnu.java.nio. CharBufferImpl(backing_buffer); res.limit((limit()*2)/4); return res; }
86    FloatBufferImpl(short[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native short nio_get_Short(FloatBufferImpl b, int index, int limit); private static native void nio_put_Short(FloatBufferImpl b, int index, int limit, short value); public java.nio. ShortBuffer asShortBuffer() { gnu.java.nio. ShortBufferImpl res = new gnu.java.nio. ShortBufferImpl(backing_buffer); res.limit((limit()*2)/4); return res; }    FloatBufferImpl(short[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native short nio_get_Short(FloatBufferImpl b, int index, int limit); private static native void nio_put_Short(FloatBufferImpl b, int index, int limit, short value); public java.nio. ShortBuffer asShortBuffer() { gnu.java.nio. ShortBufferImpl res = new gnu.java.nio. ShortBufferImpl(backing_buffer); res.limit((limit()*2)/4); return res; }
# Line 80  public final class FloatBufferImpl exten Line 88  public final class FloatBufferImpl exten
88    FloatBufferImpl(long[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native long nio_get_Long(FloatBufferImpl b, int index, int limit); private static native void nio_put_Long(FloatBufferImpl b, int index, int limit, long value); public java.nio. LongBuffer asLongBuffer() { gnu.java.nio. LongBufferImpl res = new gnu.java.nio. LongBufferImpl(backing_buffer); res.limit((limit()*8)/4); return res; }    FloatBufferImpl(long[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native long nio_get_Long(FloatBufferImpl b, int index, int limit); private static native void nio_put_Long(FloatBufferImpl b, int index, int limit, long value); public java.nio. LongBuffer asLongBuffer() { gnu.java.nio. LongBufferImpl res = new gnu.java.nio. LongBufferImpl(backing_buffer); res.limit((limit()*8)/4); return res; }
89    FloatBufferImpl(float[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native float nio_get_Float(FloatBufferImpl b, int index, int limit); private static native void nio_put_Float(FloatBufferImpl b, int index, int limit, float value); public java.nio. FloatBuffer asFloatBuffer() { gnu.java.nio. FloatBufferImpl res = new gnu.java.nio. FloatBufferImpl(backing_buffer); res.limit((limit()*4)/4); return res; }    FloatBufferImpl(float[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native float nio_get_Float(FloatBufferImpl b, int index, int limit); private static native void nio_put_Float(FloatBufferImpl b, int index, int limit, float value); public java.nio. FloatBuffer asFloatBuffer() { gnu.java.nio. FloatBufferImpl res = new gnu.java.nio. FloatBufferImpl(backing_buffer); res.limit((limit()*4)/4); return res; }
90    FloatBufferImpl(double[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native double nio_get_Double(FloatBufferImpl b, int index, int limit); private static native void nio_put_Double(FloatBufferImpl b, int index, int limit, double value); public java.nio. DoubleBuffer asDoubleBuffer() { gnu.java.nio. DoubleBufferImpl res = new gnu.java.nio. DoubleBufferImpl(backing_buffer); res.limit((limit()*8)/4); return res; }    FloatBufferImpl(double[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native double nio_get_Double(FloatBufferImpl b, int index, int limit); private static native void nio_put_Double(FloatBufferImpl b, int index, int limit, double value); public java.nio. DoubleBuffer asDoubleBuffer() { gnu.java.nio. DoubleBufferImpl res = new gnu.java.nio. DoubleBufferImpl(backing_buffer); res.limit((limit()*8)/4); return res; }
91      public boolean isReadOnly()    
92      {    public boolean isReadOnly()
93          return ro;    {
94      }      return ro;
95      public java.nio. FloatBuffer slice()    }
96      {    
97          FloatBufferImpl A = new FloatBufferImpl(this);    public java.nio. FloatBuffer slice()
98          A.array_offset = position();    {
99          return A;      FloatBufferImpl A = new FloatBufferImpl(this);
100      }      A.array_offset = position();
101      public java.nio. FloatBuffer duplicate()      return A;
102      {    }
103          return new FloatBufferImpl(this);    
104      }    public java.nio. FloatBuffer duplicate()
105      public java.nio. FloatBuffer asReadOnlyBuffer()    {
106      {      return new FloatBufferImpl(this);
107          FloatBufferImpl a = new FloatBufferImpl(this);    }
108          a.ro = true;    
109          return a;    public java.nio. FloatBuffer asReadOnlyBuffer()
110      }    {
111      public java.nio. FloatBuffer compact()      FloatBufferImpl a = new FloatBufferImpl(this);
112      {      a.ro = true;
113          return this;      return a;
114      }    }
115      public boolean isDirect()    
116      {    public java.nio. FloatBuffer compact()
117          return backing_buffer != null;    {
118      }      return this;
119      }
120      
121      public boolean isDirect()
122      {
123        return backing_buffer != null;
124      }
125      
126    final public float get()    final public float get()
127      {    {
128          float e = backing_buffer[position()];      float e = backing_buffer[position()];
129          position(position()+1);      position(position()+1);
130          return e;      return e;
131      }    }
132      
133    final public java.nio. FloatBuffer put(float b)    final public java.nio. FloatBuffer put(float b)
134      {    {
135          backing_buffer[position()] = b;      backing_buffer[position()] = b;
136          position(position()+1);      position(position()+1);
137          return this;      return this;
138      }    }
139      
140    final public float get(int index)    final public float get(int index)
141      {    {
142          return backing_buffer[index];      return backing_buffer[index];
143      }    }
144     final public java.nio. FloatBuffer put(int index, float b)    
145      {    final public java.nio. FloatBuffer put(int index, float b)
146        backing_buffer[index] = b;    {
147        return this;      backing_buffer[index] = b;
148      }      return this;
149      }
150      
151    final public char getChar() { char a = nio_get_Char(this, position(), limit()); inc_pos(2); return a; } final public java.nio. FloatBuffer putChar(char value) { nio_put_Char(this, position(), limit(), value); inc_pos(2); return this; } final public char getChar(int index) { char a = nio_get_Char(this, index, limit()); return a; } final public java.nio. FloatBuffer putChar(int index, char value) { nio_put_Char(this, index, limit(), value); return this; };    final public char getChar() { char a = nio_get_Char(this, position(), limit()); inc_pos(2); return a; } final public java.nio. FloatBuffer putChar(char value) { nio_put_Char(this, position(), limit(), value); inc_pos(2); return this; } final public char getChar(int index) { char a = nio_get_Char(this, index, limit()); return a; } final public java.nio. FloatBuffer putChar(int index, char value) { nio_put_Char(this, index, limit(), value); return this; };
152    final public short getShort() { short a = nio_get_Short(this, position(), limit()); inc_pos(2); return a; } final public java.nio. FloatBuffer putShort(short value) { nio_put_Short(this, position(), limit(), value); inc_pos(2); return this; } final public short getShort(int index) { short a = nio_get_Short(this, index, limit()); return a; } final public java.nio. FloatBuffer putShort(int index, short value) { nio_put_Short(this, index, limit(), value); return this; };    final public short getShort() { short a = nio_get_Short(this, position(), limit()); inc_pos(2); return a; } final public java.nio. FloatBuffer putShort(short value) { nio_put_Short(this, position(), limit(), value); inc_pos(2); return this; } final public short getShort(int index) { short a = nio_get_Short(this, index, limit()); return a; } final public java.nio. FloatBuffer putShort(int index, short value) { nio_put_Short(this, index, limit(), value); return this; };
153    final public int getInt() { int a = nio_get_Int(this, position(), limit()); inc_pos(4); return a; } final public java.nio. FloatBuffer putInt(int value) { nio_put_Int(this, position(), limit(), value); inc_pos(4); return this; } final public int getInt(int index) { int a = nio_get_Int(this, index, limit()); return a; } final public java.nio. FloatBuffer putInt(int index, int value) { nio_put_Int(this, index, limit(), value); return this; };    final public int getInt() { int a = nio_get_Int(this, position(), limit()); inc_pos(4); return a; } final public java.nio. FloatBuffer putInt(int value) { nio_put_Int(this, position(), limit(), value); inc_pos(4); return this; } final public int getInt(int index) { int a = nio_get_Int(this, index, limit()); return a; } final public java.nio. FloatBuffer putInt(int index, int value) { nio_put_Int(this, index, limit(), value); return this; };

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.8

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26