Key Code: Store these objects with HashMap . If you want, you can also convert it in Hindi . 在Java8中,对HashMap 有一个性能上的改进。 Java 8 came with performance improvements for HashMap . A HashMap is an implementation of the Map interface.Hashtable是线程安全的,HashMap 不是线程安全的。 Hence Hashtable is thread-safe whereas HashMap is not thread-safe.
The following code is in the HashMap constructor:.这个方法被用于hashtables,例如HashMap 。 This method is supported for the benefit of hash tables such as those provided by HashMap . 使用ConcurrentHashMap取代HashMap 可以简单地解决这点。 Using ConcurrentHashMap in place of HashMap easily solves this. HashMap详解:HashMap 有两个参数影响其性能:初始容量和加载因子。 An instance of HashMap has two parameters that affect its performance: initial capacity and load factor. 为了避免这种情况,HashMap 有能力增加其内部数组数量,用来保持存储的链表不至过长。 To avoid this case, the HashMap has the ability to increase its inner array in order to keep very short linked lists. Hashmap 是一种典型的数据结构,平均提供O(1)查找,在最坏的情况下提供O(n)查找。A hashmap is a classic data structure offering O(1) lookups on average and O(n) in the worst case. 所以这两个方法的实现对HashMap 的精确性和正确性是至关重要的。 Therefore, the implementation of both methods is crucial to the accuracy and efficiency of the HashMap . HashMap 实际上是一个“链表散列”的数据结构,即数组和链表的结合体。HashMap is actually a"chain-table hash" of the data structure, that is, the combination of arrays and linked lists. 所以,这两个方法的实现都对HashMap 的准确性和高效性有至关重要的作用。 Therefore, the implementation of both methods is crucial to the accuracy and efficiency of the HashMap . 插入HashMap 的任何键/值对都将包含于一个HashMap$Entry对象之中,该对象本身也有一定的开销。 Any key/value pairs inserted into the HashMap are wrapped by a HashMap$Entry object, which itself has some overhead. Hashtable的实现同样类似于HashMap ,也是条目对象的数组,在本例中即Hashtable$Entry对象。 The implementation of Hashtable- also similar to HashMap 's- is as an array of entry objects, in this case Hashtable$Entry objects. Hashmap 类型只能对对象进行操作,这很好,因为在Java中几乎所有东西都是JavaLang.Objor的子类。Hashmap type can only operate on objects, which is fine because in Java almost everything is a subclass of java. lang. 如果这个数量相对较小,你应该考虑使用EnumSet或EnumMap,而不是常用的HashSet或HashMap 。 If that number is relatively small, you should really consider using EnumSet or EnumMap, instead of regular HashSet or HashMap instead. HashMap 的执行过程,以及目前在Java8中的新的执行方式,并且探讨一下当使用HashMap时的性能、内存及已知的问题。HashMap , present what's new in the JAVA 8 implementation and talk about performance, memory and known issues when using HashMaps. 使用默认的加载因子0.75和足以包含指定collection中所有元素的初始容量来创建HashMap 。 The HashMap is created with default load factor(0.75) and an initial capacity sufficient to contain the elements in the specified collection. Hashtable和HashMap 的一个关键性的不同是,HashTable是同步的,而HashMap 不是。 The basic difference between a Hashtable and an HashMap is that, Hashtable is synchronized while HashMap is not. 如果这个键值非常小,我们就应该考虑使用EnumSet或EnumMap,而并非使用我们常用的HashSet或HashMap 。 If that number is relatively small, you should really consider using EnumSet or EnumMap, instead of regular HashSet or HashMap instead. 类似于HashMap ,HashSet不允许重复的key,只允许有一个nullkey,意思就是HashSet中只允许存储一个null对象。 Similar to HashMap , HashSet doesn't allow duplicate keys and only one null key, I mean you can only store one null object in HashSet. 如果这个数量相对来说较少,那么你就真的可以考虑使用EnumSet或EnumMap,而不是常见的HashSet或HashMap 。 If that number is relatively small, you should really consider using EnumSet or EnumMap, instead of regular HashSet or HashMap instead. 较高的值会降低空间开销,但提高查找成本(体现在大多数的HashMap 类的操作,包括get和put)。 Higher values decrease the space overhead but increase the lookup cost(reflected in most of the operations of the HashMap class, including get and put). 例如,可以提供一个封装了HashMap <i32,String>的People类型,用来储存人名以及相应的ID。 For example, we could provide a People type that wraps a HashMap <i32, String> that stores a person's ID associated with their name. 较高的值会减少空间成本,但会增加查找成本(反映在HashMap 类的大部分操作中,包含get和put)。 Higher values decrease the space overhead but increase the lookup cost(reflected in most of the operations of the HashMap class, including get and put). 根据开源代码Github,其主要核心开发人员是AntiochPeverell、GaryYu、hashmap 、IgnotusPeverell、QuentinLeSceller和Yeastplume。 According to the open-source code repository Github, its primary core developers are Antioch Peverell, Gary Yu, hashmap , Ignotus Peverell, Quentin Le Sceller, and Yeastplume. HashCode的通用约定,从而导致该类无法结合所有基于散列的集合一起正常运作,这样的集合包括HashMap 、HashSet和Hashtable。 HashCode(), which will prevent your class from functioning properly in conjunction with all hash-based collections, including HashMap , HashSet, and Hashtable.
Display more examples
Results: 29 ,
Time: 0.0296