01: // LRUList.java
02: // $Id: LRUList.java,v 1.7 2000/08/16 21:37:58 ylafon Exp $
03: // (c) COPYRIGHT MIT and INRIA, 1996.
04: // Please first read the full copyright statement in file COPYRIGHT.html
05:
06: package org.w3c.util;
07:
08: public abstract class LRUList {
09: protected LRUNode head;
10: protected LRUNode tail;
11:
12: public LRUList() {
13: this .head = new LRUNode();
14: this .tail = new LRUNode();
15: head.prev = null;
16: head.next = tail;
17: tail.prev = head;
18: tail.next = null;
19: }
20:
21: /**
22: * Moves node to front of list. It can be a new node, or it can be
23: * an existing node.
24: * @param node the node
25: */
26:
27: public abstract void toHead(LRUAble node);
28:
29: /**
30: * Moves node to back of list. It can be a new node, or it can be
31: * an existing node.
32: * @param node the node
33: */
34:
35: public abstract void toTail(LRUAble node);
36:
37: /**
38: * Removes node if it's in list.
39: * Does nothing if it's not.
40: * When a node is removed, both its links are set to null.
41: * @param node The node to remove
42: * @return the same node
43: */
44:
45: public abstract LRUAble remove(LRUAble node);
46:
47: /**
48: * Obtain the backmost node.
49: * @return the backmost node, or null if list is empty
50: */
51:
52: public abstract LRUAble getTail();
53:
54: /**
55: * Obtain the frontmost node.
56: * @return the frontmost node, or null if list is empty
57: */
58:
59: public abstract LRUAble getHead();
60:
61: /**
62: * Obtain the backmost node, and remove it from list too.
63: * @return the backmost node, or null if list is empty
64: */
65:
66: public abstract LRUAble removeTail();
67:
68: /**
69: * Get the next node of this list.
70: * @return The next node, or <strong>null</strong> if this one was
71: * last.
72: */
73:
74: abstract public LRUAble getNext(LRUAble node);
75:
76: /**
77: * Get the previous node of this list.
78: * @return The previous node, or <strong>null</strong> if this one was
79: * last.
80: */
81:
82: abstract public LRUAble getPrev(LRUAble node);
83:
84: }
|