[Mulgara-svn] r1979 - trunk/src/jar/util/java/org/mulgara/util
pag at mulgara.org
pag at mulgara.org
Fri Oct 1 04:04:09 UTC 2010
Author: pag
Date: 2010-10-01 04:04:07 +0000 (Fri, 01 Oct 2010)
New Revision: 1979
Modified:
trunk/src/jar/util/java/org/mulgara/util/StringToLongMap.java
Log:
Added a finalizer to clean up, plus parameterized the cache for generics
Modified: trunk/src/jar/util/java/org/mulgara/util/StringToLongMap.java
===================================================================
--- trunk/src/jar/util/java/org/mulgara/util/StringToLongMap.java 2010-10-01 04:02:51 UTC (rev 1978)
+++ trunk/src/jar/util/java/org/mulgara/util/StringToLongMap.java 2010-10-01 04:04:07 UTC (rev 1979)
@@ -257,6 +257,14 @@
}
/**
+ * Ensure that resources are cleaned up correctly, if not already done.
+ * @see java.lang.Object#finalize()
+ */
+ protected void finalize() {
+ delete();
+ }
+
+ /**
* Reorgainizes all the key/value pairs in the hash table to accomodate the
* new size.
*
@@ -350,8 +358,11 @@
return pos;
}
- static final class Cache extends LinkedHashMap {
+ static final class Cache extends LinkedHashMap<String,Long> {
+ /** serialization ID */
+ private static final long serialVersionUID = -1793863465408688001L;
+
public static final float LOAD_FACTOR = 0.75F;
final int MAX_SIZE;
@@ -360,7 +371,7 @@
MAX_SIZE = maxSize;
}
- protected boolean removeEldestEntry(Map.Entry eldest) {
+ protected boolean removeEldestEntry(Map.Entry<String,Long> eldest) {
return size() > MAX_SIZE;
}
@@ -371,7 +382,7 @@
public Long get(String s) {
assert s != null;
- return (Long)super.get(s);
+ return super.get(s);
}
}
More information about the Mulgara-svn
mailing list