List of usage examples for java.lang Object hashCode
@HotSpotIntrinsicCandidate public native int hashCode();
From source file:scouter.util.CacheTable.java
private int hash(Object key) { return (int) (key.hashCode()) & Integer.MAX_VALUE; }
From source file:CompactHashSet.java
/** * INTERNAL: Rehashes the hashset to a bigger size. *///from w w w. jav a 2 s . co m @SuppressWarnings("unchecked") protected void rehash(int newCapacity) { int oldCapacity = objects.length; @SuppressWarnings("unchecked") E[] newObjects = (E[]) new Object[newCapacity]; for (int ix = 0; ix < oldCapacity; ix++) { Object o = objects[ix]; if (o == null || o == deletedObject) continue; int hash = o.hashCode(); int index = (hash & 0x7FFFFFFF) % newCapacity; int offset = 1; // search for the object while (newObjects[index] != null) { // no need to test for // duplicates index = ((index + offset) & 0x7FFFFFFF) % newCapacity; offset = offset * 2 + 1; if (offset == -1) offset = 2; } newObjects[index] = (E) o; } objects = newObjects; freecells = objects.length - elements; }
From source file:org.carrot2.util.simplexml.SimpleXmlWrappersTest.java
public void check(Object value) throws Exception { checkMap(Long.toString(value != null ? value.hashCode() : 0), value); checkList(value);/*w w w . ja v a2s . c o m*/ checkSet(value); }
From source file:org.structr.core.entity.SchemaProperty.java
private int addContentHash(final PropertyKey key, final int contentHash) { final Object value = getProperty(key); if (value != null) { return contentHash ^ value.hashCode(); }// w ww. j ava 2 s. c o m return contentHash; }
From source file:org.dataconservancy.packaging.tool.model.dprofile.Property.java
@Override public int hashCode() { // Special handling to ignore order of complex values. Object value_hash = value; if (isComplexValue() && hasValue()) { value_hash = new HashSet<>(getComplexValue()); }/*from ww w . j av a 2 s . c o m*/ final int prime = 31; int result = 1; result = prime * result + ((type == null) ? 0 : type.hashCode()); result = prime * result + ((value_hash == null) ? 0 : value_hash.hashCode()); return result; }
From source file:org.apache.bookkeeper.util.OrderedSafeExecutor.java
ExecutorService chooseThread(Object orderingKey) { // skip hashcode generation in this special case if (threads.length == 1) { return threads[0]; }//from w w w . ja v a2 s . c o m return threads[MathUtils.signSafeMod(orderingKey.hashCode(), threads.length)]; }
From source file:org.structr.schema.export.StructrMethodDefinition.java
@Override public boolean equals(final Object other) { if (other instanceof StructrMethodDefinition) { return other.hashCode() == hashCode(); }//from www . ja v a 2s . co m return false; }
From source file:com.github.adejanovski.cassandra.jdbc.CassandraStatement.java
public int compareTo(Object target) { if (this.equals(target)) return 0; if (this.hashCode() < target.hashCode()) return -1; return 1;/*from w w w. ja v a 2s .com*/ }
From source file:org.plasma.sdo.jdbc.service.GraphAssembler.java
/** * Creates a unique mappable key using the qualified type name * and all key property values from the given row. * @param type the type/* w w w. ja v a 2 s .c o m*/ * @param row the data values * @return the key */ private int createHashKey(PlasmaType type, List<PropertyPair> row) { PropertyPair[] pairs = new PropertyPair[row.size()]; row.toArray(pairs); Arrays.sort(pairs, this.nameComparator); int result = type.getQualifiedName().hashCode(); int pks = 0; for (int i = 0; i < pairs.length; i++) { if (pairs[i].getProp().isKey(KeyType.primary)) { Object value = pairs[i].getValue(); result = result ^ value.hashCode(); pks++; } } if (pks == 0) throw new IllegalStateException( "cannot create hash key - no primary keys found for type, " + type.toString()); return result; }
From source file:org.apache.bookkeeper.util.OrderedSafeExecutor.java
private long getThreadID(Object orderingKey) { // skip hashcode generation in this special case if (threadIds.length == 1) { return threadIds[0]; }/* w w w. j a v a 2 s.com*/ return threadIds[MathUtils.signSafeMod(orderingKey.hashCode(), threadIds.length)]; }