Java Common Collection class: Deque,arraylist,hashmap,hashset

Source: Internet
Author: User

  1. Queue Family
    1. Whether it is a queue or a stack, the Deque Implementation class is now commonly used : such as single-threaded arrayqueue, multithreaded Arrayblockingqueue
    2. Deque: Read as "Deck", is a "double-end queue", that is, support for head and tail data access and additions and deletions. ----support for stack and queue operations
    3. Relationship: Arraydeque---Deque (i), Collection (i), which represents the inheritance,--> represents the implementation, (i) represents the interface.
    4. Relationship: Vector->abstractlist, Stack. The Stack method is not as complete and stable as deque, so the Deque implementation class is preferred to represent the stack.
  2. List family
    1. Vector and ArrayList basically, are the collection family under the list of the implementation class, are mutable arrays, but vector is thread synchronization, ArrayList is not. Therefore, if there is no synchronization requirements, it is recommended to use ArrayList
    2. LinkedList implements a number of interfaces, such as List,deque, which are doubly linked lists, which are supported by the general operation of the list. But it is also single-threaded (that is, unsynchronized), but probably because it is too big? --not often used anyway
  3. Map family
    1. HashMap and Hashtable are similar. However, the HashMap is single-threaded (non-synchronous) and supports null (both the key and the value are null). The Hashtable is synchronous, and neither the key nor the value is null. Common HashMap
  4. Set family
    1. HashSet behind is hashmap in support, its add () operation is added is the key value, so hashset does not allow the insertion of duplicate values, of course, allowed to insert null (HashMap allow null key)

Above is my usual, here copy a summary of the article (which deprecated should refer to not used, not in favor of use, not abandoned): http://www.importnew.com/13801.html

Single Thread Concurrent
Lists
  • ArrayList--based on a generic array
  • LinkedList--Not recommended for use
  • Vector--Obsolete (deprecated)
  • CopyOnWriteArrayList--almost not updated, often used to traverse
Queues/deques
  • Arraydeque --based on generic array
  • Stack -- Deprecated (deprecated)
  • Priorityqueue -The contents of the read operation are sorted
    • arrayblockingqueue -- Blocked queues with boundaries
    • Concurrentlinkeddeque/concurrentlinkedqueue --Borderless list queue (CAS)
    • delayqueue --element with deferred queue
    • Linkedblockingdeque/linkedblockingqueue --linked list queue (with lock), can be set with bounds
    • LinkedTransferQueue -The element ' transfer ' can be w/o stored
    • priorityblockingqueue --Concurrent priorityqueue
    • synchronousqueue --Using the Queue interface for Exchanger
Maps
  • HashMap--General Map
  • EnumMap--Key useenum
  • Hashtable--Obsolete (deprecated)
  • IdentityHashMap--use == the key to compare
  • LinkedHashMap--Keep the insertion order
  • TreeMap--Key is sorted
  • WeakHashMap--For caching (cache)
  • ConcurrentHashMap--General concurrency Map
  • ConcurrentSkipListMap--Sorted concurrency map
Sets
    • HashSet--Universal Set
    • EnumSet-- enum Set
    • BitSet--bit or dense integer set
    • LinkedHashSet--Keep the insertion order
    • TreeSet--Sort Set

  • ConcurrentSkipListSet--Sort Concurrent Set
  • CopyOnWriteArraySet--almost not updated, usually only do traversal

Java Common Collection class: Deque,arraylist,hashmap,hashset

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.