Packagevegas.util.comparators
Classpublic class GenericComparator
InheritanceGenericComparator Inheritance CoreObject
ImplementsIComparator

This comparator compare two Objects by field.

Example :

   
   import vegas.events.Delegate ;
   import vegas.util.comparators.GenericComparator ;
   import vegas.util.comparators.StringComparator ; 
   
   var write:Function = function( ar:Array ):void
   {
       var result:Array = [] ;
       var size:uint = ar.length ;
       for (var i:uint = 0 ; i
   



Public Properties
 PropertyDefined by
  comparator : IComparator
The IComparator used by this IComparator to compare two objects with this specified field.
GenericComparator
  sortBy : String
A String who represents a property name to compare the two objects.
GenericComparator
Public Methods
 MethodDefined by
  
GenericComparator(sortBy:String, comparator:IComparator)
Creates a new GenericComparator instance.
GenericComparator
  
clone():*
Creates and returns a shallow copy of the object.
GenericComparator
  
compare(o1:*, o2:*):int
Returns an integer value to compare two objects.
GenericComparator
 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 used by this IComparator to compare two objects with this specified field.

sortByproperty 
public var sortBy:String

A String who represents a property name to compare the two objects.

Constructor detail
GenericComparator()constructor
public function GenericComparator(sortBy:String, comparator:IComparator)

Creates a new GenericComparator instance.

Parameters
sortBy:String — A String who represents a property name to compare the two objects.
 
comparator:IComparator — An IComparator use to compare the two objects with the specified property names.

Throws
— If the 'sortBy' argument is 'null' or 'undefined'.
 
— If the 'comparator' argument is 'null' or 'undefined'.
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.

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