@Test public void testLeastRecentlyUsed() { ConcurrentLinkedHashMap<String, String> map = new ConcurrentLinkedHashMap<String, String>(true, 33, listener); System.out.println( map.getConcurrencyLevel() + "|" + map.getSegmentMask() + "|" + map.getSegmentShift()); for (int i = 0; i < 100; i++) { if (i > 75) map.get("75"); map.put("" + i, "v" + i); } Assert.assertThat(map.get("75"), is("v75")); }
@Test public void testMaxEntries() { ConcurrentLinkedHashMap<String, String> map = new ConcurrentLinkedHashMap<String, String>(true, 33, listener); System.out.println( map.getConcurrencyLevel() + "|" + map.getSegmentMask() + "|" + map.getSegmentShift()); for (int i = 0; i < 100; i++) { map.put("" + i, "v" + i); } System.out.println(map.size()); Assert.assertThat(map.size(), is(32)); }
public static void main(String[] args) { ConcurrentLinkedHashMap<String, String> map = new ConcurrentLinkedHashMap<String, String>(true, 33, listener); System.out.println( map.getConcurrencyLevel() + "|" + map.getSegmentMask() + "|" + map.getSegmentShift()); for (int i = 0; i < 100; i++) { map.put("key" + i, "v" + i); } System.out.println(map.toString()); for (int i = 0; i < 100; i++) { System.out.println(map.get("key" + i)); } System.out.println(map.get("key97")); System.out.println(map.get("key97")); System.out.println(map.get("key97")); System.out.println(map.get("key97")); System.out.println(map.get("key97")); }