From 952eab125925ad111c4a0734946b7e99a7437bf7 Mon Sep 17 00:00:00 2001 From: Peter Lawrey Date: Thu, 23 Apr 2015 17:46:43 +0100 Subject: [PATCH] Add a DoubleArray example. --- .../java/net/openhft/lang/values/DoubleArray.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/test/java/net/openhft/lang/values/DoubleArray.java b/src/test/java/net/openhft/lang/values/DoubleArray.java index bbc4c6b60..2887ccde6 100755 --- a/src/test/java/net/openhft/lang/values/DoubleArray.java +++ b/src/test/java/net/openhft/lang/values/DoubleArray.java @@ -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 { 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)); + } }