Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Sign up for free
Menu
Search
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Features
All features
Private URLs
Password Protection
Custom URLS
Scheduled publishing
Remove Branding
Restrict embedding
Deck Collections
Notes
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Explore
Featured decks
Featured speakers
Programming
Technology
Storyboards
Pricing
Search
Sign in
Sign up for free
collections in JDK
Search
Kengo TODA
August 26, 2012
Technology
220
2
Share
Embed
Copy iframe code
Copy JS code
Copy link
Start on current slide
collections in JDK
Kengo TODA
August 26, 2012
Transcript
13 slides
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)
More Decks by Kengo TODA
See All by Kengo TODA
セキュリティ担当がいない中小医療機関を院外のRISSはどう支えるべきか / How External RISS Can Help Small Medical Institutions
eller86
1
250
AI といっしょに仕事をする(子供向け)
eller86
0
61
Kotlin 開発のツラミを爆破した話! / Explode the difficulty of Kotlin dev!
eller86
0
230
生成AI 業務応用向けガイドライン 斜め読み / Overview of Generative AI Business Application Guidelines
eller86
0
230
KotlinユーザのためのJSpecify入門 / JSpecify 101 for Kotlin Devs
eller86
0
2.5k
JavaとGroovyで書かれたGradleプラグインをKotlinで書き直した話 / Converted a Gradle plugin from Groovy&Java to Kotlin
eller86
0
2k
ヒューマンスキル / The Humanskills
eller86
0
790
医療機関向けシステムの信頼性 / Reliability of systems for medical institutions
eller86
0
560
Server-side Kotlinを使うスタートアップでどんなDetektルールが育ったか / Detekt rules made in start-up working with Server-side Kotlin
eller86
0
1.7k
Other Decks in Technology
See All in Technology
田んぼから始まる挑戦 〜新米農家の1年目〜
miu_crescent
PRO
0
160
長い仕事を任せる (Workflows、クラウドセッション、Kiro Web) | 目指せ Kiro マスター 10
inariku
PRO
3
180
bpf_arenaとstruct_opsを使うのが難しかった話
masu_mi
0
230
農夫は秘伝のタレを知らない - NOBODY KNOWS THE HIDDEN SOURCE - Kaggriculture 3rd Place Solution
masspeaks
0
230
AIエージェントの監視、思考を見るか行動を見るか / Monitoring AI Agents: Thoughts or Actions
yusukeshimizu
2
190
AWSを利用する上で知っておきたい名前解決の話 2026
nagisa53
5
3.5k
Claude Codeで新規事業を伸ばせるか? Zennの試行錯誤の記録
wadayusuke
2
160
内製アプリとClaudeスキルのセキュリティチェック、 Backlogの課題で回しています。
ayaka_egaaa
0
180
少ない人手 限られた予算 それでも守る 消せない・見つける・戻れる オールハザード型BCP on AWS / 20261107 Mitsutoshi Matsuo
shift_evolve
PRO
0
370
ゼロから作るWebアプリの新定番!?Amplify Gen 2 × AWS Blocksで実現する「開発速度とRDBの柔軟性のいいとこ取り」
amixedcolor
1
250
Oracle Base Database Service 技術詳細
oracle4engineer
PRO
17
120k
Kiro IDE 入門 (画面の各部から、頼み方、任せ方、戻し方まで) | 目指せ Kiro マスター 02
inariku
PRO
4
220
Featured
See All Featured
YesSQL, Process and Tooling at Scale
rocio
174
15k
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
2
1.7k
Docker and Python
trallard
47
4.3k
AI: The stuff that nobody shows you
jnunemaker
PRO
12
1.3k
Why Our Code Smells
bkeepers
PRO
340
58k
Music & Morning Musume
bryan
48
7.5k
Building Better People: How to give real-time feedback that sticks.
wjessup
371
20k
GraphQLの誤解/rethinking-graphql
sonatard
75
12k
Bash Introduction
62gerente
615
220k
The #1 spot is gone: here's how to win anyway
tamaranovitovic
4
1.2k
Principles of Awesome APIs and How to Build Them.
keavy
128
18k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k