Commonly used data structures in Java

List

List is an ordered sequence of objects. Elements can be inserted or accessed at a specific index. Popular implementations – ArrayList, LinkedList,

Set

Set is a collection which doesn’t allow duplicates. Popular implementations – HashSet, LinkedHashSet, etc.

Map

Map supports dictionary format (key, value). Popular implementations – HashMap, TreeMap, etc.

Bag

Bag counts the number of times an element appears in the collection.  Popular implementation – Apache commons collection Bag interface.

BidiMap

It’s bi-directional map. Allows lookup based on key or value. Popular implementation – Apache commons collection BidiMap. Google Guava implementation of BidiMap.

Trie

It’s a prefix tree. Read more on trie. Popular implementation  Apache commons collection Trie.

Multi-Map

Map of Map. Apache commons collections and Google Guava provide multi-map implementations.

Table

A collection that attaches row key and column key to a value is called Table. Google Guava provides an Table implementations.

Graph

Data structure for graph representing nodes and connections between them. Google guava provides Graph implementation.

 

One thought on “Commonly used data structures in Java

Leave a Reply

Your email address will not be published. Required fields are marked *