001    /*--------------------------------------------------------------------------+
002    $Id: ISortableData.java 28499 2010-06-22 09:38:45Z deissenb $
003    |                                                                          |
004    | Copyright 2005-2010 Technische Universitaet Muenchen                     |
005    |                                                                          |
006    | Licensed under the Apache License, Version 2.0 (the "License");          |
007    | you may not use this file except in compliance with the License.         |
008    | You may obtain a copy of the License at                                  |
009    |                                                                          |
010    |    http://www.apache.org/licenses/LICENSE-2.0                            |
011    |                                                                          |
012    | Unless required by applicable law or agreed to in writing, software      |
013    | distributed under the License is distributed on an "AS IS" BASIS,        |
014    | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
015    | See the License for the specific language governing permissions and      |
016    | limitations under the License.                                           |
017    +--------------------------------------------------------------------------*/
018    package edu.tum.cs.commons.collections;
019    
020    /**
021     * Abstraction for sortable/comparable data. Implementations of this interface
022     * can be used with {@link SortableDataUtils} to supports basic algorithms, such
023     * as sorting and binary search on any data which can be mapped to a random
024     * access list. The main benefit of this interface is that the type of data is
025     * operated on must not be known (or be a concrete type), thus it can also be
026     * used to sort data spread over multiple lists or arrays.
027     * 
028     * @author hummelb
029     * @author $Author: deissenb $
030     * @version $Rev: 28499 $
031     * @levd.rating GREEN Hash: 8FEEC55647374909933C02DCDA3F8DE8
032     */
033    public interface ISortableData {
034    
035            /** Returns the number of elements. */
036            int size();
037    
038            /**
039             * Returns whether the element stored at index <code>i</code> is smaller
040             * than the one stored at <code>j</code>.
041             */
042            boolean isLess(int i, int j);
043    
044            /** Swaps the elements at the given indices. */
045            void swap(int i, int j);
046    }