001: /* Soot - a J*va Optimization Framework
002: * Copyright (C) 1999 Patrice Pominville
003: *
004: * This library is free software; you can redistribute it and/or
005: * modify it under the terms of the GNU Lesser General Public
006: * License as published by the Free Software Foundation; either
007: * version 2.1 of the License, or (at your option) any later version.
008: *
009: * This library is distributed in the hope that it will be useful,
010: * but WITHOUT ANY WARRANTY; without even the implied warranty of
011: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
012: * Lesser General Public License for more details.
013: *
014: * You should have received a copy of the GNU Lesser General Public
015: * License along with this library; if not, write to the
016: * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
017: * Boston, MA 02111-1307, USA.
018: */
019:
020: /*
021: * Modified by the Sable Research Group and others 1997-1999.
022: * See the 'credits' file distributed with Soot for the complete list of
023: * contributors. (Soot is distributed at http://www.sable.mcgill.ca/soot)
024: */
025:
026: package soot.util;
027:
028: import java.io.Serializable;
029: import java.util.Collection;
030: import java.util.Iterator;
031: import java.util.List;
032:
033: /** Augmented data type guaranteeing O(1) insertion and removal from a set
034: * of ordered, unique elements.
035: * @param <E> element type */
036: public interface Chain<E> extends Collection<E>, Serializable {
037: /** Inserts <code>toInsert</code> in the Chain before <code>point</code>. */
038: public void insertBefore(List<E> toInsert, E point);
039:
040: /** Inserts <code>toInsert</code> in the Chain after <code>point</code>. */
041: public void insertAfter(List<E> toInsert, E point);
042:
043: /** Inserts <code>toInsert</code> in the Chain after <code>point</code>. */
044: public void insertAfter(E toInsert, E point);
045:
046: /** Inserts <code>toInsert</code> in the Chain before <code>point</code>. */
047: public void insertBefore(E toInsert, E point);
048:
049: /** Inserts <code>toInsert</code> in the Chain before <code>point</code>.
050: * (It would probably be better to make Chain implement List)*/
051: public void insertBefore(Chain<E> toInsert, E point);
052:
053: /** Inserts <code>toInsert</code> in the Chain after <code>point</code>.
054: * (It would probably be better to make Chain implement List)*/
055: public void insertAfter(Chain<E> toInsert, E point);
056:
057: /** Replaces <code>out</code> in the Chain by <code>in</code>. */
058: public void swapWith(E out, E in);
059:
060: /** Removes the given object from this Chain. */
061: public boolean remove(E u);
062:
063: /** Adds the given object at the beginning of the Chain. */
064: public void addFirst(E u);
065:
066: /** Adds the given object at the end of the Chain. */
067: public void addLast(E u);
068:
069: /** Removes the first object contained in this Chain. */
070: public void removeFirst();
071:
072: /** Removes the last object contained in this Chain. */
073: public void removeLast();
074:
075: /** Returns true if object <code>someObject</code> follows object <code>someReferenceObject</code> in the Chain. */
076: public boolean follows(E someObject, E someReferenceObject);
077:
078: /** Returns the first object in this Chain. */
079: public E getFirst();
080:
081: /** Returns the last object in this Chain. */
082: public E getLast();
083:
084: /** Returns the object immediately following <code>point</code>. */
085: public E getSuccOf(E point);
086:
087: /** Returns the object immediately preceding <code>point</code>. */
088: public E getPredOf(E point);
089:
090: /** Returns an iterator over a copy of this chain.
091: * This avoids ConcurrentModificationExceptions from being thrown
092: * if the underlying Chain is modified during iteration.
093: * Do not use this to remove elements which have not yet been
094: * iterated over! */
095: public Iterator<E> snapshotIterator();
096:
097: /** Returns an iterator over this Chain. */
098: public Iterator<E> iterator();
099:
100: /** Returns an iterator over this Chain, starting at the given object. */
101: public Iterator<E> iterator(E u);
102:
103: /** Returns an iterator over this Chain, starting at head and reaching tail (inclusive). */
104: public Iterator<E> iterator(E head, E tail);
105:
106: /** Returns the size of this Chain. */
107: public int size();
108: }
|