IdentifyHashMap类别

In Java, IdentityHashMap class implements the Map interface. It also implements the serializable and Cloneable interface. And it extends the AbstractMap class. It requires the objects for the comparison via reference.

在Java中,IdentityHashMap类实现Map接口。 它还实现了可序列化和可克隆的接口。 并且它扩展了AbstractMap类。 它需要通过引用进行比较的对象。

以下是IdentityHashMap类的构造方法 (Following are the Constructors of the IdentityHashMap class)

1. IdentityHashMap().

1. IdentityHashMap()。

2. IdentityHashMap(intexpectedMaxSize)

2. IdentityHashMap(intexpectedMaxSize)

3. IdentityHashMap(Map m)

3. IdentityHashMap(地图m)

下面是AbstractList类的方法 (Below are the methods of AbstractList Class)
S.no.MethodDescription
1clear()It is used to remove all the mappings from the map.
2clone()It is used to get a copy of the map.
3containsKey(Object key)It is used to get the mapping of a specified key.
4containsKey(Object value)It is used to get the mapping of a specified value.
5entrySet()It is used to set a view for mapping.
6equals(Object o)It is used to compare an object from another object in the map.
7get(Object key)It is used to get the value from the specified position in the map.
8hashCode()It used to get the hash code from the map.
9hashCode()It used to get the hash code from the map.
9isEmpty()It is used to check whether the map contains any key-value or not.
10keySet()It is used to set view in the map.
11put(K key, V value).It is used for adding key and value in the map.
12putAll(Map m)It used for copying the entire map.
13remove(Object key)It is used to remove the key from a weak hash map.
14size()It is used for getting the total number of key-value in the map.
15values()It is used to get the values from the map.
序号 方法 描述
1个 明确() 它用于从地图中删除所有映射。
2 克隆() 它用于获取地图的副本。
3 containsKey(对象键) 它用于获取指定键的映射。
4 containsKey(对象值) 它用于获取指定值的映射。
5 entrySet() 它用于设置映射视图。
6 等于(对象o) 它用于比较地图中另一个对象的对象。
7 get(对象键) 它用于从地图中的指定位置获取值。
8 hashCode() 它用于从地图中获取哈希码。
9 hashCode() 它用于从地图中获取哈希码。
9 是空的() 用于检查地图是否包含任何键值。
10 keySet() 它用于设置地图视图。
11 put(K键,V值)。 它用于在地图中添加键和值。
12 putAll(地图m) 它用于复制整个地图。
13 删除(对象键) 它用于从弱哈希图中删除密钥。
14 尺寸() 用于获取地图中键值的总数。
15 values() 它用于从地图获取值。

Example:

例:

import java.util.Map; 
import java.util.HashMap; 
import java.util.IdentityHashMap; 

public class IdentityHashMapDemo1 
{ 
    public static void main(String[] args)  
    {
        Map a = new HashMap(); 
        Map b = new IdentityHashMap(); 

a.put("H_key","H_value"); 
a.put(new String("H_key"),"H_value1");  
b.put("H_key","H_value");  
b.put(new String("H_key"),"H_value1");  

System.out.println("HashMapSize : "+a.size()); 

System.out.println("IdentityHashMapSize : "+b.size());           
    } 
}
identify-map-class

In Java, Immutable Map is a type of Map. It is immutable means it can not be modified, it is fixed after the declaration. If an attempt is made to add, delete or update an element then UnsupportedOperationException is thrown. It also does not allow any null elements.

在Java中,不可变地图是地图的一种。 它是不可变的,表示无法修改,声明后已修复。 如果尝试添加,删除或更新元素,则会引发UnsupportedOperationException。 它还不允许任何null元素。

以下是ImmutableList的优点。 ( Following are the Advantages of the ImmutableList. )

1. It is threaded safe.

1.它是线程安全的。

2. The memory is well organized.

2.内存组织良好。

下面是类层次结构 (Below is the class Hierarchy)
immutable-map

翻译自: https://www.studytonight.com/java/identity-hash-map.php

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值