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

Diff of /classpath/gnu/java/nio/DoubleBufferImpl.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 DoubleBufferImpl extends java.nio. DoubleBuffer  import java.nio.DoubleBuffer;
41    
42    public final class DoubleBufferImpl extends DoubleBuffer
43  {  {
44      private int array_offset;    private int array_offset;
45      private boolean ro;    private boolean ro;
46      
47    public DoubleBufferImpl(int cap, int off, int lim)    public DoubleBufferImpl(int cap, int off, int lim)
48      {    {
49        this.backing_buffer = new double[cap];      this.backing_buffer = new double[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 DoubleBufferImpl(double[] array, int off, int lim)    public DoubleBufferImpl(double[] 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 DoubleBufferImpl(DoubleBufferImpl copy)    public DoubleBufferImpl(DoubleBufferImpl 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 double[] nio_cast(byte[]copy);    private static native double[] nio_cast(byte[]copy);
77    private static native double[] nio_cast(char[]copy);    private static native double[] nio_cast(char[]copy);
78    private static native double[] nio_cast(short[]copy);    private static native double[] nio_cast(short[]copy);
# Line 73  public final class DoubleBufferImpl exte Line 80  public final class DoubleBufferImpl exte
80    private static native double[] nio_cast(int[]copy);    private static native double[] nio_cast(int[]copy);
81    private static native double[] nio_cast(float[]copy);    private static native double[] nio_cast(float[]copy);
82    private static native double[] nio_cast(double[]copy);    private static native double[] nio_cast(double[]copy);
83    
84    DoubleBufferImpl(byte[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native byte nio_get_Byte(DoubleBufferImpl b, int index, int limit); private static native void nio_put_Byte(DoubleBufferImpl 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)/8); return res; }    DoubleBufferImpl(byte[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native byte nio_get_Byte(DoubleBufferImpl b, int index, int limit); private static native void nio_put_Byte(DoubleBufferImpl 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)/8); return res; }
85    DoubleBufferImpl(char[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native char nio_get_Char(DoubleBufferImpl b, int index, int limit); private static native void nio_put_Char(DoubleBufferImpl 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)/8); return res; }    DoubleBufferImpl(char[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native char nio_get_Char(DoubleBufferImpl b, int index, int limit); private static native void nio_put_Char(DoubleBufferImpl 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)/8); return res; }
86    DoubleBufferImpl(short[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native short nio_get_Short(DoubleBufferImpl b, int index, int limit); private static native void nio_put_Short(DoubleBufferImpl 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)/8); return res; }    DoubleBufferImpl(short[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native short nio_get_Short(DoubleBufferImpl b, int index, int limit); private static native void nio_put_Short(DoubleBufferImpl 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)/8); return res; }
# Line 80  public final class DoubleBufferImpl exte Line 88  public final class DoubleBufferImpl exte
88    DoubleBufferImpl(long[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native long nio_get_Long(DoubleBufferImpl b, int index, int limit); private static native void nio_put_Long(DoubleBufferImpl 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)/8); return res; }    DoubleBufferImpl(long[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native long nio_get_Long(DoubleBufferImpl b, int index, int limit); private static native void nio_put_Long(DoubleBufferImpl 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)/8); return res; }
89    DoubleBufferImpl(float[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native float nio_get_Float(DoubleBufferImpl b, int index, int limit); private static native void nio_put_Float(DoubleBufferImpl 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)/8); return res; }    DoubleBufferImpl(float[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native float nio_get_Float(DoubleBufferImpl b, int index, int limit); private static native void nio_put_Float(DoubleBufferImpl 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)/8); return res; }
90    DoubleBufferImpl(double[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native double nio_get_Double(DoubleBufferImpl b, int index, int limit); private static native void nio_put_Double(DoubleBufferImpl 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)/8); return res; }    DoubleBufferImpl(double[] copy) { this.backing_buffer = copy != null ? nio_cast(copy) : null; } private static native double nio_get_Double(DoubleBufferImpl b, int index, int limit); private static native void nio_put_Double(DoubleBufferImpl 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)/8); return res; }
91      public boolean isReadOnly()  
92      {    public boolean isReadOnly()
93          return ro;    {
94      }      return ro;
95      public java.nio. DoubleBuffer slice()    }
96      {  
97          DoubleBufferImpl A = new DoubleBufferImpl(this);    public java.nio. DoubleBuffer slice()
98          A.array_offset = position();    {
99          return A;      DoubleBufferImpl A = new DoubleBufferImpl(this);
100      }      A.array_offset = position();
101      public java.nio. DoubleBuffer duplicate()      return A;
102      {    }
103          return new DoubleBufferImpl(this);  
104      }    public java.nio. DoubleBuffer duplicate()
105      public java.nio. DoubleBuffer asReadOnlyBuffer()    {
106      {      return new DoubleBufferImpl(this);
107          DoubleBufferImpl a = new DoubleBufferImpl(this);    }
108          a.ro = true;  
109          return a;    public java.nio. DoubleBuffer asReadOnlyBuffer()
110      }    {
111      public java.nio. DoubleBuffer compact()      DoubleBufferImpl a = new DoubleBufferImpl(this);
112      {      a.ro = true;
113          return this;      return a;
114      }    }
115      public boolean isDirect()  
116      {    public java.nio. DoubleBuffer 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 double get()    final public double get()
127      {    {
128          double e = backing_buffer[position()];      double e = backing_buffer[position()];
129          position(position()+1);      position(position()+1);
130          return e;      return e;
131      }    }
132    
133    final public java.nio. DoubleBuffer put(double b)    final public java.nio. DoubleBuffer put(double 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 double get(int index)    final public double get(int index)
141      {    {
142          return backing_buffer[index];      return backing_buffer[index];
143      }    }
144     final public java.nio. DoubleBuffer put(int index, double b)  
145      {    final public java.nio. DoubleBuffer put(int index, double 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. DoubleBuffer 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. DoubleBuffer 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. DoubleBuffer 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. DoubleBuffer 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. DoubleBuffer 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. DoubleBuffer 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. DoubleBuffer 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. DoubleBuffer 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. DoubleBuffer 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. DoubleBuffer 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. DoubleBuffer 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. DoubleBuffer 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