Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
collections in JDK
Search
Kengo TODA
August 26, 2012
Technology
2
190
collections in JDK
Kengo TODA
August 26, 2012
Tweet
Share
More Decks by Kengo TODA
See All by Kengo TODA
生成AI 業務応用向けガイドライン 斜め読み / Overview of Generative AI Business Application Guidelines
eller86
0
58
KotlinユーザのためのJSpecify入門 / JSpecify 101 for Kotlin Devs
eller86
0
1.1k
JavaとGroovyで書かれたGradleプラグインをKotlinで書き直した話 / Converted a Gradle plugin from Groovy&Java to Kotlin
eller86
0
1.3k
ヒューマンスキル / The Humanskills
eller86
0
610
医療機関向けシステムの信頼性 / Reliability of systems for medical institutions
eller86
0
340
Server-side Kotlinを使うスタートアップでどんなDetektルールが育ったか / Detekt rules made in start-up working with Server-side Kotlin
eller86
0
1.4k
Java開発者向けのKotlin Gradleビルドスクリプト入門 / Gradle Build Script in Kotlin 101
eller86
1
1.7k
Goodbye JSR305, Hello JSpecify!
eller86
2
5k
Java8〜16におけるバイトコード生成の変化 / Changes of Bytecode Generation from Java 8 to 16
eller86
4
4.3k
Other Decks in Technology
See All in Technology
フォーイット_エンジニア向け会社紹介資料_Forit_Company_Profile.pdf
forit_tech
1
1.7k
データエンジニアリング領域におけるDuckDBのユースケース
chanyou0311
9
2.5k
遷移の高速化 ヤフートップの試行錯誤
narirou
6
1.8k
日経のデータベース事業とElasticsearch
hinatades
PRO
0
260
LINEギフトにおけるバックエンド開発
lycorptech_jp
PRO
0
380
AIエージェント開発のノウハウと課題
pharma_x_tech
7
4.2k
4th place solution Eedi - Mining Misconceptions in Mathematics
rist
0
150
事業を差別化する技術を生み出す技術
pyama86
2
420
Exadata Database Service on Cloud@Customer セキュリティ、ネットワーク、および管理について
oracle4engineer
PRO
2
1.5k
AIエージェント元年@日本生成AIユーザ会
shukob
1
240
Amazon Athenaから利用時のGlueのIcebergテーブルのメンテナンスについて
nayuts
0
100
あなたが人生で成功するための5つの普遍的法則 #jawsug #jawsdays2025 / 20250301 HEROZ
yoshidashingo
2
320
Featured
See All Featured
A Tale of Four Properties
chriscoyier
158
23k
Bootstrapping a Software Product
garrettdimon
PRO
307
110k
The Cult of Friendly URLs
andyhume
78
6.2k
Rebuilding a faster, lazier Slack
samanthasiow
80
8.9k
Building a Modern Day E-commerce SEO Strategy
aleyda
38
7.1k
Navigating Team Friction
lara
183
15k
Refactoring Trust on Your Teams (GOTO; Chicago 2020)
rmw
33
2.8k
Imperfection Machines: The Place of Print at Facebook
scottboms
267
13k
Building a Scalable Design System with Sketch
lauravandoore
461
33k
Automating Front-end Workflow
addyosmani
1369
200k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
114
51k
Mobile First: as difficult as doing things right
swwweet
223
9.5k
Transcript
collections in JDK - basic data structures you should know
- 2012/Aug/29 Kengo TODA
Basic collection List<T> Set<T> Map<K, T>
ArrayList<T> It just wraps an array Good to #get(int): O(1)
Bad to #remove(int), #contains(T) : O(n)
LinkedList<T> Simple bidirectional list It costs more Java heap than
ArrayList Good to #remove & #add for head/tail: O(1) Bad to #get(int), #contains(T) : O(n)
How to choose? ArrayList: Stack When we needs random access
LinkedList: Stack, Queue (java.util.Deque) When we treat head or tail frequently
HashMap<K, V> It use hash table to manage key We
have to implement #hashCode() correctly It does not implement SortedMap interface
TreeMap<K, V> It use red-black tree to manage key We
have to implement Comparable or Comparator correctly It implements SortedMap
LinkedHashMap<K, V> A subclass of HashMap It has bidirectional list
to memory insertion- order (or access-order) It does not implement SortedMap interface
How to choose? HashMap Standard use TreeMap When we have
to use ordering LinkedHashMap When we have to memory insertion-order
Set ≒ Map HashSet → HashMap TreeSet → TreeMap LinkedHashSet
→ LinkedHashMap
Legacy implementations Vector Stack Hashtable Properties @Deprecated
Additional collection Google guava contains useful collections Table<C, R, V>
Multiset<T> Multimap<K, V>
References Source code (OpenJDK, Google guava)