diff options
Diffstat (limited to 'src/algorithmus/Utils.java')
-rwxr-xr-x | src/algorithmus/Utils.java | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/algorithmus/Utils.java b/src/algorithmus/Utils.java new file mode 100755 index 0000000..6d1d7cf --- /dev/null +++ b/src/algorithmus/Utils.java @@ -0,0 +1,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;
+ }
+
+}
|