001    /*
002     *  This file is part of the Jikes RVM project (http://jikesrvm.org).
003     *
004     *  This file is licensed to You under the Eclipse Public License (EPL);
005     *  You may not use this file except in compliance with the License. You
006     *  may obtain a copy of the License at
007     *
008     *      http://www.opensource.org/licenses/eclipse-1.0.php
009     *
010     *  See the COPYRIGHT.txt file distributed with this work for information
011     *  regarding copyright ownership.
012     */
013    package org.jikesrvm.compilers.opt.util;
014    
015    import java.util.Enumeration;
016    
017    
018    /**
019     * List of Graph nodes.
020     * <p>
021     * TODO should a doubly linked list implement Enumeration?
022     */
023    class SpaceEffGraphNodeList implements Enumeration<SpaceEffGraphNodeList> {
024      SpaceEffGraphNode _node;
025      SpaceEffGraphNodeList _next;
026      SpaceEffGraphNodeList _prev;
027    
028      SpaceEffGraphNodeList() {
029        _node = null;
030        _next = null;
031        _prev = null;
032      }
033    
034      @Override
035      public boolean hasMoreElements() {
036        return _next != null;
037      }
038    
039      // return the next GraphNodeList element.
040      @Override
041      public SpaceEffGraphNodeList nextElement() {
042        SpaceEffGraphNodeList tmp = _next;
043        _next = _next._next;
044        return tmp;
045      }
046    
047      SpaceEffGraphNode node() {
048        return _node;
049      }
050    
051      SpaceEffGraphNodeList next() {
052        return _next;
053      }
054    
055      SpaceEffGraphNodeList prev() {
056        return _prev;
057      }
058    }