Tagged articles
HashSet
25 articles · Page 1 of 1
A permission sync task processing 50,000 records ran in 40 seconds despite sub-second SQL queries; profiling revealed the bottleneck was an O(n²) List.contains() inside a stream filter, and replacing the List with a HashSet cut the diff calculation from 38 seconds to milliseconds, demonstrating how data structure choice dominates batch performance.
HashSetJavaList.contains
0 likes · 16 min read

This article dissects the classic LeetCode #3 longest‑substring‑without‑repeating‑characters problem, shows why a HashSet‑based solution incurs heavy boxing overhead, and walks through three progressive optimizations—using a boolean array, index‑jumping with an int array, and refined update timing—to shrink runtime from 8 ms to about 2 ms, while highlighting common pitfalls and best‑practice guidelines.
AlgorithmHashSetJava
0 likes · 12 min read

This article demonstrates three practical techniques—using a HashSet, leveraging Java 8 Stream API, and applying Map's merge functionality—to combine two List collections while eliminating duplicate elements, complete with full Java code examples and output illustration.
DuplicateRemovalHashSetJava
0 likes · 5 min read

This article demonstrates six different techniques for eliminating duplicate elements from a Java List, including HashSet, TreeSet, LinkedHashSet, iterator-based removal, Stream distinct, and manual contains checks, each with complete code examples and output illustrations.
HashSetJavaStream
0 likes · 7 min read

This article examines several Java deduplication techniques—including List.contains, HashSet, double-loop removal, and Stream.distinct—by providing sample code, measuring execution time on a 20,000‑element list, and analyzing their time complexities to guide developers toward efficient duplicate‑removal strategies.
AlgorithmHashSetJava
0 likes · 7 min read

This article compares several Java duplicate‑removal techniques—including list.contains, HashSet, double‑loop removal, and Stream.distinct—by generating a 20 000‑element test list, measuring execution time, and explaining the underlying algorithmic complexities that make some approaches dramatically faster than others.
HashSetListStream
0 likes · 7 min read

This article benchmarks several Java deduplication techniques—including List.contains, HashSet, double-loop removal, and Stream.distinct—using a 20,000‑element list, analyzes their execution times, explains underlying time complexities, and provides practical recommendations on which method to use.
HashSetJavaList.contains
0 likes · 8 min read


政采云技术May 31, 2022 · Fundamentals
This article presents an efficient deduplication algorithm for parent‑child relationship validation that caches intermediate results in a hashset to eliminate redundant computations, dramatically improving performance and scalability for large datasets by reducing verification steps through stored validated nodes.
HashSetParent-Childdeduplication
0 likes · 11 min read

This article explains why Java developers must override both hashCode() and equals() methods for proper object comparison in hash-based collections, outlines the scenarios requiring such overrides, and provides detailed example code demonstrating correct implementations.
HashSetJavaObject
0 likes · 7 min read


JavaEdgeAug 19, 2021 · Interview Experience
The article explains why Java's HashSet stores a non‑null placeholder in its underlying HashMap, detailing how HashSet#add and HashSet#remove delegate to HashMap methods and why using null would prevent these operations from correctly reporting success or failure.
HashMapHashSetdata structures
0 likes · 2 min read

This article explains the purpose of Java's hashCode() and equals() methods, outlines the rules for overriding them, demonstrates common pitfalls with HashSet through a concrete code example, and clarifies why both methods must be overridden when using custom objects as HashMap keys.
HashMapHashSetJava
0 likes · 6 min read

This article explains the fundamental differences between Java's HashMap and HashSet, describes how hash tables work with arrays and linked lists, outlines storage processes, collision resolution methods, resizing strategies, and provides a sample hash function implementation in Java.
HashMapHashSetJava
0 likes · 6 min read

This article presents five distinct techniques for eliminating duplicate elements from a Java ArrayList, including using LinkedHashSet, Java 8 Stream distinct, HashSet with order preservation, manual contains checks, and a double‑for‑loop approach, each accompanied by complete code examples and output results.
HashSetJavaStream
0 likes · 6 min read

This article presents five distinct methods for eliminating duplicate elements from a Java ArrayList, including using LinkedHashSet, Java 8 streams, HashSet with order preservation, manual iteration with contains checks, and nested loops, each accompanied by complete code examples and output results.
HashSetJavaarraylist
0 likes · 6 min read

This article demonstrates five different techniques for eliminating duplicate integers from a Java List—including nested loops, contains checks, HashSet, TreeSet, and Java 8 streams—provides complete source code for each method, and compares their execution times under different random data ranges.
HashSetJavaList
0 likes · 7 min read

This tutorial demonstrates step‑by‑step how to obtain the union of two arrays in Java—both primitive and object types—by leveraging a HashSet with addAll, includes full code examples, console output, and a concise Groovy alternative.
Array UnionGroovyHashSet
0 likes · 5 min read

This article explains the roles of equals() and hashCode() in Java, demonstrates how their interaction affects hash‑based collections like HashSet, provides multiple code examples showing correct and incorrect implementations, and outlines essential principles for overriding these methods to ensure proper object equality handling.
HashSetJavaObject Equality
0 likes · 9 min read

This article explains why core Java collection classes such as ArrayList, HashSet, and HashMap are not thread‑safe, demonstrates the underlying mechanisms of their initialization and resizing, and presents multiple approaches—including Vector, synchronized wrappers, and CopyOnWrite variants—to achieve safe concurrent access.
ConcurrencyHashMapHashSet
0 likes · 16 min read

This article explains the internal workings of Java's HashSet, covering its overview, various constructors, the add and remove operations implemented via HashMap, traversal techniques, and how LinkedHashSet and TreeSet extend HashSet functionality, providing code examples and conceptual diagrams.
HashSetJavabackend development
0 likes · 10 min read

This article explains how Java's HashSet implementation guarantees element uniqueness by internally using a HashMap, detailing its constructors, internal fields, the add method, and the underlying HashMap put and putVal logic that handles collisions and duplicate detection.
DuplicateHashMapHashSet
0 likes · 6 min read

This article explains two algorithmic solutions for locating any duplicate number in an array of length n where values range from 0 to n‑1: a straightforward HashSet method using O(n) extra space and an in‑place swapping technique that achieves O(1) space, complete with Java and JavaScript code examples and complexity analysis.
HashSetJavaJavaScript
0 likes · 5 min read

This article explains how Java's hashCode() and equals() methods interact, illustrates their behavior with and without hash‑based collections through multiple code examples, and outlines the essential principles developers must follow when overriding these methods to ensure correct functionality in hash tables.
HashSetequals
0 likes · 11 min read

This article explains the contract between hashCode() and equals() in Java, shows the problems caused by violating it—such as incorrect behavior in HashMap/HashSet and memory leaks—and provides practical guidelines and code examples for implementing robust hashCode methods, including the use of Apache's HashCodeBuilder.
HashMapHashSetImmutable Objects
0 likes · 15 min read

A production Java service suffered a thread‑pool alarm due to an unbounded LinkedBlockingQueue and a non‑thread‑safe HashSet, leading to massive memory usage, a circular linked‑list loop in HashMap, and severe CPU load, which was resolved by switching to ConcurrentHashMap and tuning the pool.
ConcurrencyHashSetJava
0 likes · 8 min read

This article explains the Java collection class diagram, distinguishes concrete classes, abstract classes, and interfaces, describes Iterator and ListIterator behavior, and provides detailed code demonstrations of HashSet, ArrayList, ListIterator, and WeakHashMap usage along with their outputs.
HashSetWeakHashMaparraylist
0 likes · 13 min read
