Choosing between ArrayList and LinkedList - JEP Cafe #20
How you can choose between ArrayList and LinkedList for your application: the full tutorial.
The Collections Framework offers two implementation for the List interface: ArrayList and LinkedList. How can you choose the best one for your application? This JEP Café shows you how you can bench each implementation, and the amount of memory they consume.
⎯⎯⎯⎯⎯⎯ Chapters ⎯⎯⎯⎯⎯⎯
0:00 Intro
0:57 Choosing the best implementation for your use case
1:53 Choosing the most common operations for benchmark
2:43 Can you apply the O(n) complexity to your use case?
5:00 Using JMH to run your benchmarks
6:25 Reading elements from the beginning and the end of a list
9:03 Reading elements from the middle of a list
11:01 Introducing pointer chasing
12:51 Benching the impact of pointer chasing on LinkedList
14:27 Iterating over a list with an index or an Iterator
16:48 Creating an array-based list to speed up your iterations
17:53 Wrapping up pointer chasing
18:20 ArrayList caveats: insertion, deletion, and resizing
20:01 Benching insertion and resizing for ArrayList
21:48 Comparing inserting and adding for ArrayList and LinkedList
23:25 Comparing the memory consumption of ArrayList and LinkedList
26:27 Reducing your memory footprint by using trimToSize()
28:08 Wrapping up performances and memory consumption
30:26 Outro
⎯⎯⎯⎯⎯⎯ Resources ⎯⎯⎯⎯⎯⎯
◦ JMH on GitHub, with doc and samples ➱
◦ Alexey Shipilev’s blog ➱
◦ Alexey Shipilev on JMH ➱
◦ Java Object Layout on GitHub, with doc and samples ➱
◦ Don Raab on Java Object Layout ➱
◦ ➱
◦ ➱
◦ JDK 21 ➱
◦ OpenJDK ➱
◦ Oracle Java ➱
Tags: #Java #Java21 #OpenJDK #JDK #JDK21 #Collection #JEPCafe #insidejava
2 views
811
214
17 minutes ago 00:50:57 1
Metallica Live: Ride The Lightning / Full Album [2022-2023]
57 minutes ago 00:01:31 53
The Falconeer | Launch Trailer 🦅 | PC | XBOX SERIES X|S
2 hours ago 00:04:06 1
“Doin’ Time” (Sublime) Summertime Mashup Cover by Robyn Adele Anderson
3 hours ago 00:06:34 1
Roy Harper - Highway Blues (Remastered)
3 hours ago 00:01:11 1
One Eleven Menerung Bangsar ||# Stan Wong 012 3755399
3 hours ago 00:00:37 1
Rick Monday saves American flag from protesters in 1976
22 hours ago 00:01:44 1
Turok 3: Shadow of Oblivion Remastered - Official Launch Trailer
23 hours ago 00:10:34 1
Silkroad Origin Mobile - Official Launch Southeast Asia Gameplay Android APK iOS
1 day ago 02:02:15 1
UNBELIEVABLE Changes Ahead: MANKIND’S Great Shift Explained - PREPARE for 2024 RESET! | Sara Landon
1 day ago 00:01:01 1
Population of the USA 🇺🇸 Why 80% of Americans Live East of This Line?
2 days ago 00:04:11 1
Ariana Grande, The Weeknd - Love Me Harder
5 days ago 00:30:29 1
Elena Danaan : Divulgation galactique, contacts physiques et connexions du coeur