Ordering

Random Access

Key-Value Pairs

Allows Duplicates

Allows Null Values

Blocking Upper Operations Bounds Most Commonly Known Collections

Thread Safe

ArrayList

YES

YES

NO

YES

YES

NO

NO

NO

HashMap

NO

YES

YES

NO

YES

NO

NO

NO

Vector

YES

YES

NO

YES

YES

YES

NO

NO

Hashtable

NO

YES

YES

NO

NO

YES

NO

NO

Usage Scenarios * Default choice of List implementation * To store a bunch of things * Repetitions matters * Insertion order matters * Best implementation in case of huge lists which are read intensive (elements are accessed more frequently than inserted deleted) * Default choice of Map implementation * Majorly used for simple in-memory caching purpose. * Historical implementation of List * A good choice for thread-safe implementation * Similar to HashMap * Do not allow null values or keys * Entire map is locked for thread safety

Most Talked About Collections HashSet

NO

YES

NO

NO

YES

NO

NO

NO

TreeSet

YES

YES

NO

NO

NO

NO

NO

NO

LinkedList

YES

NO

NO

YES

YES

NO

NO

NO

ArrayDeque

YES

YES

NO

YES

NO

NO

NO

NO

Stack

YES

NO

NO

YES

YES

YES

NO

NO

TreeMap

YES

YES

YES

NO

NO

NO NO NO Special Purpose Collections

WeakHashMap

NO

YES

YES

NO

YES

NO

NO

NO

Arrays

YES

YES

NO

YES

YES

NO

NO

YES

Properties

NO

YES

YES

NO

NO

YES

NO

NO

* To store bunch of things * A very nice alternative for ArrayList if ** Do not want repetitions ** Ordering does not matter * To store bunch of things in sorted order * A very nice alternative for ArrayList if ** Do not want repetitions ** Sorted order * Sequential Access * Faster adding and deleting of elements * Slightly more memory than ArrayList * Add/Remove elements from both ends of the queue * Best alternative in case of huge lists which are more write intensive (elements added / deleted are more frequent than reading elements) * Random Access * Faster searching and retrieval of elements * Add/Remove elements from both ends of the queue * Best alternative in case of huge lists which are more read intensive * Similar to a Vector * Last-In-First-Out implementation * A very nice alternative for HashMap if sorted keys are important * The keys that are not referenced will automatically become eligible for garbage collection * Usually used for advanced caching techniques to store huge data and want to conserve memory * A Utility class provided to manipulate arrays ** Searching ** Sorting ** Converting to other Collection types such as a List * Properties are exactly same as the Hashtable * Keys and Values are String * Can be loaded from a input stream * Usually used to store application properties and configurations

Thread Safe Collections CopyOnWriteArrayList

YES

YES

NO

YES

YES

YES

NO

NO

ConcurrentHashMap

NO

YES

YES

NO

NO

YES

NO

NO

ConcurrentSkipListMap

YES

YES

YES

NO

NO

YES

NO

NO

* A thread safe variant of ArrayList * Best use for ** Small lists which are read intensive ** requires thread-safety * A thread safe variant of Hashtable * Best use for ** requires thread-safety ** Better performance at high load due to a better locking mechanism * A thread safe variant of TreeMap * Best use for ** requires thread-safety

Ordering

Random Access

Key-Value Pairs

Allows Duplicates

Allows Null Values

Thread Safe

Blocking Operations

Upper Bounds

ConcurrentSkipListSet

YES

NO

NO

NO

NO

YES

NO

NO

CopyOnWriteArraySet

YES

YES

NO

NO

YES

YES

NO

NO

ConcurrentLinkedQueue

YES

NO

NO

YES

NO

YES

NO

NO

ConcurrentLinkedDeque

YES

NO

NO

YES

NO

YES

NO

NO

Usage Scenarios * A thread safe variant of TreeSet * Best use for ** Do not want repetitions ** Sorted order ** Requires thread-safety * A thread-safe implementation of a Set * Best use for ** Small lists which are read intensive ** requires thread-safety ** Do not want repetitions * A thread-safe variant of PriorityQueue * Best use for ** Small lists ** No random access ** requires thread-safety "* A thread-safe variant of LinkedList * Best use for ** Small lists ** No random access ** Insertions, retrieval on both sides of the queue ** requires thread-safety"

Blocking Collections ArrayBlockingQueue

YES

NO

NO

YES

NO

YES

LinkedBlockingQueue

YES

NO

NO

YES

NO

YES

LinkedTransferQueue

YES

NO

NO

YES

NO

YES

PriorityBlockingQueue

YES

NO

NO

YES

NO

YES

LinkedBlockingDeque

YES

NO

NO

YES

NO

YES

SynchronousQueue

YES

NO

NO

YES

NO

YES

DelayQueue

YES

NO

NO

YES

NO

YES Source:

* Best use for Producer - Consumer type of scenarios with ** Lower capacity bound ** Predictable capacity * Has a bounded buffer. Space would be allocated during object creation * Best use for Producer - Consumer type of scenarios with ** Large capacity bound YES YES ** Unpredictable capacity * Upper bound is optional * Can be used in situations where the producers should wait for consumer YES YES to receive elements. e.g. Message Passing "* Best use for Producer - Consumer type of scenarios with ** Large capacity bound YES NO ** Unpredictable capacity ** Consumer needs elements in sorted order * A Deque implementation of LinkedBlockingQueue YES YES ** Can add elements at both head and tail * Both producer and consumer threads will have to wait for a handoff to occur. YES NO * If there is no consumer waiting. The element is not added to the collection. * Similar to a normal LinkedBlockingQueue YES NO * Elements are implementations of Delayed interface * Consumer will be able to get the element only when it's delay has expired http://www.janeve.me/articles/which-java-collection-to-use YES

YES

Ordering Random Access Key-Value Pairs Allows ... - Janeve.Me

Sequential Access. * Faster adding and deleting of elements. * Slightly more memory than ArrayList. * Add/Remove elements from both ends of the queue.

82KB Sizes 1 Downloads 112 Views

Recommend Documents

Ordering Random Access Key-Value Pairs Allows ... - Janeve.Me
Historical implementation of List. * A good choice for thread-safe implementation. Hashtable .... Has a bounded buffer. Space would be allocated during object ...

New tool allows library catalog access - Catawba County
Aug 1, 2011 - is free and available to library customers who use these Apple products. “This new tool allows customers to search for titles, place a hold on an ...

Random Access Over Multiple Access Channels: A ...
II. SYSTEM MODEL. A. Channel Model. We consider the multiple access channel described in [11]. There are 2 non-co-operating users who want to transmit data to a single receiver. Each transmitter has m antennas, and the receiver has n antennas. The tr

Online ordering instructions.
Online ordering instructions. 1. Go to our web site ... With the proof card provided to you please input the “Unique Code” and “Last Name” as it is shown on the ...

New IOS App Allows Users.pdf
There was a problem previewing this document. Retrying... Download. Connect more ... New IOS App Allows Users.pdf. New IOS App Allows Users.pdf. Open.

Apparatus for making a random access to the reverse common ...
Sep 2, 2005 - Motorola, Nortel, Qualcomm, Samsung) proposed as the ...... 33. A method for making a plurality of terminals have a random access to the ...

Performance evaluation of a reservation random access scheme for ...
We compute the steady state distribution of the Markov chain. This result is used to ... This work is supported by a University of California MICRO and Pacific-Bell ...

Apparatus for making a random access to the reverse common ...
Sep 2, 2005 - CDMA) chie?y developed in Europe and Japan. The future lMT-2000 system is to support both voiced data and packet data communications. In this case, it is very ineffective that the packet data is assigned with an exclusive channel as the

Multi-Group Random Access Resource Allocation ... - Semantic Scholar
J.-W. Choi (corresponding author) is with the Department of Informa- tion & Communication Engineering, Daegu ..... SIR (dB). Probability. Group 1 @ Underlay P1=1.0000P1. Group 2 @ Underlay P2=0.1975P1. Group 3 @ Underlay P3=0.0672P1. Group 1 @ Overla

Multi-Cell Aware Opportunistic Random Access
predefined physical layer data rate in a decentralized manner if the desired signal power to the ... Our analytical result is validated by computer simulations.

Apparatus for making a random access to the reverse common ...
Sep 2, 2005 - detection continuously transmit data and the other terminals stop data transmission. ..... mining and transmitting the broadcast signal may be reduced, thus making it possible ... Of course, the terminals that have attempted data ...

On the Energy Efficiency of Wireless Random Access ...
the SPR through extensive computer simulations. As for the energy ... communicate with a base station (BS) in a distributed manner. The random access ..... and funded by the MSIP(Ministry of Science, ICT & Future. Planning), Korea in the ICT ...

ACC Pairs Matches.pdf
Graeme Fisher & Bill Smith v Peter Knoll & Andy Scott. Norman Bruce & Marie Fisher v Terry Atkinson & Dave Pyle. Robert Shand & Charles Pressley v Ali ...

Starter Activity: Product pairs - cloudfront.net
environmental, social, economic issues included in the reasons for product choice? If you choose to do this activity before a piece of work on sustainability you.

Online ordering instructions.
(Please be aware of the order deadline highlighted in red so as not to incur any late charges, it's to ensure that the production time will be on schedule and every ...

Student ordering FAQs.pdf
Page 1. Whoops! There was a problem loading more pages. Retrying... Student ordering FAQs.pdf. Student ordering FAQs.pdf. Open. Extract. Open with. Sign In.

Starter Activity: Product pairs - cloudfront.net
practicalaction.org/schools ... organic vs non-organic. Tea/Coffee – fair trade vs non- fair trade. Sugar – ... relatively good or bad from a sustainability point of.

Maserati ghibli ordering guide pdf
Page 1 of 19. Page 1 of 19. Page 2 of 19. Page 2 of 19. Page 3 of 19. Page 3 of 19. Maserati ghibli ordering guide pdf. Maserati ghibli ordering guide pdf. Open.

Antiphonal calling allows individual discrimination in ...
Aug 8, 2008 - vampire bats, Diaemus youngi, adults produce social calls that are ...... percentage of the way to the end of the syllable. Table 3. Playback ...

skating pairs sochi.pdf
skating pairs sochi.pdf. skating pairs sochi.pdf. Open. Extract. Open with. Sign In. Main menu. Displaying skating pairs sochi.pdf.

Online ordering instructions.
on your computer or laptop. Don't use any smart phone to ... We will be delivering your package 7 – 10 day after the deadline, to the school and your child will be ...

On pseudolinearity and generic pairs
Feb 24, 2009 - dim, stp, acl, SU and Cb). A set A ⊂ (M,P) is called P-independent, if. A |. L. P (A)P(M). In [8], we showed that an LP -type of a P-independent set in a generic pair is determined by its quantifier free LP -type. For any pair of set