001    package jigcell.compare.data;
002    
003    import java.util.Collection;
004    import java.util.Comparator;
005    import java.util.List;
006    import java.util.ListIterator;
007    import jigcell.compare.IDataGenerator;
008    
009    /**
010     * Manages a list of data generators.
011     *
012     * <p>
013     * This code is licensed under the DARPA BioCOMP Open Source License.  See LICENSE for more details.
014     * </p>
015     *
016     * @author Nicholas Allen
017     */
018    
019    public interface IDataGeneratorList extends IDataGeneratorCollection {
020    
021       /**
022        * Adds a generator at the specified index.
023        *
024        * @param index Index
025        * @param generator Generator
026        */
027    
028       void add (int index, IDataGenerator generator);
029    
030       /**
031        * Adds a generator.
032        *
033        * @param generator Generator
034        */
035    
036       void add (IDataGenerator generator);
037    
038       /**
039        * Adds all the generators in a collection.
040        *
041        * @param collection Collection
042        */
043    
044       void addAll (Collection collection);
045    
046       /**
047        * Adds all the generators in a collection.
048        *
049        * @param generatorList Collection
050        */
051    
052       void addAll (IDataGeneratorList generatorList);
053    
054       /**
055        * This list of generators as an untyped list.
056        */
057    
058       List asList ();
059    
060       /**
061        * Removes all generators from this list.
062        */
063    
064       void clear ();
065    
066       /**
067        * Creates an index of generator ids and names to speed up searches.  Building this index is expensive and should only be done if many
068        * searches are going to be made in this list.  The index does not track changes to generator ids or names once it is built.
069        *
070        * @see #flushIndex()
071        */
072    
073       void createIndex ();
074    
075       /**
076        * Erases the index of generator ids and names.  This method does nothing if this index does not exist.
077        *
078        * @see #createIndex()
079        */
080    
081       void flushIndex ();
082    
083       /**
084        * A generator in the list.
085        *
086        * @param index Index
087        */
088    
089       IDataGenerator get (int index);
090    
091       /**
092        * A generator in the list.  The id is the primary search key.  This operation will be significantly accelerated if an index exists.
093        *
094        * @param key Key
095        */
096    
097       IDataGenerator get (Key key);
098    
099       /**
100        * A generator in the list by name.  This operation will be significantly accelerated if an index exists.
101        *
102        * @param name Name
103        */
104    
105       IDataGenerator get (String name);
106    
107       /**
108        * The position of a generator in the list.
109        *
110        * @param generator Generator
111        */
112    
113       int indexOf (IDataGenerator generator);
114    
115       /**
116        * Whether this list is empty.
117        */
118    
119       boolean isEmpty ();
120    
121       /**
122        * An iterator over the generators in the list.
123        */
124    
125       ListIterator iterator ();
126    
127       /**
128        * An iterator over the generators in the list starting at a particular index.
129        *
130        * @param index Index
131        */
132    
133       ListIterator iterator (int index);
134    
135       /**
136        * Removes a generator from this list.
137        *
138        * @param index Index
139        */
140    
141       IDataGenerator remove (int index);
142    
143       /**
144        * Sets a generator in this list to a new value.
145        *
146        * @param index Index
147        * @param generator Generator
148        */
149    
150       IDataGenerator set (int index, IDataGenerator generator);
151    
152       /**
153        * The number of generators in this list.
154        */
155    
156       int size ();
157    
158       /**
159        * Sorts this list according to a specified criterion.
160        *
161        * @param comparator Sorting criterion
162        */
163    
164       void sort (Comparator comparator);
165    
166       /**
167        * This list of generators as an array.
168        */
169    
170       IDataGenerator [] toArray ();
171    }