String hash function #2: Java code

class String implements java.io.Serializable, Comparable {
  /** The value is used for character storage. */
  private char value[];
  /** The offset is the first index of the storage that is used. */
  private int offset;
  /** The count is the number of characters in the String. */
  private int count;
  public int hashCode() {
		int h = 0;
		int off = offset;
		char val[] = value;
		int len = count;
 
		for (int i = 0; i < len; i++)
	    h = 31*h + val[off++];
 
		return h;
  }

CONTENTS    PREVIOUS    NEXT