summaryrefslogtreecommitdiff
path: root/src/algorithmus/Utils.java
diff options
context:
space:
mode:
authorLeonard Kugis <leonard@kug.is>2022-04-25 18:43:46 +0200
committerLeonard Kugis <leonard@kug.is>2022-04-25 18:43:46 +0200
commitc9dd9469183d95c6c2f4d01e3d6365ec57386a65 (patch)
tree07ec933179eced02eec8a70f8b64c9281d453457 /src/algorithmus/Utils.java
Initial commitHEADmaster
Diffstat (limited to 'src/algorithmus/Utils.java')
-rwxr-xr-xsrc/algorithmus/Utils.java39
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;
+ }
+
+}