List of usage examples for java.lang Object hashCode
@HotSpotIntrinsicCandidate public native int hashCode();
From source file:Main.java
/** * <p>Return an object's hash code or 0 if the object is <code>null</code>.</p> *//*from w ww.j a v a2s . c o m*/ public static int hashIt(Object o) { if (o == null) return 0; else return o.hashCode(); }
From source file:org.linqs.psl.util.HashCode.java
public static int build(int start, int multiplier, Object obj) { return start * multiplier + obj.hashCode(); }
From source file:Main.java
public static <T1, T2> void removeHashMapElementByHash(ConcurrentHashMap<T1, T2> target, int hashcode) { Iterator<T1> iter = target.keySet().iterator(); Object key = null; while (iter.hasNext()) { key = iter.next();/*from ww w . j a va2 s . c o m*/ if (key.hashCode() == hashcode) { target.remove(key); } } }
From source file:Main.java
public static <T1, T2> T2 getHashMapElementByHash(ConcurrentHashMap<T1, T2> target, int hashcode) { Iterator<T1> iter = target.keySet().iterator(); Object key = null; while (iter.hasNext()) { key = iter.next();//from www.ja va 2s. c o m if (key.hashCode() == hashcode) { return target.get(key); } } return null; }
From source file:Main.java
/** * return unified reference.//from w ww. j a va2 s .c om * * @param hash * the hash * @param object * the object * @return the object */ public static Object unifyReferences(final Hashtable hash, Object object) { final Object itemAtHash = hash.get(object.hashCode()); if (itemAtHash == null) { hash.put(object.hashCode(), object); } else { object = itemAtHash; } return object; }
From source file:Main.java
public static int hashCode(List list) { if (list == null) { return 0; }/*from w w w. jav a 2s .c om*/ final int prime = 31; int result = 1; for (Iterator it = list.iterator(); it.hasNext();) { Object next = it.next(); result = prime * result + ((next == null) ? 0 : next.hashCode()); } return result; }
From source file:Main.java
public static int getHashCode(final Object... pObjects) { final int prime = 31; int result = 1; for (int i = 0; i < pObjects.length; i++) { final Object object = pObjects[i]; result = prime * result + ((object == null) ? 0 : object.hashCode()); }//from ww w .jav a 2 s. co m return result; }
From source file:Main.java
/** * Returns a hashcode that is computed irrespective of the order of the collection. This method should be used * to compute a hashcode of a collection field when <code>unorderedListEquals</code> or * <code>unorderedCollectionEquals</code> is used for that field in the object's equals method. * /*from ww w. ja v a 2s .c o m*/ * @param c the <code>Collection</code> * @return the hashcode */ public static int unorderedCollectionHashCode(Collection<?> c) { if (c == null) return 0; int h = 0; Iterator<?> i = c.iterator(); while (i.hasNext()) { Object o = i.next(); if (o != null) h += o.hashCode(); } return h; }
From source file:Main.java
public static String toHexString(Object object) { if (object == null) { return null; }/*from www .j a va 2 s . co m*/ return Integer.toHexString(object.hashCode()); }
From source file:com.googlecode.psiprobe.controllers.threads.ListThreadsController.java
private static String toUID(Object o) { return o.getClass().getName() + "@" + o.hashCode(); }