当前位置:首页 > 开发 > 编程语言 > 编程 > 正文

LinkedHashSet

发表于: 2012-01-17   作者:darrenzhu   来源:转载   浏览次数:
摘要: Linked Hash Set: 1)LinkedHashSet implementation is a subclass of the HashSet class. It works similarly to a HashSet, except for one important detail. Unlike a HashSet, a LinkedHashSet guarantees that
Linked Hash Set:
1)LinkedHashSet implementation is a subclass of the HashSet class. It works similarly to a HashSet, except for one important detail. Unlike a HashSet, a LinkedHashSet guarantees that the iterator will access the elements in insertion order, that is, in the order in which they were inserted into the LinkedHashSet.
2)This implementation differs from HashSet in that it maintains a doubly-linked list running through all of its entries.
3)The initial capacity (i.e., the number of buckets in the hash table) and its load factor (i.e., the ratio of number of elements stored to its current capacity) can be tuned when the set is created. The default values for these parameters will under most circumstances provide acceptable performance.

Use tips:
A LinkedHashSet is an ordered version of HashSet that maintains a doubly-linked List across all elements. Use this class instead of HashSet when you care about the iteration order. When you iterate through a HashSet the order is unpredictable, while a LinkedHashSet lets you iterate through the elements in the order in which they were inserted.

Resources:
You can reference the following URL to see the comparison among TreeSet,HashSet and LinkedHashSet:
http://vidyapsi.wordpress.com/2009/01/22/treeset-vs-hashset-vs-linkedhashset/
Also you can reference the follwoing URL for more details about Set:
http://java4coders.com/tag/linkedhashset-vs-hashset/

LinkedHashSet

  • 0

    开心

    开心

  • 0

    板砖

    板砖

  • 0

    感动

    感动

  • 0

    有用

    有用

  • 0

    疑问

    疑问

  • 0

    难过

    难过

  • 0

    无聊

    无聊

  • 0

    震惊

    震惊

编辑推荐
我们常说List集合是有序、可重复;Set集合是无序、不可重复的。 那么我们试试一个程序,说明为什么L
一、Collection常用的方法: Java 集合可分为 Set、List 和 Map 三种体系: Set:无序、不可重复的
1.容器API的类图结构如下: JAVA的集合类是一种特别有用的工具类,它可以用于存储数量不等的多个对
版权所有 IT知识库 CopyRight © 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号