void () { IntObjectCache<Integer> cache = new IntObjectCache<>(4); cache.cacheObject(0, 0); cache.cacheObject(1, 1); cache.cacheObject(2, 2); cache.cacheObject(4, 4); cache.cacheObject(3, 3); cache.tryKey(4); cache.cacheObject(4, 5); HashSet<Object> values = new HashSet<>(); for (Object obj : cache) { values.add(obj); } assertFalse(values.contains(0)); assertTrue(values.contains(1)); assertTrue(values.contains(2)); assertTrue(values.contains(3)); assertTrue(values.contains(5)); assertTrue(cache.get(4).equals(5)); }