From 94c72d274685c0d2a83446ff8b9bc52885fddaab Mon Sep 17 00:00:00 2001 From: Nees Jan van Eck <36573334+neesjanvaneck@users.noreply.github.com> Date: Fri, 18 Aug 2023 16:22:47 +0200 Subject: [PATCH] Fix large array clone methods --- src/main/java/nl/cwts/util/LargeBooleanArray.java | 4 +++- src/main/java/nl/cwts/util/LargeDoubleArray.java | 4 +++- src/main/java/nl/cwts/util/LargeIntArray.java | 4 +++- src/main/java/nl/cwts/util/LargeLongArray.java | 4 +++- 4 files changed, 12 insertions(+), 4 deletions(-) diff --git a/src/main/java/nl/cwts/util/LargeBooleanArray.java b/src/main/java/nl/cwts/util/LargeBooleanArray.java index 48241a1..b1caf16 100644 --- a/src/main/java/nl/cwts/util/LargeBooleanArray.java +++ b/src/main/java/nl/cwts/util/LargeBooleanArray.java @@ -761,7 +761,9 @@ public LargeBooleanArray clone() try { clonedArray = (LargeBooleanArray)super.clone(); - clonedArray.values = values.clone(); + clonedArray.values = new boolean[values.length][]; + for (int i = 0; i < values.length; i++) + clonedArray.values[i] = values[i].clone(); return clonedArray; } catch (CloneNotSupportedException e) diff --git a/src/main/java/nl/cwts/util/LargeDoubleArray.java b/src/main/java/nl/cwts/util/LargeDoubleArray.java index b562d4e..062ad30 100644 --- a/src/main/java/nl/cwts/util/LargeDoubleArray.java +++ b/src/main/java/nl/cwts/util/LargeDoubleArray.java @@ -1057,7 +1057,9 @@ public LargeDoubleArray clone() try { clonedArray = (LargeDoubleArray)super.clone(); - clonedArray.values = values.clone(); + clonedArray.values = new double[values.length][]; + for (int i = 0; i < values.length; i++) + clonedArray.values[i] = values[i].clone(); return clonedArray; } catch (CloneNotSupportedException e) diff --git a/src/main/java/nl/cwts/util/LargeIntArray.java b/src/main/java/nl/cwts/util/LargeIntArray.java index 3df8f8a..22ab3dc 100644 --- a/src/main/java/nl/cwts/util/LargeIntArray.java +++ b/src/main/java/nl/cwts/util/LargeIntArray.java @@ -1055,7 +1055,9 @@ public LargeIntArray clone() try { clonedArray = (LargeIntArray)super.clone(); - clonedArray.values = values.clone(); + clonedArray.values = new int[values.length][]; + for (int i = 0; i < values.length; i++) + clonedArray.values[i] = values[i].clone(); return clonedArray; } catch (CloneNotSupportedException e) diff --git a/src/main/java/nl/cwts/util/LargeLongArray.java b/src/main/java/nl/cwts/util/LargeLongArray.java index 6fbd9d6..92c807f 100644 --- a/src/main/java/nl/cwts/util/LargeLongArray.java +++ b/src/main/java/nl/cwts/util/LargeLongArray.java @@ -1056,7 +1056,9 @@ public LargeLongArray clone() try { clonedArray = (LargeLongArray)super.clone(); - clonedArray.values = values.clone(); + clonedArray.values = new long[values.length][]; + for (int i = 0; i < values.length; i++) + clonedArray.values[i] = values[i].clone(); return clonedArray; } catch (CloneNotSupportedException e)