Detailed explanation of java HashMap source code

Article directory Detailed explanation of java HashMap source code HashMap source code 1 put method process 2 expansion 3 get method Detailed explanation of java HashMap source code Java HashMap is an implementation of the Map interface based on a hash table, which can store a data structure of key-value pairs. The characteristics of HashMap […]

A redis3 master-3-slave cluster built based on hash slots using docker containers

1. Construction background Cluster mode-docker version, hash slot partition for billion-level data storage 1. 100-200 million pieces of data need to be cached. How to design it? Answer: Using distributed storage, there are generally three solutions in the industry The first type: hash remainder partition (generally used by small factories) Disadvantages: The biggest disadvantage of […]

Java collection ConcurrentHashMap What is the difference between how to use each method and HashMap through source code analysis?

Table of Contents Hello friends, today I will analyze the thread-safe hashmap. The main features of ConcurrentHashMap include: ConcurrentHashMap example Let’s take a look at the source code of the size(), containsKey(), and replace() methods. Okay, let’s continue to look at the replace method. The first thing is to check whether a null pointer exception […]

hashCode in Java

1. hashCode method Java is an object-oriented programming language. All classes inherit from the Object class by default. The Object class contains the hashCode() method. // Java 1.8 public native int hashCode(); // Java 9 @HotSpotIntrinsicCandidate public native int hashCode(); This means that all classes will have a hashCode() method, which returns a value of […]

(STL hash) unordered_map

1. unordered series containers In C++98, STL provides a series of associative containers with red-black tree structures at the bottom, including set, multiset, map and multimap. The time complexity of query operations for these containers is O ( log N ) O(logN)O(logN), where N is the number of elements in the container. In order to […]

A brief discussion of HashMap and ConcurrentHashMap

As a back-end Java developer, the above-mentioned HashMap and ConcurrentHashMap are essential questions in interviews. Next, let me lead you to take a look. First of all, map is a key value structure, which is often used to store data in memory. hashMap: The data structure is based on **array + linked list**, but the […]

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

Data structure – hash (hash table)

tips: Jump table: haven’t studied the code yet 1. Dictionary order – ordered linked list #include<iostream> using namespace std; class SortedChainNode { int data; int* link; }; template<class E, class K> class SortedChain { public: SortedChain() { first = 0; } ~SortedChain(); bool IsEmpty() const { return first == 0; } int Length() const; bool […]