mirror of
https://github.com/OpenHFT/Chronicle-Map.git
synced 2021-09-13 01:26:12 +00:00
Add a DoubleArray example.
This commit is contained in:
@@ -3,11 +3,12 @@ package net.openhft.lang.values;
|
||||
import net.openhft.lang.io.Bytes;
|
||||
import net.openhft.lang.io.DirectStore;
|
||||
import net.openhft.lang.model.Byteable;
|
||||
import net.openhft.lang.model.Copyable;
|
||||
|
||||
/**
|
||||
* Created by peter.lawrey on 23/04/2015.
|
||||
*/
|
||||
public class DoubleArray implements Byteable {
|
||||
public class DoubleArray implements Byteable, Copyable<DoubleArray> {
|
||||
private static int LENGTH = 0; // assume a 32-bit size.
|
||||
private static int CAPACITY = LENGTH + 4; // assume a 32-bit size.
|
||||
private static int BASE = CAPACITY + 4;
|
||||
@@ -20,6 +21,7 @@ public class DoubleArray implements Byteable {
|
||||
offset = 0;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void bytes(Bytes bytes, long offset) {
|
||||
this.bytes = bytes;
|
||||
@@ -86,4 +88,12 @@ public class DoubleArray implements Byteable {
|
||||
doubles[index] = bytes.readDouble(BASE + offset + index * 8L);
|
||||
return length;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void copyFrom(DoubleArray doubleArray) {
|
||||
int length = length();
|
||||
doubleArray.setLength(length);
|
||||
for (int i = 0; i < length; i++)
|
||||
doubleArray.setDataAt(i, getDataAt(i));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user