java.lang.jtransc.JTranscStrings Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jtransc-rt Show documentation
Show all versions of jtransc-rt Show documentation
JVM AOT compiler currently generating JavaScript, C++, Haxe, with initial focus on Kotlin and games.
package java.lang.jtransc;
public class JTranscStrings {
static public char[] getData(String str) {
return str.getNativeCharArray();
}
static public boolean equals(char[] a, int aoffset, char[] b, int boffset, int len) {
for (int n = 0; n < len; n++) if (a[aoffset + n] != b[boffset + n]) return false;
return true;
}
static public int indexOf(char[] base, int offset, int haystack) {
int end = base.length;
for (int n = offset; n < end; n++) if (base[n] == haystack) return n;
return -1;
}
static public int lastIndexOf(char[] base, int offset, int haystack) {
int start = Math.min(offset, base.length - 1);
for (int n = start; n >= 0; n--) if (base[n] == haystack) return n;
return -1;
}
static public int indexOf(char[] base, int offset, char[] haystack) {
int end = base.length - haystack.length;
for (int n = offset; n < end; n++) if (JTranscStrings.equals(base, n, haystack, 0, haystack.length)) return n;
return -1;
}
static public int lastIndexOf(char[] base, int offset, char[] haystack) {
int start = Math.min(offset, base.length - haystack.length);
for (int n = start; n >= 0; n--) if (JTranscStrings.equals(base, n, haystack, 0, haystack.length)) return n;
return -1;
}
}