51 |
protected IntBuffer (int capacity, int limit, int position, int mark) |
protected IntBuffer (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 IntBuffer allocate(int capacity) |
protected IntBuffer (int[] 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>IntBuffer</code> object with a given capacity. |
66 |
|
*/ |
67 |
|
public static IntBuffer allocate (int capacity) |
68 |
{ |
{ |
69 |
return new IntBufferImpl (capacity, 0, capacity); |
return new IntBufferImpl (capacity); |
70 |
} |
} |
71 |
|
|
72 |
final public static IntBuffer wrap(int[] array, int offset, int length) |
/** |
73 |
|
* Wraps a <code>int</code> array into a <code>IntBuffer</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 IntBuffer wrap (int[] array, int offset, int length) |
80 |
{ |
{ |
81 |
return new IntBufferImpl(array, offset, length); |
return new IntBufferImpl (array, 0, array.length, offset + length, offset, -1, false); |
82 |
} |
} |
83 |
|
|
84 |
/** |
/** |
89 |
{ |
{ |
90 |
return wrap (array, 0, array.length); |
return wrap (array, 0, array.length); |
91 |
} |
} |
92 |
|
|
93 |
/** |
/** |
94 |
* This method transfers <code>ints<code> from this buffer into the given |
* This method transfers <code>ints<code> from this buffer into the given |
95 |
* destination array. |
* destination array. |
142 |
*/ |
*/ |
143 |
public IntBuffer put (IntBuffer src) |
public IntBuffer put (IntBuffer 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 |
|
int[] toPut = new int [src.remaining ()]; |
154 |
|
src.get (toPut); |
155 |
|
src.put (toPut); |
156 |
|
} |
157 |
|
|
158 |
return this; |
return this; |
159 |
} |
} |