/** * The readonly requests, ordered by the frequency they got registered, from least-frequently to most-frequently. * @return a list of readonly requests. */ public List<String> getReadOnlyRequestsByFrequency() { return _readOnlyRequests.getKeysSortedByValue( ATOMLONG_COMP ); }
@Test public void testGetKeysSortedByValue() { final LRUCache<String,Integer> cut = new LRUCache<String, Integer>( 3 ); final String f = "foo"; final String br = "bar"; cut.put(f, 1); cut.put(br, 2); final Comparator<Integer> c = new Comparator<Integer>() { @Override public int compare( final Integer o1, final Integer o2 ) { return o1.compareTo( o2 ); } }; Assert.assertTrue( Arrays.equals( new String[]{ f, br }, cut.getKeysSortedByValue( c ).toArray() ), "invalid order of items, the keys are not order by their values" ); cut.put(f, 3); Assert.assertTrue( Arrays.equals( new String[]{ br, f }, cut.getKeysSortedByValue( c ).toArray() ), "invalid order of items, the keys are not order by their values" ); }
/** * The readonly requests, ordered by the frequency they got registered, from least-frequently to most-frequently. * @return a list of readonly requests. */ public List<String> getReadOnlyRequestsByFrequency() { return _readOnlyRequests.getKeysSortedByValue( ATOMLONG_COMP ); }