/[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.13 by mkoch, Tue Mar 11 08:02:22 2003 UTC revision 1.14 by mkoch, Tue Mar 11 11:48:51 2003 UTC
# Line 40  package gnu.java.nio; Line 40  package gnu.java.nio;
40  import java.nio.ByteBuffer;  import java.nio.ByteBuffer;
41  import java.nio.ByteOrder;  import java.nio.ByteOrder;
42  import java.nio.FloatBuffer;  import java.nio.FloatBuffer;
43    import java.nio.ReadOnlyBufferException;
44    
45    /**
46     * This is a Heap memory implementation
47     */
48  public final class FloatBufferImpl extends FloatBuffer  public final class FloatBufferImpl extends FloatBuffer
49  {  {
50    private int array_offset;    private boolean readOnly;
   private boolean ro;  
51        
52    public FloatBufferImpl(int cap, int off, int lim)    public FloatBufferImpl(int cap, int off, int lim)
53    {    {
54      this.backing_buffer = new float[cap];      super (cap, lim, off, 0);
55      this.cap = cap;      this.backing_buffer = new float [cap];
56      this.limit(lim);      readOnly = false;
     this.position(off);  
57    }    }
58        
59    public FloatBufferImpl(float[] array, int off, int lim)    public FloatBufferImpl(float[] array, int offset, int length)
60    {    {
61        super (array.length, length, offset, 0);
62      this.backing_buffer = array;      this.backing_buffer = array;
63      this.cap = array.length;      readOnly = false;
     this.limit(lim);  
     this.position(off);  
64    }    }
65        
66    public FloatBufferImpl(FloatBufferImpl copy)    public FloatBufferImpl(FloatBufferImpl copy)
67    {    {
68        super (copy.capacity (), copy.limit (), copy.position (), 0);
69      backing_buffer = copy.backing_buffer;      backing_buffer = copy.backing_buffer;
70      ro = copy.ro;      readOnly = copy.isReadOnly ();
     limit(copy.limit());  
     position(copy.position());  
   }  
     
   void inc_pos(int a)  
   {  
     position(position() + a);  
71    }    }
72        
73    private static native float[] nio_cast (byte[] copy);    private static native float[] nio_cast (byte[] copy);
74        
75    FloatBufferImpl (byte[] copy)    FloatBufferImpl (byte[] copy)
76    {    {
77        super (copy.length, copy.length, 0, 0);
78      this.backing_buffer = copy != null ? nio_cast  (copy) : null;      this.backing_buffer = copy != null ? nio_cast  (copy) : null;
79        readOnly = false;
80    }    }
81    
82    private static native byte nio_get_Byte (FloatBufferImpl b, int index, int limit);    private static native byte nio_get_Byte (FloatBufferImpl b, int index, int limit);
# Line 93  public final class FloatBufferImpl exten Line 90  public final class FloatBufferImpl exten
90      return res;      return res;
91    }    }
92        
93    public boolean isReadOnly()    public boolean isReadOnly ()
94    {    {
95      return ro;      return readOnly;
96    }    }
97        
98    public FloatBuffer slice()    public FloatBuffer slice()
99    {    {
100      FloatBufferImpl A = new FloatBufferImpl(this);      return new FloatBufferImpl (this);
     A.array_offset = position();  
     return A;  
101    }    }
102        
103    public FloatBuffer duplicate()    public FloatBuffer duplicate()
# Line 112  public final class FloatBufferImpl exten Line 107  public final class FloatBufferImpl exten
107        
108    public FloatBuffer asReadOnlyBuffer()    public FloatBuffer asReadOnlyBuffer()
109    {    {
110      FloatBufferImpl a = new FloatBufferImpl(this);      FloatBufferImpl result = new FloatBufferImpl (this);
111      a.ro = true;      result.readOnly = true;
112      return a;      return result;
113    }    }
114        
115    public FloatBuffer compact()    public FloatBuffer compact()
# Line 124  public final class FloatBufferImpl exten Line 119  public final class FloatBufferImpl exten
119        
120    public boolean isDirect()    public boolean isDirect()
121    {    {
122      return backing_buffer != null;      return false;
123    }    }
124        
125    final public float get()    final public float get()
# Line 136  public final class FloatBufferImpl exten Line 131  public final class FloatBufferImpl exten
131        
132    final public FloatBuffer put(float b)    final public FloatBuffer put(float b)
133    {    {
134        if (readOnly)
135          throw new ReadOnlyBufferException ();
136        
137      backing_buffer[position()] = b;      backing_buffer[position()] = b;
138      position(position()+1);      position(position()+1);
139      return this;      return this;
# Line 148  public final class FloatBufferImpl exten Line 146  public final class FloatBufferImpl exten
146        
147    final public FloatBuffer put(int index, float b)    final public FloatBuffer put(int index, float b)
148    {    {
149        if (readOnly)
150          throw new ReadOnlyBufferException ();
151        
152      backing_buffer[index] = b;      backing_buffer[index] = b;
153      return this;      return this;
154    }    }

Legend:
Removed from v.1.13  
changed lines
  Added in v.1.14

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