KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > soot > util > Chain


1 /* Soot - a J*va Optimization Framework
2  * Copyright (C) 1999 Patrice Pominville
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the
16  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17  * Boston, MA 02111-1307, USA.
18  */

19
20 /*
21  * Modified by the Sable Research Group and others 1997-1999.
22  * See the 'credits' file distributed with Soot for the complete list of
23  * contributors. (Soot is distributed at http://www.sable.mcgill.ca/soot)
24  */

25
26
27 package soot.util;
28
29 import java.util.*;
30 import soot.*;
31 import java.io.*;
32
33 /** Augmented data type guaranteeing O(1) insertion and removal from a set
34  * of ordered, unique elements. */

35 public interface Chain extends Collection, Serializable
36 {
37     /** Inserts <code>toInsert</code> in the Chain before <code>point</code>. */
38     public void insertBefore(List toInsert, Object JavaDoc point);
39     /** Inserts <code>toInsert</code> in the Chain after <code>point</code>. */
40     public void insertAfter(List toInsert, Object JavaDoc point);
41     /** Inserts <code>toInsert</code> in the Chain after <code>point</code>. */
42     public void insertAfter(Object JavaDoc toInsert, Object JavaDoc point);
43     /** Inserts <code>toInsert</code> in the Chain before <code>point</code>. */
44     public void insertBefore(Object JavaDoc toInsert, Object JavaDoc point);
45     /** Inserts <code>toInsert</code> in the Chain before <code>point</code>.
46      * (It would probably be better to make Chain implement List)*/

47     public void insertBefore(Chain toInsert, Object JavaDoc point);
48     /** Inserts <code>toInsert</code> in the Chain after <code>point</code>.
49      * (It would probably be better to make Chain implement List)*/

50     public void insertAfter(Chain toInsert, Object JavaDoc point);
51
52     
53     /** Replaces <code>out</code> in the Chain by <code>in</code>. */
54     public void swapWith(Object JavaDoc out, Object JavaDoc in);
55
56     /** Removes the given object from this Chain. */
57     public boolean remove(Object JavaDoc u);
58
59     /** Adds the given object at the beginning of the Chain. */
60     public void addFirst(Object JavaDoc u);
61
62     /** Adds the given object at the end of the Chain. */
63     public void addLast(Object JavaDoc u);
64
65     /** Removes the first object contained in this Chain. */
66     public void removeFirst();
67     /** Removes the last object contained in this Chain. */
68     public void removeLast();
69
70     /** Returns true if object <code>someObject</code> follows object <code>someReferenceObject</code> in the Chain. */
71     public boolean follows(Object JavaDoc someObject, Object JavaDoc someReferenceObject);
72
73     /** Returns the first object in this Chain. */
74     public Object JavaDoc getFirst();
75
76     /** Returns the last object in this Chain. */
77     public Object JavaDoc getLast();
78     
79     /** Returns the object immediately following <code>point</code>. */
80     public Object JavaDoc getSuccOf(Object JavaDoc point);
81
82     /** Returns the object immediately preceding <code>point</code>. */
83     public Object JavaDoc getPredOf(Object JavaDoc point);
84
85     /** Returns an iterator over a copy of this chain.
86      * This avoids ConcurrentModificationExceptions from being thrown
87      * if the underlying Chain is modified during iteration.
88      * Do not use this to remove elements which have not yet been
89      * iterated over! */

90     public Iterator snapshotIterator();
91
92     /** Returns an iterator over this Chain. */
93     public Iterator iterator();
94
95     /** Returns an iterator over this Chain, starting at the given object. */
96     public Iterator iterator(Object JavaDoc u);
97
98     /** Returns an iterator over this Chain, starting at head and reaching tail (inclusive). */
99     public Iterator iterator(Object JavaDoc head, Object JavaDoc tail);
100
101     /** Returns the size of this Chain. */
102     public int size();
103 }
104
105
Popular Tags