Skip to content

Latest commit

History

43 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Java Collections Big O Performance Summary

Below are the time complexity details for common functions of major Java Collection classes.

List Implementations

List TypeAddRemoveGetContainsNextData Structure
ArrayListO(1)O(n)O(1)O(n)O(1)Array
LinkedListO(1)O(1)O(n)O(n)O(1)Linked List
CopyOnWriteArrayListO(n)O(n)O(1)O(n)O(1)Array

Set Implementations

Set TypeAddRemoveContainsNextSizeData Structure
HashSetO(1)O(1)O(1)O(h/n)O(1)Hash Table
LinkedHashSetO(1)O(1)O(1)O(1)O(1)Hash Table + Linked List
EnumSetO(1)O(1)O(1)O(1)O(1)Bit Vector
TreeSetO(log n)O(log n)O(log n)O(log n)O(1)Red-black tree
CopyOnWriteArraySetO(n)O(n)O(n)O(1)O(1)Array
ConcurrentSkipListSetO(log n)O(log n)O(log n)O(1)O(n)Skip List

Queue Implementations

Queue TypeOfferPeekPollRemoveSizeData Structure
PriorityQueueO(log n)O(1)O(log n)O(n)O(1)Priority Heap
LinkedListO(1)O(1)O(1)O(1)O(1)Array
ArrayDequeO(1)O(1)O(1)O(n)O(1)Linked List
ConcurrentLinkedQueueO(1)O(1)O(1)O(n)O(n)Linked List
ArrayBlockingQueueO(1)O(1)O(1)O(n)O(1)Array
PriorityBlockingQueueO(log n)O(1)O(log n)O(n)O(1)Priority Heap
SynchronousQueueO(1)O(1)O(1)O(n)O(1)None
DelayQueueO(log n)O(1)O(log n)O(n)O(1)Priority Heap
LinkedBlockingQueueO(1)O(1)O(1)O(n)O(1)Linked List

Map Implementations

Map TypeGetContainsKeyNextData Structure
HashMapO(1)O(1)O(h / n)Hash Table
LinkedHashMapO(1)O(1)O(1)Hash Table + Linked List
IdentityHashMapO(1)O(1)O(h / n)Array
WeakHashMapO(1)O(1)O(h / n)Hash Table
EnumMapO(1)O(1)O(1)Array
TreeMapO(log n)O(log n)O(log n)Red-black tree
ConcurrentHashMapO(1)O(1)O(h / n)Hash Tables
ConcurrentSkipListMapO(log n)O(log n)O(1)Skip List

Note:O(h/n) where h is the table capacity; for non-hash tables, ignore this detail.

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

Languages