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
840
ヒューマンスキル / The Humanskills
eller86
0
500
医療機関向けシステムの信頼性 / Reliability of systems for medical institutions
eller86
0
270
Server-side Kotlinを使うスタートアップでどんなDetektルールが育ったか / Detekt rules made in start-up working with Server-side Kotlin
eller86
0
1.2k
Java開発者向けのKotlin Gradleビルドスクリプト入門 / Gradle Build Script in Kotlin 101
eller86
1
1.4k
Goodbye JSR305, Hello JSpecify!
eller86
2
4.5k
Java8〜16におけるバイトコード生成の変化 / Changes of Bytecode Generation from Java 8 to 16
eller86
4
4k
Javaプログラミングの体験向上に関する活動 / DX enhancement around Java programming
eller86
0
3.6k
静的解析ツールで生産性向上
eller86
1
840
Other Decks in Technology
See All in Technology
たくさん本を読んだけど 1年後には綺麗サッパリ!を乗り越えて 学習の鬼になるぞ👹
yum3
0
160
目標設定は好きですか? アジャイルとともに目標と向き合い続ける方法 / Do you like target Management?
kakehashi
10
3k
スレットハンティングについて知っておきたいこと
hacket
0
130
AWSで”最小権限の原則”を実現するための考え方 /20240722-ssmjp-aws-least-privilege
opelab
10
4.3k
フルリモートワークはエンジニアの夢を叶えたか? #cm_odyssey
mamohacy
2
600
【基調講演】変える、今ここから ― IoTとAIで紡ぐ未来
soracom
PRO
0
310
コミュニティサービスに「あなたへ」フィードを リリースするまでの試行錯誤
takapy
1
140
エンジニア向け会社紹介資料
caddi_eng
14
220k
Azure OpenAI Service Dev Day / LLMでできる!使える!生成AIエージェント
masahiro_nishimi
3
740
RAGのサービスをリリースして1年3ヶ月が経ちました
segavvy
4
900
技術負債による事業の失敗はなぜ起こるのか / Why do business failures due to technical debt occur?
i35_267
0
190
[I/O Extended Android 2024] What`s new in Android 2024
kyeongwan
0
220
Featured
See All Featured
Building Adaptive Systems
keathley
34
2k
Making the Leap to Tech Lead
cromwellryan
127
8.7k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
24
1.8k
Design by the Numbers
sachag
277
18k
How to name files
jennybc
67
96k
It's Worth the Effort
3n
181
27k
Building Your Own Lightsaber
phodgson
101
5.9k
A better future with KSS
kneath
231
17k
Writing Fast Ruby
sferik
623
60k
Building a Modern Day E-commerce SEO Strategy
aleyda
25
6.7k
Thoughts on Productivity
jonyablonski
64
4.1k
ParisWeb 2013: Learning to Love: Crash Course in Emotional UX Design
dotmariusz
105
6.8k
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)