@Override public int computeHashCode(PsiElement e) { if (e instanceof BnfReferenceOrToken || e instanceof BnfLiteralExpression) { return e.getText().hashCode(); } return CANONICAL.computeHashCode(e); }
/** * Locates the index of <tt>obj</tt>. * * @param obj an <code>Object</code> value * @return the index of <tt>obj</tt> or -1 if it isn't in the set. */ protected int index(Object obj) { int hash, probe, index, length; Object[] set; Object cur; set = _set; length = set.length; hash = hashingStrategy.computeHashCode(obj) & 0x7fffffff; index = hash % length; cur = set[index]; if (cur != null && (cur == REMOVED || ! hashingStrategy.equals(cur, obj))) { // see Knuth, p. 529 probe = 1 + (hash % (length - 2)); do { index -= probe; if (index < 0) { index += length; } cur = set[index]; } while (cur != null && (cur == REMOVED || ! hashingStrategy.equals(cur, obj))); } return cur == null ? -1 : index; }
hash = hashingStrategy.computeHashCode(obj) & 0x7fffffff; index = hash % length; cur = set[index];