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
JavaとGroovyで書かれたGradleプラグインをKotlinで書き直した話 / Converted a Gradle plugin from Groovy&Java to Kotlin
eller86
0
1k
ヒューマンスキル / The Humanskills
eller86
0
510
医療機関向けシステムの信頼性 / Reliability of systems for medical institutions
eller86
0
290
Server-side Kotlinを使うスタートアップでどんなDetektルールが育ったか / Detekt rules made in start-up working with Server-side Kotlin
eller86
0
1.3k
Java開発者向けのKotlin Gradleビルドスクリプト入門 / Gradle Build Script in Kotlin 101
eller86
1
1.4k
Goodbye JSR305, Hello JSpecify!
eller86
2
4.7k
Java8〜16におけるバイトコード生成の変化 / Changes of Bytecode Generation from Java 8 to 16
eller86
4
4.2k
Javaプログラミングの体験向上に関する活動 / DX enhancement around Java programming
eller86
0
3.7k
静的解析ツールで生産性向上
eller86
1
880
Other Decks in Technology
See All in Technology
マーケットプレイス版Oracle WebCenter Content For OCI
oracle4engineer
PRO
2
220
業務ヒアリングと知識の呪い
tamai_63
0
220
軽いノリで"自動化"に取り組んではいけないという話
tetsuyaooooo
1
440
【swonet.conf_】NOCメンバーが語るSTMの実態!! ~ShowNetから若者への贈り物~
shownet
PRO
0
290
HashHub会社案内「なぜ今、パブリックブロックチェーンに賭けるのか」
hashhub
3
75k
Azure App Service on Linux の Sidecar に Phi-3 を配置してインテリジェントなアプリケーションを作ってみよう/jazug-anniv14
thara0402
0
320
Oracle Database 23ai 新機能#4 Real Application Clusters
oracle4engineer
PRO
0
140
低コストで実現する社内文書RAG機能を搭載したAIチャットボット開発
takapy
4
690
Azure Verified Moduleを触って分かった注目ポイント/azure-verified-module-begin
mhrtech
1
330
Hazard pointers with reference counter
ennael
PRO
0
120
たった一人で始めた音楽制作が気がついたら会社公認の部活動になっていた話〜組織の垣根を超えるコラボレーションを実現するには〜 / On-KAG-bu
piyonakajima
0
200
Assisted reorganization of data structures
ennael
PRO
0
240
Featured
See All Featured
Making Projects Easy
brettharned
114
5.8k
Designing on Purpose - Digital PM Summit 2013
jponch
114
6.9k
Testing 201, or: Great Expectations
jmmastey
38
7k
Helping Users Find Their Own Way: Creating Modern Search Experiences
danielanewman
29
2.2k
The Language of Interfaces
destraynor
154
24k
Designing for Performance
lara
604
68k
The Brand Is Dead. Long Live the Brand.
mthomps
53
38k
Navigating Team Friction
lara
183
14k
It's Worth the Effort
3n
183
27k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
26
1.9k
Web development in the modern age
philhawksworth
205
10k
5 minutes of I Can Smell Your CMS
philhawksworth
202
19k
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)