Adding JMCR-Stable version
[Benchmarks_CSolver.git] / JMCR-Stable / real-world application / jigsaw / src / org / w3c / util / LRUList.java
diff --git a/JMCR-Stable/real-world application/jigsaw/src/org/w3c/util/LRUList.java b/JMCR-Stable/real-world application/jigsaw/src/org/w3c/util/LRUList.java
new file mode 100644 (file)
index 0000000..fc7ded6
--- /dev/null
@@ -0,0 +1,85 @@
+// LRUList.java\r
+// $Id: LRUList.java,v 1.1 2010/06/15 12:25:41 smhuang Exp $\r
+// (c) COPYRIGHT MIT and INRIA, 1996.\r
+// Please first read the full copyright statement in file COPYRIGHT.html\r
+\r
+package org.w3c.util ;\r
+\r
+public abstract class LRUList {\r
+    protected LRUNode head ;\r
+    protected LRUNode tail ;\r
+\r
+    public LRUList()\r
+    {\r
+       this.head = new LRUNode() ;\r
+       this.tail = new LRUNode() ;\r
+       head.prev = null ;\r
+       head.next = tail ;\r
+       tail.prev = head ;\r
+       tail.next = null ;\r
+    }\r
+\r
+    /**\r
+     * Moves node to front of list. It can be a new node, or it can be \r
+     * an existing node.\r
+     * @param node the node\r
+     */\r
+\r
+    public abstract void toHead(LRUAble node) ;\r
+\r
+    /**\r
+     * Moves node to back of list. It can be a new node, or it can be\r
+     * an existing node.\r
+     * @param node the node\r
+     */\r
+\r
+    public abstract void toTail(LRUAble node) ;\r
+\r
+    /**\r
+     * Removes node if it's in list.\r
+     * Does nothing if it's not.\r
+     * When a node is removed, both its links are set to null.\r
+     * @param node The node to remove\r
+     * @return the same node\r
+     */\r
+\r
+    public abstract LRUAble remove(LRUAble node) ;\r
+\r
+    /**\r
+     * Obtain the backmost node.\r
+     * @return the backmost node, or null if list is empty\r
+     */\r
+\r
+    public abstract LRUAble getTail() ;\r
+\r
+    /**\r
+     * Obtain the frontmost node.\r
+     * @return the frontmost node, or null if list is empty\r
+     */\r
+\r
+    public abstract LRUAble getHead() ;\r
+\r
+    /**\r
+     * Obtain the backmost node, and remove it from list too.\r
+     * @return the backmost node, or null if list is empty\r
+     */\r
+\r
+    public abstract LRUAble removeTail() ;\r
+\r
+    /**\r
+     * Get the next node of this list.\r
+     * @return The next node, or <strong>null</strong> if this one was\r
+     * last.\r
+     */\r
+\r
+    abstract public LRUAble getNext(LRUAble node) ;\r
+\r
+    /**\r
+     * Get the previous node of this list.\r
+     * @return The previous node, or <strong>null</strong> if this one was\r
+     * last.\r
+     */\r
+\r
+    abstract public LRUAble getPrev(LRUAble node) ;\r
+\r
+}\r