1 11 package org.eclipse.ui.internal.texteditor.quickdiff.compare.equivalence; 12 13 17 public final class DJBHashFunction implements IHashFunction { 18 19 public Hash computeHash(CharSequence string) { 20 return new IntHash(hash(string)); 21 } 22 23 private int hash(CharSequence seq){ 24 int hash = 5381; 25 int len= seq.length(); 26 for (int i= 0; i < len; i++) { 27 char ch= seq.charAt(i); 28 hash = ((hash << 5) + hash) + ch; 29 } 30 31 return hash; 32 } 33 34 } 35 | Popular Tags |