summaryrefslogtreecommitdiff
path: root/gi/posterior-regularisation/prjava/src/util/Array.java
diff options
context:
space:
mode:
Diffstat (limited to 'gi/posterior-regularisation/prjava/src/util/Array.java')
-rw-r--r--gi/posterior-regularisation/prjava/src/util/Array.java41
1 files changed, 41 insertions, 0 deletions
diff --git a/gi/posterior-regularisation/prjava/src/util/Array.java b/gi/posterior-regularisation/prjava/src/util/Array.java
new file mode 100644
index 00000000..cc4725af
--- /dev/null
+++ b/gi/posterior-regularisation/prjava/src/util/Array.java
@@ -0,0 +1,41 @@
+package util;
+
+import java.util.Arrays;
+
+public class Array {
+
+
+
+ public static void sortDescending(double[] ds){
+ for (int i = 0; i < ds.length; i++) ds[i] = -ds[i];
+ Arrays.sort(ds);
+ for (int i = 0; i < ds.length; i++) ds[i] = -ds[i];
+ }
+
+ /**
+ * Return a new reversed array
+ * @param array
+ * @return
+ */
+ public static int[] reverseIntArray(int[] array){
+ int[] reversed = new int[array.length];
+ for (int i = 0; i < reversed.length; i++) {
+ reversed[i] = array[reversed.length-1-i];
+ }
+ return reversed;
+ }
+
+ public static String[] sumArray(String[] in, int from){
+ String[] res = new String[in.length-from];
+ for (int i = from; i < in.length; i++) {
+ res[i-from] = in[i];
+ }
+ return res;
+ }
+
+ public static void main(String[] args) {
+ int[] i = {1,2,3,4};
+ util.Printing.printIntArray(i, null, "original");
+ util.Printing.printIntArray(reverseIntArray(i), null, "reversed");
+ }
+}