This article hashmap the realization of the source code for a simple analysis. The version information of the HashMap source used is as follows:/* * @ (#) Hashmap.java 1.73 07/03/13** Copyright 2006 Sun Microsystems, Inc. All rights reserved.* SUN
HashMap is one of the most common data structures we use to write code in our daily lives, and it provides us with key-value forms of data storage. At the same time, its query, insert efficiency is very high.In the previous sort algorithm summary, I
I. The difference between HASHMAP and HashtableLet's first look at the definition of 2 classes.1 Public class Hashtable 2 extends Dictionary 3 Implements Public class HashMap extends Abstractmap Implements Map, Cloneable,
Let's first look at the definition of 2 classes.[Java]View PlainCopy
Public class Hashtable
extends Dictionary
implements Map, Cloneable, "Http://lib.csdn.net/base/javaee" class=' Replace_word ' title= "Java ee Knowledge Base"
The analysis of a storage class is nothing more than two points: the data structure used for storage and the operating mechanism of storage.
Data structure:
Array
[Java]/*** The table, resized as necessary. Length MUST Always be a power of
I. Add default values to hash:H = {1, 2, 3, 4 }#=>{ 1 => 2, 3 => 4}
H. Default = 7
H [1] # => 2
H [3] # => 4
H [4] # => 7
H [5] # => 7
II. Add a key-value pair to the hash:H ={}#=> {}
H. Store ("A", 1) # => 1
H ["A"] # => 1
H. Fetch ("A") # => 1
H ["
HashMap methods and ideas for solving hash conflicts, hashmaphash
When asked about the hash function, I forgot about it for a while. After a review, I thought the difficulty was nothing more than hash () algorithm design and conflict resolution.
Defined Public class Hashmap extends abstractmap implements Map, cloneable, Serializable Public Abstract class ImplementsHASHMAP implements the map interface and inherits the Abstractmap. Where the map interface defines the rules for mapping
Let's first look at the definition of 2 classes.public class Hashtable extends Dictionary implements Map, Cloneable, java.io.Serializable public class HashMap extends Abstractmap implements Map, Cloneable,
HashMapa definition and creationHASHMAP implements the map interface and inherits the Abstractmap class. The basic functionality of map is included in the Abstractmap.(1) Initial sizeStatic int 1 4 // akaFrom the source can be seen size is 16 (1
Transfer from http://blog.csdn.net/java2000_net/archive/2008/06/05/2512510.aspxLet's first look at the definition of 2 classes.[Java]View Plaincopy
public class Hashtable
Extends Dictionary
Implements Map, Cloneable,
If we were to design hashmap ourselves, what should we do? Array. With array storage nodes, each node has key and value information. Well, first we have to have node storage key,value.Node DesignIn this node class, there are three properties, hash
First, look at the data structure of the HASHMAP, you can see that the array is implemented by the linked list.Transient entry[] table = (entry[]) empty_table;You can see that its implementation is an array of type entry named table. And entry is an
1, the two inherit the direct parent class is different: Hashtable inherit from the Dictiionary,hashmap inherit from Abstractmap, this difference can be clearly seen through the source code of both:public class hashmap extends abstractmap
Redis Implements Business Description of clicks and views & nbsp; CMS article views (titles are loaded), clicks statistics (number of clicks on an article) & nbsp; The following is a self-designed statistics service, key technologies: redis, nodejs,
A hash table is an important way of storing and a common retrieval method. The basic idea is to use the value of the relationship code as an independent variable, calculate the corresponding function value by a certain function relation, interpret
SymptomA requirement was launched recently, and the code was restructured during the requirement process. About half an hour after the application was released, an alarm was reported on a machine, and the load was too high. Log on to the machine to
It seems that there is no source read today, so come and seeJavathe two kinds of hashmap have a different place, before this, first popularize some basic knowledge of HashMap:(1) The element to be put into HashMap is key-value.(2) The bottom is the
The HashMap class in the Java set and the HashMap class in the Java set
Jdk1.8.0 _ 144
As one of the most common collections, HashMap inherits from AbstractMap. The HashMap Implementation of JDK 8 is different from that of JDK 7. The red/black tree
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.