Java data structure (red-black tree) set collection HashSet HashSet three problems LinkedHashSetTreeSet TreeSet collection default rules sorting rules

Directory Data structure (red-black tree) red and black rules Red-black tree adding node rules set set summary HashSet Three problems with HashSet LinkedHashSet summary TreeSet TreeSet collection default rules Sorting rules (first sorting method) Method 2 practise Xiaolian Summarize Summary: How to choose when using collections Data structure (red-black tree) Red and black rules The […]

Collection framework: characteristics of Set collection, underlying principles of HashSet collection, hash table, implementation of deduplication

Characteristics of Set collection Set is an unordered, non-repeating data structure. Its characteristics are as follows: 1. The elements in the set are unordered: The elements in the Set have no order and cannot be accessed through indexes. 2. The elements in the set are unique: Duplicate elements are not allowed in the Set, and […]

Java SeriesHashSet

HashSet introduce Add element Determine whether the element exists Delete element To delete all elements in the collection, use the clear method: Calculate size Iterate over a HashSet Series of articles version record Introduction HashSet is implemented based on HashMap and is a set that does not allow duplicate elements. HashSet allows null values. HashSet […]

The deduplication principle of HashSet

The set collection has no index value and cannot be repeated. The bottom layer is map. When adding an element, the hashCode() method will be called first to calculate the hash value of the object, and then use the hash value % of the array length to calculate the index value position of the new […]

HashSet deduplication principle

1. What is Hashset Collections in Java are divided into Collection collections (single-column collections) and Map collections (double-column collections) The Hashset collection is an implementation class of the set interface. The set interface also inherits from the top-level parent class Collection interface, so HashSet can have methods common to Collection. The characteristics of the set […]

JAVA-Day51Exploring the Java HashSet Collection

Exploring the Java HashSet collection **Exploring the Java HashSet Collection ** **1. First introduction to HashSet** 1.1 What is the Java collection class HashSet? 1.2 The working principle behind the hash table **2. Use HashSet collection** 2.1 Create and initialize the HashSet collection Create an empty HashSet: Initialize HashSet via Collection: Initialize a HashSet by […]

Why use hashing algorithm? Hand-shred HashSet: add, delete, exist, expand

#I have been practicing algorithms and structures recently, and their importance is self-evident. What I’m sharing today is a hand-shredded HashSet. Let’s start from the interviewer’s perspective# 1. Interviewer: Please tell me about your understanding of HashSet and why you should use the hash algorithm Little Z: Let’s talk about its official definition first (list […]