Packagevegas.util.comparators
Classpublic class BooleanComparator
InheritanceBooleanComparator Inheritance CoreObject
ImplementsICloneable, IComparator, ICopyable

An IComparator for Boolean objects that can sort either true or false first.

Example :

  var c:IComparator = new BooleanComparator() ;
  trace(c.compare(true, true)) ; // 0
  trace(c.compare(true, false)) ; // 1
  trace(c.compare(false, true)) ; // -1
  trace(c.compare(false, false)) ; // 0
  



Public Properties
 PropertyDefined by
  trueFirst : Boolean
When true sort true boolean values before false.
BooleanComparator
Public Methods
 MethodDefined by
  
BooleanComparator(trueFirst:Boolean = true)
Creates a BooleanComparator that sorts trueFirst values before !trueFirst values.
BooleanComparator
  
clone():*
Creates and returns a shallow copy of the object.
BooleanComparator
  
compare(o1:*, o2:*):int
Returns an integer value to compare two Boolean objects.
BooleanComparator
  
copy():*
Creates and returns a deep copy of the object.
BooleanComparator
  
[static] Returns a BooleanComparator singleton that sorts false values before true values.
BooleanComparator
 Inherited
Returns the internal ILogger reference of this ILogable object.
CoreObject
  
[static] Returns a BooleanComparator singleton that sorts true values before false values.
BooleanComparator
 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
trueFirstproperty
public var trueFirst:Boolean

When true sort true boolean values before false.

Constructor detail
BooleanComparator()constructor
public function BooleanComparator(trueFirst:Boolean = true)

Creates a BooleanComparator that sorts trueFirst values before !trueFirst values. Please use the static factories instead whenever possible.

Parameters
trueFirst:Boolean (default = true) — when true, sort true boolean values before false
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 Boolean 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 the first argument is null and not a Boolean object.
     
    — when either argument is not Boolean
    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.
    getFalseFirstComparator()method 
    public static function getFalseFirstComparator():BooleanComparator

    Returns a BooleanComparator singleton that sorts false values before true values. Clients are encouraged to use the value returned from this method instead of constructing a new instance to reduce allocation and garbage collection overhead when multiple BooleanComparators may be used in the same application.

    Example :

       var c:IComparator = BooleanComparator.getFalseFirstComparator() ;
       trace(c.compare(true, true)) ; // 0
       trace(c.compare(true, false)) ; // -1
       trace(c.compare(false, true)) ; // 1
       trace(c.compare(false, false)) ; // 0
        

    Returns
    BooleanComparator — a BooleanComparator instance that sorts false values before true values.
    getTrueFirstComparator()method 
    public static function getTrueFirstComparator():BooleanComparator

    Returns a BooleanComparator singleton that sorts true values before false values. Clients are encouraged to use the value returned from this method instead of constructing a new instance to reduce allocation and garbage collection overhead when multiple BooleanComparators may be used in the same application.

       var c:IComparator = BooleanComparator.getTrueFirstComparator() ;
       trace(c.compare(true, true)) ; // 0
       trace(c.compare(true, false)) ; // 1
       trace(c.compare(false, true)) ; // -1
       trace(c.compare(false, false)) ; // 0
        

    Returns
    BooleanComparator — a BooleanComparator instance that sorts true values before false values.