In Java LinkedHashSet is created with backing HashSet creating LinkedHashMap with following LinkedHashMap constructor
map = new LinkedHashMap<>(initialCapacity, loadFactor);
Now in LinkedHashMap, the above constructor in turn calls
public LinkedHashMap(int initialCapacity, float loadFactor) {
super(initialCapacity, loadFactor);
accessOrder = false;
}
so is there any way to have a LinkedHashSet with accessOrder
set to true
?
This can help create LRU cache implementation with LinkedHashSet.