employer cover photo
employer logo

Pergunta de entrevista da empresa VMware

Write the implementation for LRUMap.

Resposta da entrevista

Sigiloso

28 de abr. de 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