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 (beta)
Search
Kengo TODA
August 20, 2012
Technology
2
96
collections in JDK (beta)
To explain the basic collection in JDK
Kengo TODA
August 20, 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
920
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
データマネジメントを支える武器としてのメタデータ管理
10xinc
2
950
戦略的DDDを実践するための跳躍力 / OOC 2024
pictiny
6
4.2k
Oracle Database で機械学習を始めよう! Oracle Machine Learning
oracle4engineer
PRO
1
140
これまでのキャリアとこれからMLエンジニアとしてどう動くか
masatakashiwagi
1
710
生成AIサービスPanorama AIご説明資料
sdt
0
300
私のRSpecの書き方 / How I write RSpec
tmtms
4
840
Introducing Pkl
enomotok
0
260
生成AI・LLM時代における 機械学習エンジニアとしてのキャリア戦略・開発戦略 / my-career-and-development-strategies-for-ml-engineer-2024
yuya4
4
930
中央集権体制からDataOpsへの転換 / centralized-to-dataops-transformation
pei0804
7
1.6k
こんなに簡単!AWSマルチアカウント
takuya_terada
0
120
KubeCon EU 2024 : Knative Maintainers Session
salaboy
0
380
技術広報経験0のEMがエンジニアブランディングをはじめてみた
coconala_engineer
1
140
Featured
See All Featured
A Modern Web Designer's Workflow
chriscoyier
689
190k
How GitHub (no longer) Works
holman
301
140k
Infographics Made Easy
chrislema
237
18k
Writing Fast Ruby
sferik
619
59k
BBQ
matthewcrist
78
8.7k
Optimizing for Happiness
mojombo
369
69k
実際に使うSQLの書き方 徹底解説 / pgcon21j-tutorial
soudai
111
35k
Raft: Consensus for Rubyists
vanstee
130
6.2k
Art, The Web, and Tiny UX
lynnandtonic
288
19k
How to Create Impact in a Changing Tech Landscape [PerfNow 2023]
tammyeverts
12
1.4k
No one is an island. Learnings from fostering a developers community.
thoeni
14
2k
Mobile First: as difficult as doing things right
swwweet
215
8.5k
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(0), #add(0, T): O(1) Bad to #get(int), #contains(T) : O(n)
How to choose? ArrayList: Stack When we needs random access
LinkedList: Queue (Deque) When we call #remove(int) 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 TreeSet LinkedHashSet
Legacy implementations Vector Stack Hashtable Properties @Deprecated
Additional collection Google guava contains useful collections Table<C, R, V>
Multiset<T> Multimap<K, V>