Packagevegas.util.comparators
Classpublic class ReverseComparator
InheritanceReverseComparator Inheritance CoreObject
ImplementsICloneable, IComparator, ICopyable

Reverse an IComparator object. For example if the comparator must return 1 the reverse comparator return -1.

Example :

  import vegas.util.comparators.ReverseComparator ;
  import vegas.util.comparators.StringComparator ;
  
  var c:StringComparator = new StringComparator() ;
  var s:ReverseComparator = new ReverseComparator( c ) ;
  
  trace( c.compare( "hello", "world" ) ) ; // -1
  trace( s.compare( "hello", "world" ) ) ; // 1
  



Public Properties
 PropertyDefined by
  comparator : IComparator
The IComparator instance to reverse.
ReverseComparator
Public Methods
 MethodDefined by
  
Creates a new ReverseComparator instance.
ReverseComparator
  
clone():*
Creates and returns a shallow copy of the object.
ReverseComparator
  
compare(o1:*, o2:*):int
Returns an integer value to compare two objects (reverse the value).
ReverseComparator
  
copy():*
Creates and returns a deep copy of the object.
ReverseComparator
  
[static] Returns the singleton instance of a ReverseComparator.
ReverseComparator
 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
Property detail
comparatorproperty
public var comparator:IComparator

The IComparator instance to reverse.

Constructor detail
ReverseComparator()constructor
public function ReverseComparator(comp:IComparator = null)

Creates a new ReverseComparator instance.

Parameters
comp:IComparator (default = null) — the IComparator to be reverse.
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 objects (reverse the value).

Parameters
o1:* — the first object to compare.
 
o2:* — the second 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.
  • 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():ReverseComparator

    Returns the singleton instance of a ReverseComparator. 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
    ReverseComparator — the singleton instance of a ReverseComparator.