[Schmitzm-commits] r1576 - trunk/schmitzm-core/src/main/java/de/schmitzm/lang
scm-commit@wald.intevation.org
scm-commit at wald.intevation.org
Wed May 11 13:21:29 CEST 2011
Author: alfonx
Date: 2011-05-11 13:21:29 +0200 (Wed, 11 May 2011)
New Revision: 1576
Modified:
trunk/schmitzm-core/src/main/java/de/schmitzm/lang/TimedHashMap.java
Log:
Improved timedhashmap
Modified: trunk/schmitzm-core/src/main/java/de/schmitzm/lang/TimedHashMap.java
===================================================================
--- trunk/schmitzm-core/src/main/java/de/schmitzm/lang/TimedHashMap.java 2011-05-11 11:18:29 UTC (rev 1575)
+++ trunk/schmitzm-core/src/main/java/de/schmitzm/lang/TimedHashMap.java 2011-05-11 11:21:29 UTC (rev 1576)
@@ -3,6 +3,7 @@
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.HashMap;
+import java.util.Map;
import javax.swing.Timer;
@@ -28,6 +29,21 @@
}
@Override
+ public void putAll(Map<? extends K, ? extends V> m) {
+ final Long now = Long.valueOf(System.currentTimeMillis());
+ super.putAll(m);
+ for (K k : m.keySet()) {
+ inputTimes.put(k, now);
+ }
+ }
+
+ @Override
+ public V remove(Object key) {
+ inputTimes.remove(key);
+ return super.remove(key);
+ }
+
+ @Override
public V put(K key, V value) {
if (timeout > 0) {
@@ -70,7 +86,7 @@
V v = super.get(key);
if (v != null) {
Long inputTime = inputTimes.get(key);
- if (inputTime != null && (System.currentTimeMillis() - inputTime) >= timeout) {
+ if ((System.currentTimeMillis() - inputTime) >= timeout) {
remove(key);
inputTimes.remove(key);
return null;
More information about the Schmitzm-commits
mailing list