employer cover photo
employer logo

Sollicitatievraag bij VMware

Write the implementation for LRUMap.

Antwoord op sollicitatievraag

Anoniem

28 apr 2015

LRU stands for Least Recently Used. LRUMap uses the LRU algorithm to delete the least recently used value in the map (presumably full) to make space for the newest entry. Implementation using Java: import java.util.Collections; import java.util.Map; import org.apache.commons.collections.map.LRUMap; public class LRUSample { private static final int MAX_CAPACITY = 5; public static void main(String[] args) { Map lruMap = (Map) Collections.synchronizedMap(new LRUMap(MAX_CAPACITY)); for(int i = 0; i

1