Namespace calitha.collections
Version 1.1.
Defined in: _base.js.
Constructor Attributes | Constructor Name and Description |
---|---|
The collections namespace consists of static methods that supports the use of the collections framework.
|
Method Attributes | Method Name and Description |
---|---|
<static> |
calitha.collections.caseInsenstiveStringComparator()
returns a comparator to compare string in a case insensitive way (only objects of type string).
|
<static> |
calitha.collections.makeNumberHashCompatible(number)
Makes a number with integer value compatible with hash-based collections.
|
<static> |
calitha.collections.makeStringHashCompatible(str)
Makes a string compativle with hash-based collections.
|
<static> |
calitha.collections.numberComparator()
returns a comparator to compare numbers.
|
<static> |
calitha.collections.objectAsCaseInsensitiveStringComparator()
returns a comparator to compare case insensitive any object by getting its string representation.
|
<static> |
calitha.collections.objectAsStringComparator()
returns a comparator to compare any object by getting its string representation.
|
<static> |
calitha.collections.reverseNaturalOrder()
Returns a comparator that imposes the reverse of the natural ordering on a collection of objects that
implement the IComparable interface.
|
<static> |
calitha.collections.reverseOrder(cmp)
Returns a comparator that imposes reverse ordering.
|
<static> |
calitha.collections.sort(list, comparator)
Sorts a list by using the comparator object/function.
|
<static> |
calitha.collections.stringComparator()
returns a comparator to compare string (only objects of type string).
|
Namespace Detail
calitha.collections
The collections namespace consists of static methods that supports the use of the collections framework.
The methods operate or return collections or comparators. Probably the most important methods are those
that make integer-based numbers and strings compatible as keys in hash-based collections.
Method Detail
returns a comparator to compare string in a case insensitive way (only objects of type string).
The comparator can be used for tree-based collections.
- Returns:
- {calitha.collections.IComparator} comparator
<static>
calitha.collections.makeNumberHashCompatible(number)
Makes a number with integer value compatible with hash-based collections. This is done by
extending the object to include an equals and hashCode value. You can pass the Number.prototype to make all existing
and new numbers compatible.
- Parameters:
- {Number} number
- number to make compatible
<static>
calitha.collections.makeStringHashCompatible(str)
Makes a string compativle with hash-based collections. This is done by extending the object to
include an equals and hashCode value. You can pass String.prototype to make all existing and new strings compatible.
- Parameters:
- {String} str
- string to make compatible
returns a comparator to compare numbers. The comparator can be used for tree-based collections.
- Returns:
- {calitha.collections.IComparator} comparator
<static>
{calitha.collections.IComparator}
calitha.collections.objectAsCaseInsensitiveStringComparator()
returns a comparator to compare case insensitive any object by getting its string representation.
The comparator can be used for tree-based collections.
- Returns:
- {calitha.collections.IComparator} comparator
returns a comparator to compare any object by getting its string representation.
The comparator can be used for tree-based collections.
- Returns:
- {calitha.collections.IComparator} comparator
<static>
calitha.collections.reverseNaturalOrder()
Returns a comparator that imposes the reverse of the natural ordering on a collection of objects that
implement the IComparable interface.
- Returns:
- a comparator that imposes the reverse of the natural ordering
Returns a comparator that imposes reverse ordering. If a comparator is used, then the ordering
is reversed on that comparator. Otherwise the elements must be IComparable and the natural ordering is reversed.
- Parameters:
- {calitha.collections.IComparator?} cmp
- comparator optional comparator
- Returns:
- {calitha.collections.IComparator} comparator with reverse ordering
<static>
calitha.collections.sort(list, comparator)
Sorts a list by using the comparator object/function. Or if the comparator is not specified, it uses
the natural ordering which means the elements must be IComparable objects.
- Parameters:
- {calitha.collections.IList} list
- list
- {(calitha.collections.IComparator|Function)?} comparator
- optional comparator
returns a comparator to compare string (only objects of type string).
The comparator can be used for tree-based collections.
- Returns:
- {calitha.collections.IComparator} comparator