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
530
JavaとGroovyで書かれたGradleプラグインをKotlinで書き直した話 / Converted a Gradle plugin from Groovy&Java to Kotlin
eller86
0
1.2k
ヒューマンスキル / The Humanskills
eller86
0
570
医療機関向けシステムの信頼性 / Reliability of systems for medical institutions
eller86
0
320
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.6k
Goodbye JSR305, Hello JSpecify!
eller86
2
4.9k
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
ガバナンスを支える新サービス / New Services to Support Governance
sejima1105
0
470
プロダクト組織で取り組むアドベントカレンダー/Advent Calendar in Product Teams
mixplace
0
500
【re:Invent 2024 アプデ】 Prompt Routing の紹介
champ
1
280
新機能VPCリソースエンドポイント機能検証から得られた考察
duelist2020jp
0
250
pg_bigmをRustで実装する(第50回PostgreSQLアンカンファレンス@オンライン 発表資料)
shinyakato_
0
120
Wantedly での Datadog 活用事例
bgpat
2
850
小学3年生夏休みの自由研究「夏休みに Copilot で遊んでみた」
taichinakamura
0
190
DUSt3R, MASt3R, MASt3R-SfM にみる3D基盤モデル
spatial_ai_network
2
350
生成AIをより賢く エンジニアのための RAG入門 - Oracle AI Jam Session #20
kutsushitaneko
4
320
いまからでも遅くないコンテナ座学
nomu
0
160
スケールし続ける事業とサービスを支える組織とアーキテクチャの生き残り戦略 / The survival strategy for Money Forward’s engineering.
moneyforward
0
120
[Ruby] Develop a Morse Code Learning Gem & Beep from Strings
oguressive
1
200
Featured
See All Featured
Exploring the Power of Turbo Streams & Action Cable | RailsConf2023
kevinliebholz
28
4.4k
GraphQLとの向き合い方2022年版
quramy
44
13k
Creating an realtime collaboration tool: Agile Flush - .NET Oxford
marcduiker
26
1.9k
Docker and Python
trallard
43
3.2k
Side Projects
sachag
452
42k
Rails Girls Zürich Keynote
gr2m
94
13k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
28
2.1k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
111
50k
Documentation Writing (for coders)
carmenintech
67
4.5k
Performance Is Good for Brains [We Love Speed 2024]
tammyeverts
7
530
Designing for Performance
lara
604
68k
Building an army of robots
kneath
302
44k
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)