123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168 |
- package de.nplusc.izc.tools.baseTools;
- import java.util.Arrays;
- /*
- * To change this template, choose Tools | Templates
- * and open the template in the editor.
- */
- /**
- *
- * @author LH
- */
- public class arraytools {
- protected arraytools()
- {
-
- }
- public static int arrayMaxValue(int[] input)
- {
- int iMax = 0;
- for(int i=0;i<input.length;i++)
- {
- if(input[i]>iMax)
- {
- iMax = input[i];
- }
- }
- return iMax;
- }
- public static int tsvSumUpInCol(String[][] input,int col)
- {
- int sum = 0;
- int value = 0;
- for(int i=0;i<input.length;i++)
- {
- String entry = input[i][col];
- Tools.DebugHelperPrint(entry, true, "Toolkit.enableCoreDebug");
- value = Integer.valueOf(entry);
- sum = sum + value;
- }
- return sum;
- }
- public static int tsvCountDiffInCol(String[] input,int col)
- {
- col = col-1;
- String[] line;
- int cycles = input.length;
- int j=0;
- String[] coldat = new String[cycles];
- for(int i=0;i<cycles;i++)
- {
- coldat[i] = "";
- }
- for (int i=0;i<cycles;i++)
- {
- line = input[i].split("\t");
- String data = line[col];
- if(arraySearch(coldat,data,j+1)==false)
- {
- coldat[j] = data;
- j++;
- }
-
- }
- return j;
- //return 0;
- }
- public static boolean arraySearch(String[] Searchable,String searched,int length)
- {
- for(int i=0;i<length;i++)
- {
- if(Searchable[i].equals(searched))
- {
- i=length;
- return true;
- }
- }
- return false;
- }
-
- public static int getElemPosInArray(String[] Searchable,String searched)
- {
- for(int i=0;i<Searchable.length;i++)
- {
- if(Searchable[i].equals(searched))
- {
- //i=length;
- return i;
- }
- }
- return -1;
- }
-
- /*
- Disabled Code
- public static String[] tsvInCol(String[][]tsv,int Column,int Rows)
- {
- boolean found = false;
- String[] array;
- if (found==afalse)
- {
- array = new String[1];
- array[0] = "NotInArray";
- }
- else
- {
- array = new String[0];
- }
- return array;
- }
- public static String[] tsvInCol(String[][]tsv,int Column)
- {
- return tsvInCol(tsv,Column,-1);
- }
- */
- public static String ArrayKleben(Object[]o,String k)
- {
- String ret = "";
- for (Object object : o) {
- ret +=o+k;
- }
-
- return ret.substring(0,ret.length()-k.length());
- }
- public static Object[] arrayReverse(Object[] array)
- {
- Object j;
- int k, l;
- Object[] zahlen2 = new Object[array.length];
- for (int i = 0; i < array.length; i++)
- {
- j = array[i];
- k = array.length;
- l = k - i - 1;
- Tools.DebugHelperPrint(k+"", true, "Toolkit.enableFinerDebug");
- zahlen2[l] = array[i];
- }
- array = zahlen2;
- for (Object object : zahlen2)
- {
- Tools.DebugHelperPrint(object+"", true, "Toolkit.enableFinerDebug");
- }
- return array;
- }
- public static <T> T[] concatAll(T[] first, T[]... rest)
- {
- int totalLength = first.length;
- for (T[] array : rest)
- {
- totalLength += array.length;
- }
- T[] result = Arrays.copyOf(first, totalLength);
- int offset = first.length;
- for (T[] array : rest)
- {
- System.arraycopy(array, 0, result, offset, array.length);
- offset += array.length;
- }
- return result;
- }
- }
|