employer cover photo
employer logo

Pregunta de entrevista de VMware

Write the implementation for LRUMap.

Respuesta de la entrevista

Anónimo

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