View Javadoc

1   /*
2    * EL4J, the Extension Library for the J2EE, adds incremental enhancements to
3    * the spring framework, http://el4j.sf.net
4    * Copyright (C) 2006 by ELCA Informatique SA, Av. de la Harpe 22-24,
5    * 1000 Lausanne, Switzerland, http://www.elca.ch
6    *
7    * EL4J is published under the GNU Lesser General Public License (LGPL)
8    * Version 2.1. See http://www.gnu.org/licenses/
9    *
10   * This program is distributed in the hope that it will be useful,
11   * but WITHOUT ANY WARRANTY; without even the implied warranty of
12   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13   * GNU Lesser General Public License for more details.
14   *
15   * For alternative licensing, please contact info@elca.ch
16   */
17  package ch.elca.el4j.util.collections;
18  
19  import java.util.NoSuchElementException;
20  import java.util.RandomAccess;
21  
22  /**
23   * An extended interface, random access list permitting element reordering, but
24   * not neccessarily inserting/removing elements.
25   *
26   * @param <T> the member type.
27   *
28   *
29   * @svnLink $Revision: 3875 $;$Date: 2009-08-04 14:35:53 +0200 (Di, 04. Aug 2009) $;$Author: swismer $;$URL: https://el4j.svn.sourceforge.net/svnroot/el4j/branches/el4j_3_1/el4j/framework/modules/core/src/main/java/ch/elca/el4j/util/collections/ExtendedReorderableList.java $
30   *
31   * @author Adrian Moos (AMS)
32   */
33  public interface ExtendedReorderableList<T> extends ExtendedList<T>,
34  	RandomAccess {
35  	
36  	/** exchanges the elements located at indices {@code i} and {@code j}.
37  	 * @param i ...
38  	 * @param j ...
39  	 */
40  	public void swap(int i, int j);
41  	
42  	/**
43  	 * Reorders this list's elements by example. This method makes sure that
44  	 * the result will start with the sublist {@code example} as far as
45  	 * element equality is concerned, or throws
46  	 * a {@code NoSuchElementException} if this is not possible.
47  	 * In either case, the order of the remaining elements may be affected.
48  	 * This method may require quadratic time.
49  	 *
50  	 * <p>Formally, if this method completes normally, the condition
51  	 * &forall; {@code  i < example.size();
52  	 *   c.apply(this.get(i)).equals(example.get(i))}
53  	 *  is true.
54  	 * @param example a list whose elements are in the descired order
55  	 * @throws NoSuchElementException if the example's order can not be
56  	 *                                duplicated by reordering alone.
57  	 **/
58  	public void orderLike(java.util.List<? extends T> example)
59  		throws NoSuchElementException;
60  }