Coverage Report - org.as3coreaddendum.system.ISortable
 
Classes in this File Line Coverage Branch Coverage Complexity
ISortable
0%
0/1
N/A
0
 
 1  
 /*
 2  
  * Licensed under the MIT License
 3  
  * 
 4  
  * Copyright 2010 (c) Flávio Silva, http://flsilva.com
 5  
  *
 6  
  * Permission is hereby granted, free of charge, to any person
 7  
  * obtaining a copy of this software and associated documentation
 8  
  * files (the "Software"), to deal in the Software without
 9  
  * restriction, including without limitation the rights to use,
 10  
  * copy, modify, merge, publish, distribute, sublicense, and/or sell
 11  
  * copies of the Software, and to permit persons to whom the
 12  
  * Software is furnished to do so, subject to the following
 13  
  * conditions:
 14  
  *
 15  
  * The above copyright notice and this permission notice shall be
 16  
  * included in all copies or substantial portions of the Software.
 17  
  *
 18  
  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
 19  
  * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
 20  
  * OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
 21  
  * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
 22  
  * HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
 23  
  * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 24  
  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
 25  
  * OTHER DEALINGS IN THE SOFTWARE.
 26  
  * 
 27  
  * http://www.opensource.org/licenses/mit-license.php
 28  
  */
 29  
 
 30  0
 package org.as3coreaddendum.system
 31  
 {
 32  
         import org.as3coreaddendum.system.IComparator;
 33  
 
 34  
         /**
 35  
          * A class that implements this interface indicates that it can be sorted by the <code>sort()</code> method.
 36  
          * <p>Usually the classes that implement this interface are collections of some sort.</p>
 37  
          * 
 38  
          * @author Flávio Silva
 39  
          */
 40  
         public interface ISortable
 41  
         {
 42  
                 /**
 43  
                  * Defines the <code>IComparator</code> object to be used in the comparison.
 44  
                  */
 45  
                 function get comparator(): IComparator;
 46  
 
 47  
                 function set comparator(value:IComparator): void;
 48  
 
 49  
                 /**
 50  
                  * Defines the options to be used automatically to sort.
 51  
                  */
 52  
                 function get options(): uint;
 53  
 
 54  
                 function set options(value:uint): void;
 55  
 
 56  
                 /**
 57  
                  * Sorts the objects within this class.
 58  
                  * <p>By default, <code>Array.sort()</code> works in the following way:</p>
 59  
                  * <p>
 60  
                  * <ul>
 61  
                  * <li>Sorting is case-sensitive (Z precedes a).</li>
 62  
                  * <li>Sorting is ascending (a precedes b).</li>
 63  
                  * <li>The array is modified to reflect the sort order; multiple elements that have identical sort fields are placed consecutively in the sorted array in no particular order.</li>
 64  
                  * <li>All elements, regardless of data type, are sorted as if they were strings, so 100 precedes 99, because "1" is a lower string value than "9".</li>
 65  
                  * </ul>
 66  
                  * </p>
 67  
                  * 
 68  
                  * @param                  compare         A comparison function used to determine the sorting order of elements in an array. For more info see <code>IComparator.compare</code>.
 69  
                  * @param                  options         One or more numbers or defined constants, separated by the | (bitwise OR) operator, that change the behavior of the sort from the default.
 70  
                  * The following values are acceptable for <code>options</code>:
 71  
                  * <ul>
 72  
                  * <li>1 or Array.CASEINSENSITIVE</li>
 73  
                  * <li>2 or Array.DESCENDING</li>
 74  
                  * <li>4 or Array.UNIQUESORT</li>
 75  
                  * <li>8 or Array.RETURNINDEXEDARRAY</li>
 76  
                  * <li>16 or Array.NUMERIC</li>
 77  
                  * </ul>
 78  
                  * @return                 The return value depends on whether you pass any arguments, as described in the following list:
 79  
                  * <ul>
 80  
                  * <li>If you specify a value of 4 or Array.UNIQUESORT for the <code>options</code> argument and two or more elements being sorted have identical sort fields, returns a value of 0 and does not modify the array.</li>
 81  
                  * <li>If you specify a value of 8 or Array.RETURNINDEXEDARRAY for the options parameter, an array is returned that reflects the results of the sort and the array is not modified.</li>
 82  
                  * <li>Otherwise, nothing is returned and the array is modified to reflect the sort order.</li>
 83  
                  * </ul>
 84  
                  * @see                 IComparator#compare() IComparator.compare()
 85  
                  */
 86  
                 function sort(compare:Function = null, options:uint = 0): Array;
 87  
         }
 88  
 
 89  
 }