All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.stjs.javascript.SortFunction Maven / Gradle / Ivy

/**
 *  Copyright 2011 Alexandru Craciun, Eyal Kaspi
 *
 *  Licensed under the Apache License, Version 2.0 (the "License");
 *  you may not use this file except in compliance with the License.
 *  You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 *  Unless required by applicable law or agreed to in writing, software
 *  distributed under the License is distributed on an "AS IS" BASIS,
 *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *  See the License for the specific language governing permissions and
 *  limitations under the License.
 */
package org.stjs.javascript;

import org.stjs.javascript.annotation.JavascriptFunction;
import org.stjs.javascript.annotation.Template;

@JavascriptFunction
public interface SortFunction {
	 
	/**
	 * Compares its two arguments for order. Returns a negative integer, zero, or a positive 
	 * integer as the first argument is less than, equal to, or greater than the second.
	 * 
	 * 

The notation: *

    *
  • a <CF b means comparefn(a,b) < 0 *
  • a =CF b means comparefn(a,b) = 0 (of either sign) *
  • a >CF b means comparefn(a,b) > 0 *
* *

A function comparefn is a consistent comparison function for a set of values * S if all of the requirements below are met for all values a, * b, and c (possibly the same value) in the set S: * *

    *
  • Calling comparefn(a,b) always returns the same value v when given a * specific pair of values a and b as its two arguments. Furthermore, * Type(v) is Number, and v is not NaN. Note that this * implies that exactly one of a <CF b, a =CF b, * and a >CF b will be true for a given pair of a and b. *
  • Calling comparefn(a,b) does not modify the this object *
  • a =CF a (reflexivity) *
  • If a =CF b, then b =CF a (symmetry) *
  • If a =CF b and b =CF c, then a =CF * c (transitivity of =CF) *
  • If a <CF b and b <CF c, then a * <CF c (transitivity of <CF) *
  • If a >CF b and b >CF c, then a >CF * c (transitivity of >CF) *
* * @param a the first object to be compared * @param b the second object to be compared * @return a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second. */ @Template("invoke") public int $invoke(V a, V b); }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy