@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,s.charAt(i)); } len = s.length(); }
public String toString() { // fixme: optimize this by direct copy char ch[] = new char[len]; for ( int i=0; i < len; i++ ) { ch[i] = chars(i); } return new String(ch); }
/** * 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,s.charAt(i)); } 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 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 = chars(i); char c2 = str.charAt(i); if (c1 != c2) { return c1 - c2; } i++; } return l1 - l2; }
public String toString() { // fixme: optimize this by direct copy char ch[] = new char[len]; for ( int i=0; i < len; i++ ) { ch[i] = chars(i); } return new String(ch); }
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 = chars(i); char c2 = str.charAt(i); if (c1 != c2) { return c1 - c2; } i++; } return l1 - l2; }