@Test public void testAdd() { HistoryMap hm = makeHistoryMap(); Assert.assertTrue("Expected other HistoryMap result, got " + hm, (hm.size() == 3) && hm.containsValue(s1) && hm.containsValue(s2) && hm.containsValue(s3)); hm.add(s4); Assert.assertTrue("First should be gone, but got" + hm, (hm.size() == 3) && hm.containsValue(s2) && hm.containsValue(s3) && hm.containsValue(s4)); }
public void add(T obj) { if (suppressDuplicates && containsValue(obj)) return; counter++; put(new Integer(counter), obj); if (size() >= maxEntries) try { remove(new Integer(counter - maxEntries)); } catch (Exception e) { log.error("Remove of entry from historymap without success." + e.getMessage()); } }
HistoryMap extends HashMap<Integer, T> { public void add(T obj) { if (suppressDuplicates && containsValue(obj)) return; counter++; put(new Integer(counter), obj); if (size() >= maxEntries) try { remove(new Integer(counter - maxEntries)); } catch (Exception e) { log.error("Remove of entry from historymap without success." + e.getMessage()); } } }
HistoryMap extends HashMap<Integer, T> { public void add(T obj) { if (suppressDuplicates && containsValue(obj)) return; counter++; put(new Integer(counter), obj); if (size() >= maxEntries) try { remove(new Integer(counter - maxEntries)); } catch (Exception e) { log.error("Remove of entry from historymap without success." + e.getMessage()); } } HistoryMap();  HistoryMap(int maxEntries, boolean suppressDuplicates); }
HistoryMap extends HashMap<Integer, T> { public void add(T obj) { if (suppressDuplicates && containsValue(obj)) return; counter++; put(new Integer(counter), obj); if (size() >= maxEntries) try { remove(new Integer(counter - maxEntries)); } catch (Exception e) { log.error("Remove of entry from historymap without success." + e.getMessage()); } } HistoryMap();  HistoryMap(int maxEntries, boolean suppressDuplicates); int getMaxEntries(); boolean doesSuppressDuplicates(); void add(T obj); void removeEntry(T obj); T getEntry(int index); Collection<T> getEntries(); Collection getEntriesReverse(); }
HistoryMap extends HashMap<Integer, T> { public void add(T obj) { if (suppressDuplicates && containsValue(obj)) return; counter++; put(new Integer(counter), obj); if (size() >= maxEntries) try { remove(new Integer(counter - maxEntries)); } catch (Exception e) { log.error("Remove of entry from historymap without success." + e.getMessage()); } } HistoryMap();  HistoryMap(int maxEntries, boolean suppressDuplicates); int getMaxEntries(); boolean doesSuppressDuplicates(); void add(T obj); void removeEntry(T obj); T getEntry(int index); Collection<T> getEntries(); Collection getEntriesReverse();  }