Packagesystem.comparators
Classpublic class CharComparator
InheritanceCharComparator Inheritance Object
Implements Comparator

This comparator compare characters (String with one character) objects.

Example :

     import system.comparators.CharComparator ;
     
     var c:CharComparator = new CharComparator() ;
     
     trace( c.compare( "A" , "A" ) ) ; // 0
     trace( c.compare( "A" , "a" ) ) ; // 1
     trace( c.compare( "A" , "b" ) ) ; // 1
     
     trace("--") ;
     
     trace( c.compare( "a" , "A" ) ) ; // -1
     trace( c.compare( "a" , "a" ) ) ; //  0
     trace( c.compare( "a" , "b" ) ) ; // -1
     trace( c.compare( "a" , "B" ) ) ; // -1
     
     trace("--") ;
     
     trace( c.compare( "b" , "A" ) ) ; // -1
     trace( c.compare( "b" , "a" ) ) ; //  1
     trace( c.compare( "b" , "b" ) ) ; //  0
     trace( c.compare( "b" , "B" ) ) ; // -1
     
     trace("--") ;
     
     trace( c.compare( "B" , "a" ) ) ; // 1
     trace( c.compare( "B" , "b" ) ) ; // 1
     trace( c.compare( "B" , "B" ) ) ; // 0
     



Public Methods
 MethodDefined By
  
Creates a new CharComparator instance.
CharComparator
  
caseValue(str:String):uint
[static] Returns 0 if the passed string is lower case else 1.
CharComparator
  
compare(o1:*, o2:*, options:* = null):int
Returns an integer value to compare two String characters objects.
CharComparator
Constructor Detail
CharComparator()Constructor
public function CharComparator()

Creates a new CharComparator instance.

Method Detail
caseValue()method
public static function caseValue(str:String):uint

Returns 0 if the passed string is lower case else 1.

Parameters

str:String

Returns
uint — 0 if the passed string is lower case else 1.
compare()method 
public function compare(o1:*, o2:*, options:* = null):int

Returns an integer value to compare two String characters objects.

Parameters

o1:* — the first character object to compare.
 
o2:* — the second character object to compare.
 
options:* (default = null) — Not implemented.

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.