Packagevegas.util.comparators
Classpublic class NumberComparator
InheritanceNumberComparator Inheritance CoreObject
ImplementsICloneable, IComparator, ICopyable

This comparator compare two Number objects.

Example :

  import vegas.util.comparators.NumberComparator ;
  
  var c:NumberComparator = new NumberComparator() ;
   
   trace( c.compare(0,0) ) ; // 0
  trace( c.compare(1,1) ) ; // 0
  trace( c.compare(-1,-1) ) ; // 0
  trace( c.compare(0.1,0.1) ) ; // 0
  trace( c.compare( Number(Math.cos(25)) , 0.9912028118634736 ) ) ; // 0
  trace( c.compare(1, 0) ) ; // 1
  trace( c.compare(0, 1) ) ; // -1
  



Public Methods
 MethodDefined by
  
Creates a new NumberComparator instance.
NumberComparator
  
clone():*
Creates and returns a shallow copy of the object.
NumberComparator
  
compare(o1:*, o2:*):int
Returns an integer value to compare two Number objects.
NumberComparator
  
copy():*
Creates and returns a deep copy of the object.
NumberComparator
  
[static] Returns the singleton instance of a NumberComparator.
NumberComparator
 Inherited
Returns the internal ILogger reference of this ILogable object.
CoreObject
 Inherited
hashCode():uint
Returns a hashcode value for the object.
CoreObject
 Inherited
setLogger(log:ILogger = null):void
Sets the internal ILogger reference of this ILogable object.
CoreObject
 Inherited
toSource(indent:int = 0):String
Returns the string representation the source code of the object.
CoreObject
 Inherited
toString():String
Returns the string representation of this instance.
CoreObject
Constructor detail
NumberComparator()constructor
public function NumberComparator()

Creates a new NumberComparator instance.

Method detail
clone()method
public function clone():*

Creates and returns a shallow copy of the object.

Returns
* — A new object that is a shallow copy of this instance.
compare()method 
public function compare(o1:*, o2:*):int

Returns an integer value to compare two Number objects.

Parameters
o1:* — the first Number object to compare.
 
o2:* — the second Number object to compare.

Returns
int

  • -1 if o1 is "lower" than (less than, before, etc.) o2 ;
  • 1 if o1 is "higher" than (greater than, after, etc.) o2 ;
  • 0 if o1 and o2 are equal.

  • Throws
    — if compare(a, b) and 'a' and 'b' must be Number objects.
    copy()method 
    public function copy():*

    Creates and returns a deep copy of the object.

    Returns
    * — A new object that is a deep copy of this instance.
    getInstance()method 
    public static function getInstance():NumberComparator

    Returns the singleton instance of a NumberComparator. Developers are encouraged to use the comparator returned from this method instead of constructing a new instance to reduce allocation and GC overhead when multiple comparable comparators may be used in the same application.

    Returns
    NumberComparator — the singleton instance of a NumberComparator.