/[classpath]/classpath/java/nio/DoubleBuffer.java
ViewVC logotype

Diff of /classpath/java/nio/DoubleBuffer.java

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

revision 1.10 by mkoch, Sun May 18 12:12:40 2003 UTC revision 1.11 by mkoch, Mon May 19 08:36:27 2003 UTC
# Line 51  public abstract class DoubleBuffer exten Line 51  public abstract class DoubleBuffer exten
51    protected DoubleBuffer (int capacity, int limit, int position, int mark)    protected DoubleBuffer (int capacity, int limit, int position, int mark)
52    {    {
53      super (capacity, limit, position, mark);      super (capacity, limit, position, mark);
54        array_offset = 0;
55    }    }
56      
57    public static DoubleBuffer allocate(int capacity)    protected DoubleBuffer (double[] buffer, int offset, int capacity, int limit, int position, int mark)
58      {
59        super (capacity, limit, position, mark);
60        this.backing_buffer = buffer;
61        this.array_offset = offset;
62      }
63    
64      /**
65       * Allocates a new <code>DoubleBuffer</code> object with a given capacity.
66       */
67      public static DoubleBuffer allocate (int capacity)
68    {    {
69      return new DoubleBufferImpl(capacity, 0, capacity);      return new DoubleBufferImpl (capacity);
70    }    }
71    
72      /**
73       * Wraps a <code>double</code> array into a <code>DoubleBuffer</code>
74       * object.
75       *
76       * @exception IndexOutOfBoundsException If the preconditions on the offset
77       * and length parameters do not hold
78       */
79    final public static DoubleBuffer wrap (double[] array, int offset, int length)    final public static DoubleBuffer wrap (double[] array, int offset, int length)
80    {    {
81      return new DoubleBufferImpl(array, offset, length);      return new DoubleBufferImpl (array, 0, array.length, offset + length, offset, -1, false);
82    }    }
83    
84    /**    /**
# Line 71  public abstract class DoubleBuffer exten Line 89  public abstract class DoubleBuffer exten
89    {    {
90      return wrap (array, 0, array.length);      return wrap (array, 0, array.length);
91    }    }
92      
93    /**    /**
94     * This method transfers <code>doubles<code> from this buffer into the given     * This method transfers <code>doubles<code> from this buffer into the given
95     * destination array.     * destination array.
# Line 124  public abstract class DoubleBuffer exten Line 142  public abstract class DoubleBuffer exten
142     */     */
143    public DoubleBuffer put (DoubleBuffer src)    public DoubleBuffer put (DoubleBuffer src)
144    {    {
145      while (src.hasRemaining())      if (src == this)
146        put(src.get());        throw new IllegalArgumentException ();
147    
148        if (src.remaining () > remaining ())
149          throw new BufferOverflowException ();
150    
151        if (src.remaining () > 0)
152          {
153            double[] toPut = new double [src.remaining ()];
154            src.get (toPut);
155            src.put (toPut);
156          }
157    
158      return this;      return this;
159    }    }

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11

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