mirror of
https://github.com/openjdk/jdk.git
synced 2025-08-27 06:45:07 +02:00
5071718: (bf) Add ByteBuffer.slice(int offset, int length)
Reviewed-by: alanb, bchristi, darcy, rriggs
This commit is contained in:
parent
8f84ae5684
commit
fad1f059b0
17 changed files with 367 additions and 77 deletions
|
@ -27,6 +27,8 @@
|
|||
|
||||
package java.nio;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
#if[rw]
|
||||
* A read/write Heap$Type$Buffer.
|
||||
|
@ -38,8 +40,6 @@ package java.nio;
|
|||
#end[rw]
|
||||
*/
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
class Heap$Type$Buffer$RW$
|
||||
extends {#if[ro]?Heap}$Type$Buffer
|
||||
{
|
||||
|
@ -112,19 +112,17 @@ class Heap$Type$Buffer$RW$
|
|||
this.position() + offset);
|
||||
}
|
||||
|
||||
#if[byte]
|
||||
$Type$Buffer slice(int pos, int lim) {
|
||||
assert (pos >= 0);
|
||||
assert (pos <= lim);
|
||||
int rem = lim - pos;
|
||||
@Override
|
||||
public $Type$Buffer slice(int index, int length) {
|
||||
Objects.checkIndex(index, limit() + 1);
|
||||
Objects.checkIndex(length, limit() - index + 1);
|
||||
return new Heap$Type$Buffer$RW$(hb,
|
||||
-1,
|
||||
0,
|
||||
rem,
|
||||
rem,
|
||||
pos + offset);
|
||||
length,
|
||||
length,
|
||||
index + offset);
|
||||
}
|
||||
#end[byte]
|
||||
|
||||
public $Type$Buffer duplicate() {
|
||||
return new Heap$Type$Buffer$RW$(hb,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue