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

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

    震惊

    震惊

版权所有 IT知识库 CopyRight © 2009-2015 IT知识库 IT610.com , All Rights Reserved. 京ICP备09083238号