@Override public int hashCode() { int l = len; int h = 0; if (l > 0) { for (int i = 0; i < len; i++) { h = 31 * h + chars(i); } } return h; }
/** * modify content of this StructString. The length of the new String must not exceed * the length of internal char array * * @param s */ public void setString(String s) { if (s == null) { setLen(0); return; } if (s.length() > charsLen()) { throw new RuntimeException("String length exceeds buffer size. String len " + s.length() + " charsLen:" + charsLen()); } for (int i = 0; i < s.length(); i++) { chars(i, (byte) (s.charAt(i)&0xff)); } len = s.length(); }
public String toString() { // fixme: optimize this by direct copy byte ch[] = new byte[len]; for (int i = 0; i < len; i++) { ch[i] = chars(i); } return new String(ch,0); }
/** * modify content of this StructString. The length of the new String must not exceed * the length of internal char array * * @param s */ public void setString(String s) { if (s == null) { setLen(0); return; } if (s.length() > charsLen()) { throw new RuntimeException("String length exceeds buffer size. String len " + s.length() + " charsLen:" + charsLen()); } for (int i = 0; i < s.length(); i++) { chars(i, (byte) (s.charAt(i)&0xff)); } len = s.length(); }
@Override public int hashCode() { int l = len; int h = 0; if (l > 0) { for (int i = 0; i < len; i++) { h = 31 * h + chars(i); } } return h; }
public String toString() { // fixme: optimize this by direct copy byte ch[] = new byte[len]; for (int i = 0; i < len; i++) { ch[i] = chars(i); } return new String(ch,0); }
public int compareToString(String str) { int l1 = len; int l2 = str.length(); int max = Math.min(l1, l2); int i = 0; while (i < max) { char c1 = (char) ((chars(i)+256)&0xff); char c2 = str.charAt(i); if (c1 != c2) { return c1 - c2; } i++; } return l1 - l2; }
public int compareToString(String str) { int l1 = len; int l2 = str.length(); int max = Math.min(l1, l2); int i = 0; while (i < max) { char c1 = (char) ((chars(i)+256)&0xff); char c2 = str.charAt(i); if (c1 != c2) { return c1 - c2; } i++; } return l1 - l2; }