@Override public int hashCode() { if (isEmpty()) return 0; int h = hash; if (h == 0) { for (int i = begin; i < end; ++i) { h = 31 * h + buf[i]; } hash = h; } return h; }
@Override public int hashCode() { if (isEmpty()) return 0; int h = hash; if (h == 0) { for (int i = begin; i < end; ++i) { h = 31 * h + buf[i]; } hash = h; } return h; }
@Override public boolean isBlank() { if (isEmpty()) { return true; } for (int i = begin; i < end; ++i) { char c = buf[i]; if (c > ' ') { return false; } } return true; }
@Override public boolean isBlank() { if (isEmpty()) { return true; } for (int i = begin; i < end; ++i) { char c = buf[i]; if (c > ' ') { return false; } } return true; }
/** * Wrapper of {@link String#contentEquals(CharSequence)} * * @param x the char sequence to be compared * @return true if content equals content of the specified char sequence */ public boolean contentEquals(CharSequence x) { if (x == this) return true; if (isEmpty()) return x.length() == 0; int sz = size(), sz2 = x.length(); if (sz != sz2) return false; for (int i = 0; i < sz; ++i) { char c = buf[toInternalId(i)]; char c1 = x.charAt(i); if (c != c1) return false; } return true; }
/** * Wrapper of {@link String#contentEquals(CharSequence)} * * @param x the char sequence to be compared * @return true if content equals content of the specified char sequence */ public boolean contentEquals(CharSequence x) { if (x == this) return true; if (isEmpty()) return x.length() == 0; int sz = size(), sz2 = x.length(); if (sz != sz2) return false; for (int i = 0; i < sz; ++i) { char c = buf[toInternalId(i)]; char c1 = x.charAt(i); if (c != c1) return false; } return true; }
/** * Wrapper of {@link String#equalsIgnoreCase(String)} * * @param x the char sequence to be compared * @return {@code true} if the argument is not {@code null} and it * represents an equivalent {@code String} ignoring case; {@code * false} otherwise */ public boolean equalsIgnoreCase(CharSequence x) { if (x == this) return true; if (null == x || size() != x.length()) return false; if (isEmpty() && x.length() == 0) return true; return regionMatches(true, 0, x, 0, size()); }
private int count(char[] search, int searchOffset, int searchCount, boolean overlap) { if (isEmpty()) return 0; return S.count(buf, begin, size(), search, searchOffset, searchCount, overlap); }
/** * Wrapper of {@link String#equalsIgnoreCase(String)} * * @param x the char sequence to be compared * @return {@code true} if the argument is not {@code null} and it * represents an equivalent {@code String} ignoring case; {@code * false} otherwise */ public boolean equalsIgnoreCase(CharSequence x) { if (x == this) return true; if (null == x || size() != x.length()) return false; if (isEmpty() && x.length() == 0) return true; return regionMatches(true, 0, x, 0, size()); }
private int count(char[] search, int searchOffset, int searchCount, boolean overlap) { if (isEmpty()) return 0; return S.count(buf, begin, size(), search, searchOffset, searchCount, overlap); }
@Override public FastStr capFirst() { if (isEmpty()) return this; int sz = size(); char[] buf = this.buf; char[] newBuf = S.unsafeCapFirst(buf, begin, sz); if (buf == newBuf) return this; return unsafeOf(newBuf, 0, sz); }
@Override public FastStr capFirst() { if (isEmpty()) return this; int sz = size(); char[] buf = this.buf; char[] newBuf = S.unsafeCapFirst(buf, begin, sz); if (buf == newBuf) return this; return unsafeOf(newBuf, 0, sz); }
public boolean startsWith(FastStr prefix, int toffset) { if (prefix.isEmpty()) return true; int sz2 = prefix.size(), sz = size(); if (toffset < 0 || toffset > sz - sz2) { return false; } int po = 0, pc = sz2, to = toffset; char[] buf1 = buf, buf2 = prefix.buf; while (--pc >= 0) { if (buf1[toInternalId(to++)] != buf2[prefix.toInternalId(po++)]) { return false; } } return true; }
public boolean startsWith(FastStr prefix, int toffset) { if (prefix.isEmpty()) return true; int sz2 = prefix.size(), sz = size(); if (toffset < 0 || toffset > sz - sz2) { return false; } int po = 0, pc = sz2, to = toffset; char[] buf1 = buf, buf2 = prefix.buf; while (--pc >= 0) { if (buf1[toInternalId(to++)] != buf2[prefix.toInternalId(po++)]) { return false; } } return true; }
@Override public FastStr takeWhile($.Function<? super Character, Boolean> predicate) { if (isEmpty()) { return EMPTY_STR; } int sz = size(), b = toInternalId(0), e = -1; for (int i = 0; i < sz; ++i) { char c = charAt(i); e = toInternalId(i); if (!predicate.apply(c)) break; } return unsafeOf(buf, b, e); }
@Override public FastStr takeWhile($.Function<? super Character, Boolean> predicate) { if (isEmpty()) { return EMPTY_STR; } int sz = size(), b = toInternalId(0), e = -1; for (int i = 0; i < sz; ++i) { char c = charAt(i); e = toInternalId(i); if (!predicate.apply(c)) break; } return unsafeOf(buf, b, e); }
private void init(CharSequence chars) { final FastStr fs = FastStr.of(chars); final int sz = fs.length(); int last = nextNonSeparator(fs, 0); int pos; while (true) { pos = locateNextStop(fs, last); if (pos < 0 || pos == sz) { FastStr sub = fs.substr(last); if (!sub.isEmpty()) { list.add(sub.toLowerCase()); } break; } FastStr sub = fs.subSequence(last, pos); if (!sub.isEmpty()) { list.add(sub.toLowerCase()); } last = nextNonSeparator(fs, pos); } }
private void init(CharSequence chars) { final FastStr fs = FastStr.of(chars); final int sz = fs.length(); int last = nextNonSeparator(fs, 0); int pos; while (true) { pos = locateNextStop(fs, last); if (pos < 0 || pos == sz) { FastStr sub = fs.substr(last); if (!sub.isEmpty()) { list.add(sub.toLowerCase()); } break; } FastStr sub = fs.subSequence(last, pos); if (!sub.isEmpty()) { list.add(sub.toLowerCase()); } last = nextNonSeparator(fs, pos); } }
private $.T2<String, String> splitActionStr(String action) { FastStr fs = FastStr.of(action); FastStr fs1 = fs.beforeFirst(':'); FastStr fs2 = fs1.isEmpty() ? fs : fs.substr(fs1.length() + 1); return $.T2(fs1.trim().toString(), fs2.trim().toString()); }
private $.T2<String, String> splitActionStr(String action) { FastStr fs = FastStr.of(action); FastStr fs1 = fs.beforeFirst(':'); FastStr fs2 = fs1.isEmpty() ? fs : fs.substr(fs1.length() + 1); return $.T2(fs1.trim().toString(), fs2.trim().toString()); }