Made byteOrder implicit in ByteIterator methods
This commit is contained in:
parent
5d7823fd49
commit
18e6e3ed7a
1 changed files with 20 additions and 20 deletions
|
|
@ -129,7 +129,7 @@ abstract class ByteIterator extends BufferedIterator[Byte] {
|
||||||
/**
|
/**
|
||||||
* Get a single Short from this iterator.
|
* Get a single Short from this iterator.
|
||||||
*/
|
*/
|
||||||
def getShort(byteOrder: ByteOrder = ByteOrder.BIG_ENDIAN): Short = {
|
def getShort(implicit byteOrder: ByteOrder = ByteOrder.BIG_ENDIAN): Short = {
|
||||||
if (byteOrder == ByteOrder.BIG_ENDIAN)
|
if (byteOrder == ByteOrder.BIG_ENDIAN)
|
||||||
((next() & 0xff) << 8 | (next() & 0xff) << 0).toShort
|
((next() & 0xff) << 8 | (next() & 0xff) << 0).toShort
|
||||||
else if (byteOrder == ByteOrder.LITTLE_ENDIAN)
|
else if (byteOrder == ByteOrder.LITTLE_ENDIAN)
|
||||||
|
|
@ -140,7 +140,7 @@ abstract class ByteIterator extends BufferedIterator[Byte] {
|
||||||
/**
|
/**
|
||||||
* Get a single Int from this iterator.
|
* Get a single Int from this iterator.
|
||||||
*/
|
*/
|
||||||
def getInt(byteOrder: ByteOrder = ByteOrder.BIG_ENDIAN): Int = {
|
def getInt(implicit byteOrder: ByteOrder = ByteOrder.BIG_ENDIAN): Int = {
|
||||||
if (byteOrder == ByteOrder.BIG_ENDIAN)
|
if (byteOrder == ByteOrder.BIG_ENDIAN)
|
||||||
((next() & 0xff) << 24
|
((next() & 0xff) << 24
|
||||||
| (next() & 0xff) << 16
|
| (next() & 0xff) << 16
|
||||||
|
|
@ -157,7 +157,7 @@ abstract class ByteIterator extends BufferedIterator[Byte] {
|
||||||
/**
|
/**
|
||||||
* Get a single Long from this iterator.
|
* Get a single Long from this iterator.
|
||||||
*/
|
*/
|
||||||
def getLong(byteOrder: ByteOrder = ByteOrder.BIG_ENDIAN): Long = {
|
def getLong(implicit byteOrder: ByteOrder = ByteOrder.BIG_ENDIAN): Long = {
|
||||||
if (byteOrder == ByteOrder.BIG_ENDIAN)
|
if (byteOrder == ByteOrder.BIG_ENDIAN)
|
||||||
((next().toLong & 0xff) << 56
|
((next().toLong & 0xff) << 56
|
||||||
| (next().toLong & 0xff) << 48
|
| (next().toLong & 0xff) << 48
|
||||||
|
|
@ -179,10 +179,10 @@ abstract class ByteIterator extends BufferedIterator[Byte] {
|
||||||
else throw new IllegalArgumentException("Unknown byte order " + byteOrder)
|
else throw new IllegalArgumentException("Unknown byte order " + byteOrder)
|
||||||
}
|
}
|
||||||
|
|
||||||
def getFloat(byteOrder: ByteOrder = ByteOrder.BIG_ENDIAN): Float =
|
def getFloat(implicit byteOrder: ByteOrder = ByteOrder.BIG_ENDIAN): Float =
|
||||||
java.lang.Float.intBitsToFloat(getInt(byteOrder))
|
java.lang.Float.intBitsToFloat(getInt(byteOrder))
|
||||||
|
|
||||||
def getDouble(byteOrder: ByteOrder = ByteOrder.BIG_ENDIAN): Double =
|
def getDouble(implicit byteOrder: ByteOrder = ByteOrder.BIG_ENDIAN): Double =
|
||||||
java.lang.Double.longBitsToDouble(getLong(byteOrder))
|
java.lang.Double.longBitsToDouble(getLong(byteOrder))
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -194,27 +194,27 @@ abstract class ByteIterator extends BufferedIterator[Byte] {
|
||||||
/**
|
/**
|
||||||
* Get a number of Shorts from this iterator.
|
* Get a number of Shorts from this iterator.
|
||||||
*/
|
*/
|
||||||
def getShorts(xs: Array[Short], offset: Int, n: Int, byteOrder: ByteOrder = ByteOrder.BIG_ENDIAN): this.type
|
def getShorts(xs: Array[Short], offset: Int, n: Int)(implicit byteOrder: ByteOrder = ByteOrder.BIG_ENDIAN): this.type
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a number of Ints from this iterator.
|
* Get a number of Ints from this iterator.
|
||||||
*/
|
*/
|
||||||
def getInts(xs: Array[Int], offset: Int, n: Int, byteOrder: ByteOrder = ByteOrder.BIG_ENDIAN): this.type
|
def getInts(xs: Array[Int], offset: Int, n: Int)(implicit byteOrder: ByteOrder = ByteOrder.BIG_ENDIAN): this.type
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a number of Longs from this iterator.
|
* Get a number of Longs from this iterator.
|
||||||
*/
|
*/
|
||||||
def getLongs(xs: Array[Long], offset: Int, n: Int, byteOrder: ByteOrder = ByteOrder.BIG_ENDIAN): this.type
|
def getLongs(xs: Array[Long], offset: Int, n: Int)(implicit byteOrder: ByteOrder = ByteOrder.BIG_ENDIAN): this.type
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a number of Floats from this iterator.
|
* Get a number of Floats from this iterator.
|
||||||
*/
|
*/
|
||||||
def getFloats(xs: Array[Float], offset: Int, n: Int, byteOrder: ByteOrder = ByteOrder.BIG_ENDIAN): this.type
|
def getFloats(xs: Array[Float], offset: Int, n: Int)(implicit byteOrder: ByteOrder = ByteOrder.BIG_ENDIAN): this.type
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a number of Doubles from this iterator.
|
* Get a number of Doubles from this iterator.
|
||||||
*/
|
*/
|
||||||
def getDoubles(xs: Array[Double], offset: Int, n: Int, byteOrder: ByteOrder = ByteOrder.BIG_ENDIAN): this.type
|
def getDoubles(xs: Array[Double], offset: Int, n: Int)(implicit byteOrder: ByteOrder = ByteOrder.BIG_ENDIAN): this.type
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copy as many bytes as possible to a ByteBuffer, starting from it's
|
* Copy as many bytes as possible to a ByteBuffer, starting from it's
|
||||||
|
|
@ -342,19 +342,19 @@ class ByteArrayIterator private (private var array: Array[Byte], private var fro
|
||||||
} else Iterator.empty.next
|
} else Iterator.empty.next
|
||||||
}
|
}
|
||||||
|
|
||||||
def getShorts(xs: Array[Short], offset: Int, n: Int, byteOrder: ByteOrder = ByteOrder.BIG_ENDIAN) =
|
def getShorts(xs: Array[Short], offset: Int, n: Int)(implicit byteOrder: ByteOrder = ByteOrder.BIG_ENDIAN) =
|
||||||
{ toByteString.asByteBuffer.order(byteOrder).asShortBuffer.get(xs, offset, n); drop(2 * n) }
|
{ toByteString.asByteBuffer.order(byteOrder).asShortBuffer.get(xs, offset, n); drop(2 * n) }
|
||||||
|
|
||||||
def getInts(xs: Array[Int], offset: Int, n: Int, byteOrder: ByteOrder = ByteOrder.BIG_ENDIAN) =
|
def getInts(xs: Array[Int], offset: Int, n: Int)(implicit byteOrder: ByteOrder = ByteOrder.BIG_ENDIAN) =
|
||||||
{ toByteString.asByteBuffer.order(byteOrder).asIntBuffer.get(xs, offset, n); drop(4 * n) }
|
{ toByteString.asByteBuffer.order(byteOrder).asIntBuffer.get(xs, offset, n); drop(4 * n) }
|
||||||
|
|
||||||
def getLongs(xs: Array[Long], offset: Int, n: Int, byteOrder: ByteOrder = ByteOrder.BIG_ENDIAN) =
|
def getLongs(xs: Array[Long], offset: Int, n: Int)(implicit byteOrder: ByteOrder = ByteOrder.BIG_ENDIAN) =
|
||||||
{ toByteString.asByteBuffer.order(byteOrder).asLongBuffer.get(xs, offset, n); drop(8 * n) }
|
{ toByteString.asByteBuffer.order(byteOrder).asLongBuffer.get(xs, offset, n); drop(8 * n) }
|
||||||
|
|
||||||
def getFloats(xs: Array[Float], offset: Int, n: Int, byteOrder: ByteOrder = ByteOrder.BIG_ENDIAN) =
|
def getFloats(xs: Array[Float], offset: Int, n: Int)(implicit byteOrder: ByteOrder = ByteOrder.BIG_ENDIAN) =
|
||||||
{ toByteString.asByteBuffer.order(byteOrder).asFloatBuffer.get(xs, offset, n); drop(4 * n) }
|
{ toByteString.asByteBuffer.order(byteOrder).asFloatBuffer.get(xs, offset, n); drop(4 * n) }
|
||||||
|
|
||||||
def getDoubles(xs: Array[Double], offset: Int, n: Int, byteOrder: ByteOrder = ByteOrder.BIG_ENDIAN) =
|
def getDoubles(xs: Array[Double], offset: Int, n: Int)(implicit byteOrder: ByteOrder = ByteOrder.BIG_ENDIAN) =
|
||||||
{ toByteString.asByteBuffer.order(byteOrder).asDoubleBuffer.get(xs, offset, n); drop(8 * n) }
|
{ toByteString.asByteBuffer.order(byteOrder).asDoubleBuffer.get(xs, offset, n); drop(8 * n) }
|
||||||
|
|
||||||
def copyToBuffer(buffer: ByteBuffer): Int = {
|
def copyToBuffer(buffer: ByteBuffer): Int = {
|
||||||
|
|
@ -525,19 +525,19 @@ class MultiByteArrayIterator private (private var iterators: List[ByteArrayItera
|
||||||
def getBytes(xs: Array[Byte], offset: Int, n: Int) =
|
def getBytes(xs: Array[Byte], offset: Int, n: Int) =
|
||||||
getToArray(xs, offset, n, 1) { getByte } { getBytes(_, _, _) }
|
getToArray(xs, offset, n, 1) { getByte } { getBytes(_, _, _) }
|
||||||
|
|
||||||
def getShorts(xs: Array[Short], offset: Int, n: Int, byteOrder: ByteOrder = ByteOrder.BIG_ENDIAN) =
|
def getShorts(xs: Array[Short], offset: Int, n: Int)(implicit byteOrder: ByteOrder = ByteOrder.BIG_ENDIAN) =
|
||||||
getToArray(xs, offset, n, 2) { getShort(byteOrder) } { current.getShorts(_, _, _)(byteOrder) }
|
getToArray(xs, offset, n, 2) { getShort(byteOrder) } { current.getShorts(_, _, _)(byteOrder) }
|
||||||
|
|
||||||
def getInts(xs: Array[Int], offset: Int, n: Int, byteOrder: ByteOrder = ByteOrder.BIG_ENDIAN) =
|
def getInts(xs: Array[Int], offset: Int, n: Int)(implicit byteOrder: ByteOrder = ByteOrder.BIG_ENDIAN) =
|
||||||
getToArray(xs, offset, n, 4) { getInt(byteOrder) } { current.getInts(_, _, _)(byteOrder) }
|
getToArray(xs, offset, n, 4) { getInt(byteOrder) } { current.getInts(_, _, _)(byteOrder) }
|
||||||
|
|
||||||
def getLongs(xs: Array[Long], offset: Int, n: Int, byteOrder: ByteOrder = ByteOrder.BIG_ENDIAN) =
|
def getLongs(xs: Array[Long], offset: Int, n: Int)(implicit byteOrder: ByteOrder = ByteOrder.BIG_ENDIAN) =
|
||||||
getToArray(xs, offset, n, 8) { getLong(byteOrder) } { current.getLongs(_, _, _)(byteOrder) }
|
getToArray(xs, offset, n, 8) { getLong(byteOrder) } { current.getLongs(_, _, _)(byteOrder) }
|
||||||
|
|
||||||
def getFloats(xs: Array[Float], offset: Int, n: Int, byteOrder: ByteOrder = ByteOrder.BIG_ENDIAN) =
|
def getFloats(xs: Array[Float], offset: Int, n: Int)(implicit byteOrder: ByteOrder = ByteOrder.BIG_ENDIAN) =
|
||||||
getToArray(xs, offset, n, 8) { getFloat(byteOrder) } { current.getFloats(_, _, _)(byteOrder) }
|
getToArray(xs, offset, n, 8) { getFloat(byteOrder) } { current.getFloats(_, _, _)(byteOrder) }
|
||||||
|
|
||||||
def getDoubles(xs: Array[Double], offset: Int, n: Int, byteOrder: ByteOrder = ByteOrder.BIG_ENDIAN) =
|
def getDoubles(xs: Array[Double], offset: Int, n: Int)(implicit byteOrder: ByteOrder = ByteOrder.BIG_ENDIAN) =
|
||||||
getToArray(xs, offset, n, 8) { getDouble(byteOrder) } { current.getDoubles(_, _, _)(byteOrder) }
|
getToArray(xs, offset, n, 8) { getDouble(byteOrder) } { current.getDoubles(_, _, _)(byteOrder) }
|
||||||
|
|
||||||
def copyToBuffer(buffer: ByteBuffer): Int = {
|
def copyToBuffer(buffer: ByteBuffer): Int = {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue