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

Diff of /classpath/java/nio/LongBuffer.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 LongBuffer extends Line 51  public abstract class LongBuffer extends
51    protected LongBuffer (int capacity, int limit, int position, int mark)    protected LongBuffer (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 LongBuffer allocate(int capacity)    protected LongBuffer (long[] 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>LongBuffer</code> object with a given capacity.
66       */
67      public static LongBuffer allocate (int capacity)
68    {    {
69      return new LongBufferImpl(capacity, 0, capacity);      return new LongBufferImpl (capacity);
70    }    }
71    
72    final public static LongBuffer wrap(long[] array, int offset, int length)    /**
73       * Wraps a <code>long</code> array into a <code>LongBuffer</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 LongBuffer wrap (long[] array, int offset, int length)
80    {    {
81      return new LongBufferImpl (array, offset, length);      return new LongBufferImpl (array, 0, array.length, offset + length, offset, -1, false);
82    }    }
83    
84    /**    /**
# Line 71  public abstract class LongBuffer extends Line 89  public abstract class LongBuffer extends
89    {    {
90      return wrap (array, 0, array.length);      return wrap (array, 0, array.length);
91    }    }
92      
93    /**    /**
94     * This method transfers <code>longs<code> from this buffer into the given     * This method transfers <code>longs<code> from this buffer into the given
95     * destination array.     * destination array.
# Line 124  public abstract class LongBuffer extends Line 142  public abstract class LongBuffer extends
142     */     */
143    public LongBuffer put (LongBuffer src)    public LongBuffer put (LongBuffer 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            long[] toPut = new long [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