summaryrefslogtreecommitdiff
path: root/src/algorithmus/Utils.java
blob: 6d1d7cf55ab86dcba20b054be79d03ed318db374 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
package algorithmus;

import java.util.Arrays;

public class Utils {
	
	public static byte[] crop(byte[] arr) {
		for(int i = 0; i<arr.length; i++)
			if(arr[i] == (byte)0x00)
				return Arrays.copyOfRange(arr, 0, i);
		return arr;
	}
	
	public static byte[] fill(byte[] arr, int length) {
		return Arrays.copyOf(arr, length);
	}
	
	public static int inArr(Object[] arr, Object tofind) {
		for(int i = 0; i<arr.length; i++)
			if(arr[i] == tofind)
				return i;
		return 0;
	}
	
	public static int inArr(char[] arr, char tofind) {
		for(int i = 0; i<arr.length; i++)
			if(arr[i] == tofind)
				return i;
		return 0;
	}
	
	public static int inArrEq(Object[] arr, Object tofind) {
		for(int i = 0; i<arr.length; i++)
			if(arr[i].equals(tofind))
				return i;
		return 0;
	}

}