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
KotlinユーザのためのJSpecify入門 / JSpecify 101 for Kotlin Devs
eller86
0
9
JavaとGroovyで書かれたGradleプラグインをKotlinで書き直した話 / Converted a Gradle plugin from Groovy&Java to Kotlin
eller86
0
1.1k
ヒューマンスキル / The Humanskills
eller86
0
550
医療機関向けシステムの信頼性 / Reliability of systems for medical institutions
eller86
0
300
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.5k
Goodbye JSR305, Hello JSpecify!
eller86
2
4.8k
Java8〜16におけるバイトコード生成の変化 / Changes of Bytecode Generation from Java 8 to 16
eller86
4
4.3k
Javaプログラミングの体験向上に関する活動 / DX enhancement around Java programming
eller86
0
3.8k
Other Decks in Technology
See All in Technology
安心してください、日本語使えますよ―Ubuntu日本語Remix提供休止に寄せて― 2024-11-17
nobutomurata
1
1k
ISUCONに強くなるかもしれない日々の過ごしかた/Findy ISUCON 2024-11-14
fujiwara3
8
880
プロダクト活用度で見えた真実 ホリゾンタルSaaSでの顧客解像度の高め方
tadaken3
0
190
誰も全体を知らない ~ ロールの垣根を超えて引き上げる開発生産性 / Boosting Development Productivity Across Roles
kakehashi
1
230
The Web Performance Landscape in 2024 [PerfNow 2024]
tammyeverts
0
110
[CV勉強会@関東 ECCV2024 読み会] オンラインマッピング x トラッキング MapTracker: Tracking with Strided Memory Fusion for Consistent Vector HD Mapping (Chen+, ECCV24)
abemii
0
230
OCI 運用監視サービス 概要
oracle4engineer
PRO
0
4.8k
DynamoDB でスロットリングが発生したとき/when_throttling_occurs_in_dynamodb_short
emiki
0
260
複雑なState管理からの脱却
sansantech
PRO
1
150
これまでの計測・開発・デプロイ方法全部見せます! / Findy ISUCON 2024-11-14
tohutohu
3
370
オープンソースAIとは何か? --「オープンソースAIの定義 v1.0」詳細解説
shujisado
10
1.2k
ドメインの本質を掴む / Get the essence of the domain
sinsoku
2
160
Featured
See All Featured
Navigating Team Friction
lara
183
14k
I Don’t Have Time: Getting Over the Fear to Launch Your Podcast
jcasabona
28
2k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
232
17k
Music & Morning Musume
bryan
46
6.2k
CoffeeScript is Beautiful & I Never Want to Write Plain JavaScript Again
sstephenson
159
15k
The Cost Of JavaScript in 2023
addyosmani
45
6.8k
The Art of Programming - Codeland 2020
erikaheidi
52
13k
"I'm Feeling Lucky" - Building Great Search Experiences for Today's Users (#IAC19)
danielanewman
226
22k
Imperfection Machines: The Place of Print at Facebook
scottboms
265
13k
Faster Mobile Websites
deanohume
305
30k
Become a Pro
speakerdeck
PRO
25
5k
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
93
16k
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)