Dear readers!
fliprank, a platform studying Computer Engineering who is a passionate learner with a mind full of innovative and passionate. I started my blogging to learn more about what exists behind the computer programs that we use everyday.
-XX:+UseG1GC
on the command line.-XX:InitiatingHeapOccupancyPercent
determines the initial value as a percentage of the size of the current old generation as long as there aren't enough observations to make a good prediction of the Initiating Heap Occupancy threshold. Turn off this behavior of G1 using the option-XX:-G1UseAdaptiveIHOP
. In this case, the value of -XX:InitiatingHeapOccupancyPercent
always determines this threshold.-XX:G1HeapReservePercent
as the extra buffer.-XX:G1HeapRegionSize
option.bool
, all kinds of integers, and floating point values. G1 opportunistically tries to reclaim humongous objects if they are not referenced by many objects at any kind of garbage collection pause. This behavior is enabled by default but you can disable it with the option -XX:G1EagerReclaimHumongousObjects
.-XX:MaxGCPauseTimeMillis
and -XX:PauseTimeIntervalMillis
based on long-term observations of actual pause time. It takes into account how long it took young generations of similar size to evacuate. This includes information like how many objects had to be copied during collection, and how interconnected these objects had been.-XX:G1NewSizePercent
and -XX:G1MaxNewSizePercent
determine to meet pause-time. See Garbage-First Garbage Collector Tuning for more information about how to fix long pauses.-XX:G1NewSizePercent
, and any old generation regions to reclaim space are added until G1 determines that adding further regions will exceed the pause time goal. In a particular garbage collection pause, G1 adds old generation regions in order of their reclamation efficiency, highest first, and the remaining available time to get the final collection set.-XX:G1MixedGCCountTarget
. The collection set candidate regions are all old generation regions that have an occupancy that's lower than -XX:G1MixedGCLiveThresholdPercent
at the start of the phase.-XX:G1HeapWastePercent
.-XX:-G1EagerReclaimHumongousObjects
. String deduplication is disabled by default. You can enable it using the option -XX:+G1EnableStringDeduplication
.“…Returns a stream consisting of the results of replacing each element of this stream with the contents of a mapped stream produced by applying the provided mapping function to each element…”
flatMap
and a possible example scenario. Let us consider a zoo and the list of animals in it. Then we can use the flatMap
to get an aggregate of animals in a list of Zoo. If we use the Pre-Java8 approach, we would be doing this by using multiple for-loops. Now the same can be achieve with Java 8 Stream API as below. import java.util.ArrayList; import java.util.HashSet; import java.util.List; import java.util.Set; import java.util.stream.Collectors; public class FlatMapExample { public static void main(String args[]) { List<Zoo> zooList = new ArrayList<>(); Zoo nationalZoo = new Zoo("National"); nationalZoo.add("Lion"); nationalZoo.add("Tiger"); nationalZoo.add("Peacock"); nationalZoo.add("Gorilla"); Zoo aCountyZoo = new Zoo("Wills County"); aCountyZoo.add("Peacock"); aCountyZoo.add("Camelion"); zooList.add(nationalZoo); zooList.add(aCountyZoo); // to get the aggregate List<String> animalList = zooList.stream() .flatMap(element -> element.getAnimals().stream()) .collect(Collectors.toList()); System.out.println(animalList); // to get the unique set Set<String> animalSet = zooList.stream() .flatMap(element -> element.getAnimals().stream()) .collect(Collectors.toSet()); System.out.println(animalSet); } } class Zoo { private String zooName; private Set<String> animals; public Zoo(String zooName) { this.zooName = zooName; this.animals = new HashSet<>(); } public void add(String animal) { this.animals.add(animal); } public Set<String> getAnimals() { return animals; } }
[Peacock, Lion, Tiger, Gorilla, Peacock, Camelion] [Peacock, Lion, Tiger, Gorilla, Camelion]
Add
|
Remove
|
Get
|
Contains
|
Data Structure
| |
ArrayList
|
O(1)
|
O(n)
|
O(1)
|
O(n)
|
Array
|
LinkedList
|
O(1)
|
O(1)
|
O(n)
|
O(n)
|
Linked List
|
CopyonWriteArrayList
|
O(n)
|
O(n)
|
O(1)
|
O(n)
|
Array
|
Add
|
Contains
|
Next
|
Data Structure
| |
HashSet
|
O(1)
|
O(1)
|
O(h/n)
|
Hash Table
|
LinkedHashSet
|
O(1)
|
O(1)
|
O(1)
|
Hash Table + Linked List
|
EnumSet
|
O(1)
|
O(1)
|
O(1)
|
Bit Vector
|
TreeSet
|
O(log n)
|
O(log n)
|
O(log n)
|
Red-black tree
|
CopyonWriteArraySet
|
O(n)
|
O(n)
|
O(1)
|
Array
|
ConcurrentSkipList
|
O(log n)
|
O(log n)
|
O(1)
|
Skip List
|
Offer
|
Peak
|
Poll
|
Size
|
Data Structure
| |
PriorityQueue
|
O(log n )
|
O(1)
|
O(log n)
|
O(1)
|
Priority Heap
|
LinkedList
|
O(1)
|
O(1)
|
O(1)
|
O(1)
|
Array
|
ArrayDequeue
|
O(1)
|
O(1)
|
O(1)
|
O(1)
|
Linked List
|
ConcurrentLinkedQueue
|
O(1)
|
O(1)
|
O(1)
|
O(n)
|
Linked List
|
ArrayBlockingQueue
|
O(1)
|
O(1)
|
O(1)
|
O(1)
|
Array
|
PriorirityBlockingQueue
|
O(log n)
|
O(1)
|
O(log n)
|
O(1)
|
Priority Heap
|
SynchronousQueue
|
O(1)
|
O(1)
|
O(1)
|
O(1)
|
None!
|
DelayQueue
|
O(log n)
|
O(1)
|
O(log n)
|
O(1)
|
Priority Heap
|
LinkedBlockingQueue
|
O(1)
|
O(1)
|
O(1)
|
O(1)
|
Linked List
|
Get
|
ContainsKey
|
Next
|
Data Structure
| |
HashMap
|
O(1)
|
O(1)
|
O(h / n)
|
Hash Table
|
LinkedHashMap
|
O(1)
|
O(1)
|
O(1)
|
Hash Table + Linked List
|
IdentityHashMap
|
O(1)
|
O(1)
|
O(h / n)
|
Array
|
WeakHashMap
|
O(1)
|
O(1)
|
O(h / n)
|
Hash Table
|
EnumMap
|
O(1)
|
O(1)
|
O(1)
|
Array
|
TreeMap
|
O(log n)
|
O(log n)
|
O(log n)
|
Red-black tree
|
ConcurrentHashMap
|
O(1)
|
O(1)
|
O(h / n)
|
Hash Tables
|
ConcurrentSkipListMap
|
O(log n)
|
O(log n)
|
O(1)
|
Skip List
|