| Package | vegas.util.comparators |
| Class | public class NullComparator |
| Inheritance | NullComparator CoreObject |
| Implements | ICloneable, IComparator, ICopyable |
Example :
import vegas.util.comparators.NullComparator;
var comp1:NullComparator = new NullComparator(null, true) ;
var comp2:NullComparator = new NullComparator(null, false) ;
var n = null ;
var o = {} ;
trace( comp1.compare(n, n) ) ; // 0
trace( comp1.compare(n, o) ) ; // 1
trace( comp1.compare(o, n) ) ; // -1
trace("----") ;
trace( comp2.compare(n, n) ) ; // 0
trace( comp2.compare(n, o) ) ; // -1
trace( comp2.compare(o, n) ) ; // 1
| Property | Defined by | ||
|---|---|---|---|
| nonNullComparator : IComparator = null
Defines the comparator to use when comparing two non-null objects.
| NullComparator | ||
| nullsAreHigh : Boolean = false
Defines that null should be compared as higher than a non-null object.
| NullComparator | ||
| Method | Defined by | ||
|---|---|---|---|
|
NullComparator(nonNullComparator:IComparator = null, nullsAreHigh:Boolean = false)
Creates a new NullComparator instance.
| NullComparator | ||
|
clone():*
Creates and returns a shallow copy of the object.
| NullComparator | ||
|
compare(o1:*, o2:*):int
Perform a comparison between two objects.
| NullComparator | ||
|
copy():*
Creates and returns a deep copy of the object.
| NullComparator | ||
|
[static]
Returns the singleton instance of a ReverseComparator.
| NullComparator | ||
![]() |
Returns the internal
ILogger reference of this ILogable object. | CoreObject | |
![]() |
hashCode():uint
Returns a hashcode value for the object.
| CoreObject | |
![]() |
Sets the internal
ILogger reference of this ILogable object. | CoreObject | |
![]() |
toSource(indent:int = 0):String
Returns the string representation the source code of the object.
| CoreObject | |
![]() |
toString():String
Returns the string representation of this instance.
| CoreObject | |
| nonNullComparator | property |
public var nonNullComparator:IComparator = nullDefines the comparator to use when comparing two non-null objects.
| nullsAreHigh | property |
public var nullsAreHigh:Boolean = falseDefines that null should be compared as higher than a non-null object.
| NullComparator | () | constructor |
public function NullComparator(nonNullComparator:IComparator = null, nullsAreHigh:Boolean = false)Creates a new NullComparator instance.
ParametersnonNullComparator:IComparator (default = null) — the comparator to use when comparing two non-null objects.
|
|
nullsAreHigh:Boolean (default = false) — a true value indicates that null should be compared as higher than a non-null object. A false value indicates that null should be compared as lower than a non-null object.
|
| 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:*):intPerform a comparison between two objects. If both objects are null, a 0 value is returned. If one object is null and the other is not, the result is determined on whether the Comparator was constructed to have nulls as higher or lower than other objects. If neither object is null, an underlying comparator specified in the constructor (or the default) is used to compare the non-null objects. The default IComparator used to compare two non-null objects is the ComparableComparator.
Parameterso1:* — the first 'null' object to compare.
|
|
o2:* — the second 'null' object to compare.
|
int —
|
See also
| 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():NullComparatorReturns 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.
ReturnsNullComparator —
the singleton instance of a ReverseComparator.
|