5029431: (bf) Add absolute bulk put and get methods

Reviewed-by: alanb, darcy, chegar, rriggs
This commit is contained in:
Brian Burkhalter 2019-02-20 10:57:22 -08:00
parent 2ee61b353b
commit 315b7d0399
12 changed files with 804 additions and 29 deletions

View file

@ -1,5 +1,5 @@
/*
* Copyright (c) 2000, 2016, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@ -38,6 +38,8 @@ package java.nio;
#end[rw]
*/
import java.util.Objects;
class Heap$Type$Buffer$RW$
extends {#if[ro]?Heap}$Type$Buffer
{
@ -181,6 +183,13 @@ class Heap$Type$Buffer$RW$
return this;
}
public $Type$Buffer get(int index, $type$[] dst, int offset, int length) {
Objects.checkFromIndexSize(index, length, limit());
Objects.checkFromIndexSize(offset, length, dst.length);
System.arraycopy(hb, ix(index), dst, offset, length);
return this;
}
public boolean isDirect() {
return false;
}
@ -250,6 +259,17 @@ class Heap$Type$Buffer$RW$
#end[rw]
}
public $Type$Buffer put(int index, $type$[] src, int offset, int length) {
#if[rw]
Objects.checkFromIndexSize(index, length, limit());
Objects.checkFromIndexSize(offset, length, src.length);
System.arraycopy(src, offset, hb, ix(index), length);
return this;
#else[rw]
throw new ReadOnlyBufferException();
#end[rw]
}
public $Type$Buffer compact() {
#if[rw]
System.arraycopy(hb, ix(position()), hb, ix(0), remaining());