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
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
11 package net.sourceforge.phpdt.internal.core;
13 import java.util.Enumeration;
16 * The <code>LRUCacheEnumerator</code> returns its elements in
17 * the order they are found in the <code>LRUCache</code>, with the
18 * most recent elements first.
20 * Once the enumerator is created, elements which are later added
21 * to the cache are not returned by the enumerator. However,
22 * elements returned from the enumerator could have been closed
25 public class LRUCacheEnumerator implements Enumeration {
29 protected LRUEnumeratorElement fElementQueue;
31 public static class LRUEnumeratorElement {
33 * Value returned by <code>nextElement()</code>;
40 public LRUEnumeratorElement fNext;
45 public LRUEnumeratorElement(Object value) {
50 * Creates a CacheEnumerator on the list of <code>LRUEnumeratorElements</code>.
52 public LRUCacheEnumerator(LRUEnumeratorElement firstElement) {
53 fElementQueue = firstElement;
56 * Returns true if more elements exist.
58 public boolean hasMoreElements() {
59 return fElementQueue != null;
62 * Returns the next element.
64 public Object nextElement() {
65 Object temp = fElementQueue.fValue;
66 fElementQueue = fElementQueue.fNext;