Refactory: remove unused classes, imports, fields and methods.
[phpeclipse.git] / net.sourceforge.phpeclipse / src / net / sourceforge / phpdt / internal / core / LRUCacheEnumerator.java
1 /*******************************************************************************
2  * Copyright (c) 2000, 2003 IBM Corporation and others.
3  * All rights reserved. This program and the accompanying materials 
4  * are made available under the terms of the Common Public License v1.0
5  * which accompanies this distribution, and is available at
6  * http://www.eclipse.org/legal/cpl-v10.html
7  * 
8  * Contributors:
9  *     IBM Corporation - initial API and implementation
10  *******************************************************************************/
11 package net.sourceforge.phpdt.internal.core;
12
13 import java.util.Enumeration;
14
15 /**
16  * The <code>LRUCacheEnumerator</code> returns its elements in the order they
17  * are found in the <code>LRUCache</code>, with the most recent elements
18  * first.
19  * 
20  * Once the enumerator is created, elements which are later added to the cache
21  * are not returned by the enumerator. However, elements returned from the
22  * enumerator could have been closed by the cache.
23  */
24 public class LRUCacheEnumerator implements Enumeration {
25         /**
26          * Current element;
27          */
28         protected LRUEnumeratorElement fElementQueue;
29
30         public static class LRUEnumeratorElement {
31                 /**
32                  * Value returned by <code>nextElement()</code>;
33                  */
34                 public Object fValue;
35
36                 /**
37                  * Next element
38                  */
39                 public LRUEnumeratorElement fNext;
40
41                 /**
42                  * Constructor
43                  */
44                 public LRUEnumeratorElement(Object value) {
45                         fValue = value;
46                 }
47         }
48
49         /**
50          * Creates a CacheEnumerator on the list of
51          * <code>LRUEnumeratorElements</code>.
52          */
53         public LRUCacheEnumerator(LRUEnumeratorElement firstElement) {
54                 fElementQueue = firstElement;
55         }
56
57         /**
58          * Returns true if more elements exist.
59          */
60         public boolean hasMoreElements() {
61                 return fElementQueue != null;
62         }
63
64         /**
65          * Returns the next element.
66          */
67         public Object nextElement() {
68                 Object temp = fElementQueue.fValue;
69                 fElementQueue = fElementQueue.fNext;
70                 return temp;
71         }
72 }