mass rename and rebranding from xwt to ibex - fixed to use ixt files
[org.ibex.core.git] / src / org / xwt / util / Cache.java
diff --git a/src/org/xwt/util/Cache.java b/src/org/xwt/util/Cache.java
deleted file mode 100644 (file)
index 1822363..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-// Copyright (C) 2003 Adam Megacz <adam@xwt.org> all rights reserved.
-//
-// You may modify, copy, and redistribute this code under the terms of
-// the GNU Library Public License version 2.1, with the exception of
-// the portion of clause 6a after the semicolon (aka the "obnoxious
-// relink clause")
-
-package org.xwt.util;
-
-import java.util.*;
-
-// FIXME needs to be a weak hash
-
-/**
- *  A Hash table with a fixed size; drops extraneous elements.  Uses
- *  LRU strategy.
- */
-public class Cache extends Hash {
-
-    /** head of list is the mru; tail is the lru */
-    Node mru = null;
-    Node lru = null;
-
-    private int maxSize;
-    private Cache() { }
-    public Cache(int maxSize) {
-        super(maxSize * 2, 3);
-        this.maxSize = maxSize;
-    }
-
-    /** A doubly-linked list */
-    private class Node {
-        final Object val;
-        final Object k1;
-        final Object k2;
-        public Node(Object k1, Object k2, Object val) { this.k1 = k1; this.k2 = k2; this.val = val; }
-        Node next = null;
-        Node prev = null;
-        void remove() {
-            if (this == lru) lru = prev;
-            if (this == mru) mru = next;
-            if (next != null) next.prev = prev;
-            if (prev != null) prev.next = next;
-            next = prev = null;
-        }
-        void placeAfter(Node n) {
-            remove();
-            if (n == null) return;
-            next = n.next;
-            if (n.next != null) n.next.prev = this;
-            n.next = this;
-            prev = n;
-        }
-        void placeBefore(Node n) {
-            remove();
-            if (n == null) return;
-            next = n;
-            prev = n.prev;
-            n.prev = this;
-            if (prev != null) prev.next = this;
-        }
-    }
-
-    public void clear() {
-        lru = null;
-        super.clear();
-    }
-
-    public void remove(Object k1, Object k2) {
-        Object o = super.get(k1, k2);
-        if (o != null) ((Node)o).remove();
-        super.remove(k1, k2);
-    }
-
-    public Object get(Object k1, Object k2) {
-        Node n = (Node)super.get(k1, k2);
-        if (n == null) return null;
-        n.remove();
-        n.placeBefore(mru);
-        mru = n;
-        return n.val;
-    }
-
-    public void put(Object k1, Object k2, Object v) {
-        Node n = new Node(k1, k2, v);
-        if (lru == null) {
-            lru = mru = n;
-        } else {
-            n.placeBefore(mru);
-            mru = n;
-        }
-        if (super.get(k1, k2) != null) remove(k1, k2);
-        super.put(k1, k2, n);
-        if (size > maxSize) remove(lru.k1, lru.k2);
-    }
-
-}
-
-