It was never so easy to get YouTube subscribers
Get Free YouTube Subscribers, Views and Likes

Choosing between ArrayList and LinkedList - JEP Cafe #20

Follow
Java

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 arraybased 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 ➱ https://github.com/openjdk/jmh
◦ Alexey Shipilev's blog ➱ https://shipilev.net/
◦ Alexey Shipilev on JMH ➱    • Java Microbenchmark Harness: The Less...  
◦ Java Object Layout on GitHub, with doc and samples ➱ https://github.com/openjdk/jol
◦ Don Raab on Java Object Layout ➱ https://betterprogramming.pub/sweatin...
◦ Dev.java ➱ https://dev.java
◦ Inside.java ➱ https://inside.java
◦ JDK 21 ➱ https://openjdk.org/projects/jdk/21'>https://openjdk.org/projects/jdk/21
◦ OpenJDK ➱ https://openjdk.org
◦ Oracle Java ➱ https://www.oracle.com/java/

Tags: #Java #Java21 #OpenJDK #JDK #JDK21 #Collection #JEPCafe #insidejava

posted by Brunton6x