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
180
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
580
ヒューマンスキル / The Humanskills
eller86
0
460
医療機関向けシステムの信頼性 / Reliability of systems for medical institutions
eller86
0
240
Server-side Kotlinを使うスタートアップでどんなDetektルールが育ったか / Detekt rules made in start-up working with Server-side Kotlin
eller86
0
910
Java開発者向けのKotlin Gradleビルドスクリプト入門 / Gradle Build Script in Kotlin 101
eller86
1
1.2k
Goodbye JSR305, Hello JSpecify!
eller86
2
4.2k
Java8〜16におけるバイトコード生成の変化 / Changes of Bytecode Generation from Java 8 to 16
eller86
4
3.8k
Javaプログラミングの体験向上に関する活動 / DX enhancement around Java programming
eller86
0
3.6k
静的解析ツールで生産性向上
eller86
1
770
Other Decks in Technology
See All in Technology
複数の LLM モデルを扱う上で直面した辛みまとめ
kazuyaseki
1
230
GitHub最新情報キャッチアップ 2024年3月
dzeyelid
16
3.2k
20240321_生成AI時代のDevOps
kzkmaeda
2
610
OpenTelemetry実践 はじめの一歩
taxin
0
300
Tohoku.Tech #1 「Cursorを使ったRaspberry Piの開発」by ねこまた
jun2882
0
250
これまでのキャリアとこれからMLエンジニアとしてどう動くか
masatakashiwagi
0
210
暗黙知を集積するプラットフォーム : 「健常者エミュレータ事例集」の取り組み
sora32127
1
160
関数型DDDの理論と実践:「決定を遅らせる」を先につくり、 ビジネスの機動力と価値をあげる
knih
2
470
戦略的DDDを実践するための跳躍力 / OOC 2024
pictiny
6
3.8k
Cloud Deploy と仲良くなりたい
phaya72
1
100
私のRSpecの書き方 / How I write RSpec
tmtms
4
820
中央集権体制からDataOpsへの転換 / centralized-to-dataops-transformation
pei0804
7
1.4k
Featured
See All Featured
Design by the Numbers
sachag
274
18k
Being A Developer After 40
akosma
56
580k
GraphQLとの向き合い方2022年版
quramy
28
12k
BBQ
matthewcrist
78
8.7k
Templates, Plugins, & Blocks: Oh My! Creating the theme that thinks of everything
marktimemedia
18
1.7k
Fontdeck: Realign not Redesign
paulrobertlloyd
75
4.8k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
226
16k
Large-scale JavaScript Application Architecture
addyosmani
501
110k
How GitHub (no longer) Works
holman
301
140k
Visualizing Your Data: Incorporating Mongo into Loggly Infrastructure
mongodb
34
8.8k
Designing Dashboards & Data Visualisations in Web Apps
destraynor
225
51k
Faster Mobile Websites
deanohume
296
30k
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)