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 the order they
17 * are found in the <code>LRUCache</code>, with the most recent elements
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.
24 public class LRUCacheEnumerator implements Enumeration {
28 protected LRUEnumeratorElement fElementQueue;
30 public static class LRUEnumeratorElement {
32 * Value returned by <code>nextElement()</code>;
39 public LRUEnumeratorElement fNext;
44 public LRUEnumeratorElement(Object value) {
50 * Creates a CacheEnumerator on the list of
51 * <code>LRUEnumeratorElements</code>.
53 public LRUCacheEnumerator(LRUEnumeratorElement firstElement) {
54 fElementQueue = firstElement;
58 * Returns true if more elements exist.
60 public boolean hasMoreElements() {
61 return fElementQueue != null;
65 * Returns the next element.
67 public Object nextElement() {
68 Object temp = fElementQueue.fValue;
69 fElementQueue = fElementQueue.fNext;