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

Diff of /classpath/java/nio/ShortBuffer.java

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

revision 1.11 by mkoch, Sun May 18 12:12:40 2003 UTC revision 1.12 by mkoch, Mon May 19 08:36:27 2003 UTC
# Line 51  public abstract class ShortBuffer extend Line 51  public abstract class ShortBuffer extend
51    protected ShortBuffer (int capacity, int limit, int position, int mark)    protected ShortBuffer (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 ShortBuffer allocate(int capacity)    protected ShortBuffer (short[] 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>ShortBuffer</code> object with a given capacity.
66       */
67      public static ShortBuffer allocate (int capacity)
68    {    {
69      return new ShortBufferImpl(capacity, 0, capacity);      return new ShortBufferImpl (capacity);
70    }    }
71    
72    final public static ShortBuffer wrap(short[] array, int offset, int length)    /**
73       * Wraps a <code>short</code> array into a <code>ShortBuffer</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 ShortBuffer wrap (short[] array, int offset, int length)
80    {    {
81      return new ShortBufferImpl(array, offset, length);      return new ShortBufferImpl (array, 0, array.length, offset + length, offset, -1, false);
82    }    }
83    
84    /**    /**
# Line 71  public abstract class ShortBuffer extend Line 89  public abstract class ShortBuffer extend
89    {    {
90      return wrap (array, 0, array.length);      return wrap (array, 0, array.length);
91    }    }
92      
93    /**    /**
94     * This method transfers <code>shorts<code> from this buffer into the given     * This method transfers <code>shorts<code> from this buffer into the given
95     * destination array.     * destination array.
# Line 124  public abstract class ShortBuffer extend Line 142  public abstract class ShortBuffer extend
142     */     */
143    public ShortBuffer put (ShortBuffer src)    public ShortBuffer put (ShortBuffer 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            short[] toPut = new short [src.remaining ()];
154            src.get (toPut);
155            src.put (toPut);
156          }
157    
158      return this;      return this;
159    }    }

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

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