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 […]

The underlying principle of LinkedHashSet collection

1. Features of LinkedHashSet 2. LinkedHashSet principle (introduction of double linked list—–ordered) 3. TreeSet principle 1. Sort custom objects Method 1 (implement Compareable interface and rewrite comparison rules) import java.util.Objects; public class Student implements Comparable<Student>{ private String name; public int age; private double height; @Override//Rewriting of comparison rules public int compareTo(Student o) { return this.age-o.age; […]

[Set collection in java] HashSet, LinkedHashSet, TreeSet (the most understandable version!!)

Table of Contents 1. HashSet collection 1. Characteristics of HashSet collection 2. Common methods of HashSet 2. LinkedHashSet collection Characteristics of LinkedHashSet collection 3. TreeSet collection 1. Characteristics of TreeSet collection 2.Basic use of TreeSet 4. Usage scenarios of HashSet, LinkedHashSet, and TreeSet 5. The difference between list and set collections 1. HashSet collection 1.Characteristics […]

[Set] Set collection ordered and unordered test cases: HashSet, TreeSet, LinkedHashSet (122)

Common Set collections: HashSet, TreeSe, LinkedHashSet The connection between the three: (1) HashSet and TreeSet are two typical implementations of Set, and LinkedHashSet is the implementation class of HashSet. Simply put, the performance of HashSet is always better than that of TreeSet (especially the most commonly used operations such as adding and querying elements), because […]

HashSet and LinkedHashSet

HashSet Introduction 1. HashSetimplements the Set interface 2. HashSet The bottom layer is actually a HashMap 3. can store null values, but there can only be one null, but the element cannot be repeated 4. HashSet does not guarantee that the elements are ordered (that is, the order of extraction and storage is inconsistent), it […]

Java collections: Collection, Map, List, ArrayList, Vector, LinkedList, HashSet, LinkedHashSet, HashMap…

Understanding and benefits of collection Framework diagram of collection Collections are mainly divided into two groups: single-column collections (Collection) and double-column collections (Map). A single column means that the value of the element is stored, and a double column means that the stored element is in the form of key-value. Collection Collection System Diagram Map […]

Underlying analysis of HashSet and LinkedHashSet

A brief introduction to HashSet HashSet implements the Set interface HashSet is actually HashMap (the source code of the constructor) HashSet can store null, but there can only be one null, and elements cannot be repeated HashSet does not guarantee that the elements are in order, it depends on the hash, and then determines the […]

HashSet, LinkedHashSet

Article directory Set series collection The implementation class of the Set collection collection Exercise: Storing a string and iterating over it HashSet Hash table composition hash value Object hash value characteristics The underlying principle of HashSet Three problems with HashSet Exercise: Use the HashSet collection to remove duplicate elements LinkedHashSet The underlying principle of LinkedHashSet […]