Java Code Examples for java.util.HashSet#hashCode()
The following examples show how to use
java.util.HashSet#hashCode() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DistinctEntrySetElements.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { final EnumMap<TestEnum, String> enumMap = new EnumMap<>(TestEnum.class); for (TestEnum e : TestEnum.values()) { enumMap.put(e, e.name()); } Set<Map.Entry<TestEnum, String>> entrySet = enumMap.entrySet(); HashSet<Map.Entry<TestEnum, String>> hashSet = new HashSet<>(entrySet); if (false == hashSet.equals(entrySet)) { throw new RuntimeException("Test FAILED: Sets are not equal."); } if (hashSet.hashCode() != entrySet.hashCode()) { throw new RuntimeException("Test FAILED: Set's hashcodes are not equal."); } }
Example 2
Source File: DistinctEntrySetElements.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { final ConcurrentHashMap<String, String> concurrentHashMap = new ConcurrentHashMap<>(); concurrentHashMap.put("One", "Un"); concurrentHashMap.put("Two", "Deux"); concurrentHashMap.put("Three", "Trois"); Set<Map.Entry<String, String>> entrySet = concurrentHashMap.entrySet(); HashSet<Map.Entry<String, String>> hashSet = new HashSet<>(entrySet); if (false == hashSet.equals(entrySet)) { throw new RuntimeException("Test FAILED: Sets are not equal."); } if (hashSet.hashCode() != entrySet.hashCode()) { throw new RuntimeException("Test FAILED: Set's hashcodes are not equal."); } }
Example 3
Source File: DistinctEntrySetElements.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { final IdentityHashMap<String, String> identityHashMap = new IdentityHashMap<>(); identityHashMap.put("One", "Un"); identityHashMap.put("Two", "Deux"); identityHashMap.put("Three", "Trois"); Set<Map.Entry<String, String>> entrySet = identityHashMap.entrySet(); HashSet<Map.Entry<String, String>> hashSet = new HashSet<>(entrySet); // NB: These comparisons are valid in this case because none of the // keys put into 'identityHashMap' above are equal to any other. if (false == hashSet.equals(entrySet)) { throw new RuntimeException("Test FAILED: Sets are not equal."); } if (hashSet.hashCode() != entrySet.hashCode()) { throw new RuntimeException("Test FAILED: Set's hashcodes are not equal."); } }
Example 4
Source File: DistinctEntrySetElements.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { final EnumMap<TestEnum, String> enumMap = new EnumMap<>(TestEnum.class); for (TestEnum e : TestEnum.values()) { enumMap.put(e, e.name()); } Set<Map.Entry<TestEnum, String>> entrySet = enumMap.entrySet(); HashSet<Map.Entry<TestEnum, String>> hashSet = new HashSet<>(entrySet); if (false == hashSet.equals(entrySet)) { throw new RuntimeException("Test FAILED: Sets are not equal."); } if (hashSet.hashCode() != entrySet.hashCode()) { throw new RuntimeException("Test FAILED: Set's hashcodes are not equal."); } }
Example 5
Source File: DistinctEntrySetElements.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { final EnumMap<TestEnum, String> enumMap = new EnumMap<>(TestEnum.class); for (TestEnum e : TestEnum.values()) { enumMap.put(e, e.name()); } Set<Map.Entry<TestEnum, String>> entrySet = enumMap.entrySet(); HashSet<Map.Entry<TestEnum, String>> hashSet = new HashSet<>(entrySet); if (false == hashSet.equals(entrySet)) { throw new RuntimeException("Test FAILED: Sets are not equal."); } if (hashSet.hashCode() != entrySet.hashCode()) { throw new RuntimeException("Test FAILED: Set's hashcodes are not equal."); } }
Example 6
Source File: DistinctEntrySetElements.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { final EnumMap<TestEnum, String> enumMap = new EnumMap<>(TestEnum.class); for (TestEnum e : TestEnum.values()) { enumMap.put(e, e.name()); } Set<Map.Entry<TestEnum, String>> entrySet = enumMap.entrySet(); HashSet<Map.Entry<TestEnum, String>> hashSet = new HashSet<>(entrySet); if (false == hashSet.equals(entrySet)) { throw new RuntimeException("Test FAILED: Sets are not equal."); } if (hashSet.hashCode() != entrySet.hashCode()) { throw new RuntimeException("Test FAILED: Set's hashcodes are not equal."); } }
Example 7
Source File: DistinctEntrySetElements.java From jdk8u-dev-jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { final EnumMap<TestEnum, String> enumMap = new EnumMap<>(TestEnum.class); for (TestEnum e : TestEnum.values()) { enumMap.put(e, e.name()); } Set<Map.Entry<TestEnum, String>> entrySet = enumMap.entrySet(); HashSet<Map.Entry<TestEnum, String>> hashSet = new HashSet<>(entrySet); if (false == hashSet.equals(entrySet)) { throw new RuntimeException("Test FAILED: Sets are not equal."); } if (hashSet.hashCode() != entrySet.hashCode()) { throw new RuntimeException("Test FAILED: Set's hashcodes are not equal."); } }
Example 8
Source File: DistinctEntrySetElements.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { final EnumMap<TestEnum, String> enumMap = new EnumMap<>(TestEnum.class); for (TestEnum e : TestEnum.values()) { enumMap.put(e, e.name()); } Set<Map.Entry<TestEnum, String>> entrySet = enumMap.entrySet(); HashSet<Map.Entry<TestEnum, String>> hashSet = new HashSet<>(entrySet); if (false == hashSet.equals(entrySet)) { throw new RuntimeException("Test FAILED: Sets are not equal."); } if (hashSet.hashCode() != entrySet.hashCode()) { throw new RuntimeException("Test FAILED: Set's hashcodes are not equal."); } }
Example 9
Source File: DistinctEntrySetElements.java From hottub with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { final IdentityHashMap<String, String> identityHashMap = new IdentityHashMap<>(); identityHashMap.put("One", "Un"); identityHashMap.put("Two", "Deux"); identityHashMap.put("Three", "Trois"); Set<Map.Entry<String, String>> entrySet = identityHashMap.entrySet(); HashSet<Map.Entry<String, String>> hashSet = new HashSet<>(entrySet); // NB: These comparisons are valid in this case because none of the // keys put into 'identityHashMap' above are equal to any other. if (false == hashSet.equals(entrySet)) { throw new RuntimeException("Test FAILED: Sets are not equal."); } if (hashSet.hashCode() != entrySet.hashCode()) { throw new RuntimeException("Test FAILED: Set's hashcodes are not equal."); } }
Example 10
Source File: DistinctEntrySetElements.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { final ConcurrentHashMap<String, String> concurrentHashMap = new ConcurrentHashMap<>(); concurrentHashMap.put("One", "Un"); concurrentHashMap.put("Two", "Deux"); concurrentHashMap.put("Three", "Trois"); Set<Map.Entry<String, String>> entrySet = concurrentHashMap.entrySet(); HashSet<Map.Entry<String, String>> hashSet = new HashSet<>(entrySet); if (false == hashSet.equals(entrySet)) { throw new RuntimeException("Test FAILED: Sets are not equal."); } if (hashSet.hashCode() != entrySet.hashCode()) { throw new RuntimeException("Test FAILED: Set's hashcodes are not equal."); } }
Example 11
Source File: DistinctEntrySetElements.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { final IdentityHashMap<String, String> identityHashMap = new IdentityHashMap<>(); identityHashMap.put("One", "Un"); identityHashMap.put("Two", "Deux"); identityHashMap.put("Three", "Trois"); Set<Map.Entry<String, String>> entrySet = identityHashMap.entrySet(); HashSet<Map.Entry<String, String>> hashSet = new HashSet<>(entrySet); // NB: These comparisons are valid in this case because none of the // keys put into 'identityHashMap' above are equal to any other. if (false == hashSet.equals(entrySet)) { throw new RuntimeException("Test FAILED: Sets are not equal."); } if (hashSet.hashCode() != entrySet.hashCode()) { throw new RuntimeException("Test FAILED: Set's hashcodes are not equal."); } }
Example 12
Source File: DistinctEntrySetElements.java From jdk8u60 with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { final IdentityHashMap<String, String> identityHashMap = new IdentityHashMap<>(); identityHashMap.put("One", "Un"); identityHashMap.put("Two", "Deux"); identityHashMap.put("Three", "Trois"); Set<Map.Entry<String, String>> entrySet = identityHashMap.entrySet(); HashSet<Map.Entry<String, String>> hashSet = new HashSet<>(entrySet); // NB: These comparisons are valid in this case because none of the // keys put into 'identityHashMap' above are equal to any other. if (false == hashSet.equals(entrySet)) { throw new RuntimeException("Test FAILED: Sets are not equal."); } if (hashSet.hashCode() != entrySet.hashCode()) { throw new RuntimeException("Test FAILED: Set's hashcodes are not equal."); } }
Example 13
Source File: DistinctEntrySetElements.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { final ConcurrentHashMap<String, String> concurrentHashMap = new ConcurrentHashMap<>(); concurrentHashMap.put("One", "Un"); concurrentHashMap.put("Two", "Deux"); concurrentHashMap.put("Three", "Trois"); Set<Map.Entry<String, String>> entrySet = concurrentHashMap.entrySet(); HashSet<Map.Entry<String, String>> hashSet = new HashSet<>(entrySet); if (false == hashSet.equals(entrySet)) { throw new RuntimeException("Test FAILED: Sets are not equal."); } if (hashSet.hashCode() != entrySet.hashCode()) { throw new RuntimeException("Test FAILED: Set's hashcodes are not equal."); } }
Example 14
Source File: DistinctEntrySetElements.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { final ConcurrentHashMap<String, String> concurrentHashMap = new ConcurrentHashMap<>(); concurrentHashMap.put("One", "Un"); concurrentHashMap.put("Two", "Deux"); concurrentHashMap.put("Three", "Trois"); Set<Map.Entry<String, String>> entrySet = concurrentHashMap.entrySet(); HashSet<Map.Entry<String, String>> hashSet = new HashSet<>(entrySet); if (false == hashSet.equals(entrySet)) { throw new RuntimeException("Test FAILED: Sets are not equal."); } if (hashSet.hashCode() != entrySet.hashCode()) { throw new RuntimeException("Test FAILED: Set's hashcodes are not equal."); } }
Example 15
Source File: DistinctEntrySetElements.java From jdk8u-jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { final ConcurrentHashMap<String, String> concurrentHashMap = new ConcurrentHashMap<>(); concurrentHashMap.put("One", "Un"); concurrentHashMap.put("Two", "Deux"); concurrentHashMap.put("Three", "Trois"); Set<Map.Entry<String, String>> entrySet = concurrentHashMap.entrySet(); HashSet<Map.Entry<String, String>> hashSet = new HashSet<>(entrySet); if (false == hashSet.equals(entrySet)) { throw new RuntimeException("Test FAILED: Sets are not equal."); } if (hashSet.hashCode() != entrySet.hashCode()) { throw new RuntimeException("Test FAILED: Set's hashcodes are not equal."); } }
Example 16
Source File: DistinctEntrySetElements.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { final EnumMap<TestEnum, String> enumMap = new EnumMap<>(TestEnum.class); for (TestEnum e : TestEnum.values()) { enumMap.put(e, e.name()); } Set<Map.Entry<TestEnum, String>> entrySet = enumMap.entrySet(); HashSet<Map.Entry<TestEnum, String>> hashSet = new HashSet<>(entrySet); if (false == hashSet.equals(entrySet)) { throw new RuntimeException("Test FAILED: Sets are not equal."); } if (hashSet.hashCode() != entrySet.hashCode()) { throw new RuntimeException("Test FAILED: Set's hashcodes are not equal."); } }
Example 17
Source File: DistinctEntrySetElements.java From jdk8u_jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { final IdentityHashMap<String, String> identityHashMap = new IdentityHashMap<>(); identityHashMap.put("One", "Un"); identityHashMap.put("Two", "Deux"); identityHashMap.put("Three", "Trois"); Set<Map.Entry<String, String>> entrySet = identityHashMap.entrySet(); HashSet<Map.Entry<String, String>> hashSet = new HashSet<>(entrySet); // NB: These comparisons are valid in this case because none of the // keys put into 'identityHashMap' above are equal to any other. if (false == hashSet.equals(entrySet)) { throw new RuntimeException("Test FAILED: Sets are not equal."); } if (hashSet.hashCode() != entrySet.hashCode()) { throw new RuntimeException("Test FAILED: Set's hashcodes are not equal."); } }
Example 18
Source File: DistinctEntrySetElements.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { final IdentityHashMap<String, String> identityHashMap = new IdentityHashMap<>(); identityHashMap.put("One", "Un"); identityHashMap.put("Two", "Deux"); identityHashMap.put("Three", "Trois"); Set<Map.Entry<String, String>> entrySet = identityHashMap.entrySet(); HashSet<Map.Entry<String, String>> hashSet = new HashSet<>(entrySet); // NB: These comparisons are valid in this case because none of the // keys put into 'identityHashMap' above are equal to any other. if (false == hashSet.equals(entrySet)) { throw new RuntimeException("Test FAILED: Sets are not equal."); } if (hashSet.hashCode() != entrySet.hashCode()) { throw new RuntimeException("Test FAILED: Set's hashcodes are not equal."); } }
Example 19
Source File: DistinctEntrySetElements.java From dragonwell8_jdk with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { final ConcurrentHashMap<String, String> concurrentHashMap = new ConcurrentHashMap<>(); concurrentHashMap.put("One", "Un"); concurrentHashMap.put("Two", "Deux"); concurrentHashMap.put("Three", "Trois"); Set<Map.Entry<String, String>> entrySet = concurrentHashMap.entrySet(); HashSet<Map.Entry<String, String>> hashSet = new HashSet<>(entrySet); if (false == hashSet.equals(entrySet)) { throw new RuntimeException("Test FAILED: Sets are not equal."); } if (hashSet.hashCode() != entrySet.hashCode()) { throw new RuntimeException("Test FAILED: Set's hashcodes are not equal."); } }
Example 20
Source File: DistinctEntrySetElements.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
public static void main(String[] args) throws Exception { final IdentityHashMap<String, String> identityHashMap = new IdentityHashMap<>(); identityHashMap.put("One", "Un"); identityHashMap.put("Two", "Deux"); identityHashMap.put("Three", "Trois"); Set<Map.Entry<String, String>> entrySet = identityHashMap.entrySet(); HashSet<Map.Entry<String, String>> hashSet = new HashSet<>(entrySet); // NB: These comparisons are valid in this case because none of the // keys put into 'identityHashMap' above are equal to any other. if (false == hashSet.equals(entrySet)) { throw new RuntimeException("Test FAILED: Sets are not equal."); } if (hashSet.hashCode() != entrySet.hashCode()) { throw new RuntimeException("Test FAILED: Set's hashcodes are not equal."); } }