#include <coherence/util/comparator/SafeComparator.hpp>
Inherits Object, Comparator, QueryMapComparator, EntryAwareComparator, and PortableObject.
Inherited by EntryComparator, and InverseComparator.
NULL values are evaluated as "less then" any non-null value. If the wrapped comparator is not specified then all non-null values must implement the coherence::util::Comparable interface. Use SafeComparator::getInstance to obtain an instance of non-delegating SafeComparator.
Public Types | ||||
| typedef spec::Handle | Handle | |||
| SafeComparator Handle definition. | ||||
| typedef spec::View | View | |||
| SafeComparator View definition. | ||||
| typedef spec::Holder | Holder | |||
| SafeComparator Holder definition. | ||||
Public Member Functions | ||||
| virtual int32_t | compare (Object::View vO1, Object::View vO2) const | |||
| Compares its two arguments for order. | ||||
| virtual int32_t | compareEntries (QueryMap::Entry::View vEntry1, QueryMap::Entry::View vEntry2) const | |||
| Compare two entries using the underlying comparator. | ||||
| virtual bool | isKeyComparator () const | |||
| Specifies whether this comparator expects to compare keys or values.
| ||||
| virtual void | readExternal (PofReader::Handle hIn) | |||
| virtual void | writeExternal (PofWriter::Handle hOut) const | |||
| virtual bool | equals (Object::View v) const | |||
| virtual size32_t | hashCode () const | |||
| Return a hash code value for the Object. This method is supported for the benefit of hash-based containers.
The general contract of
The default implementation is identity based.
| ||||
| virtual void | toStream (std::ostream &out) const | |||
| Output a human-readable description of this Object to the given stream. coherence::lang::operator<<(std::ostream, Object::View) is defined and will call into the toStream method, to output Objects. If a managed String object is desired, the COH_TO_STRING macro can be used to build up a String from streamable contents.
Object::View vKey = ... Object::View vValue = ... std::cout << vKey << " = " << vValue << std::endl; String::Handle hs = COH_TO_STRING(vKey << " = " << vValue);
| ||||
| virtual Comparator::View | getComparator () const | |||
| Obtain the wrapped Comparator. | ||||
Static Public Member Functions | ||||
| static bool | isKeyComparator (Comparator::View vComparator) | |||
| Check whether the specified comparator expects to compare keys or values. | ||||
| static int32_t | compareSafe (Comparator::View vComparator, Object::View vO1, Object::View vO2) | |||
| Compares its two arguments for order. | ||||
|
static SafeComparator::Handle | getInstance () | |||
| An instance of the SafeComparator. | ||||
Protected Member Functions | ||||
| SafeComparator () | ||||
| Default constructor (necessary for the PortableObject interface). | ||||
| SafeComparator (Comparator::View vComparator) | ||||
| Construct a SafeComparator delegating to the specified (wrapped) comparator. | ||||
Protected Attributes | ||||
| FinalView< Comparator > | f_vComparator | |||
| The wrapped Comparator. | ||||
| SafeComparator | ( | Comparator::View | vComparator | ) | [protected] |
Construct a SafeComparator delegating to the specified (wrapped) comparator.
| vComparator | Comparator object to delegate comparison of non-null values (optional) |
| virtual int32_t compare | ( | Object::View | vO1, | |
| Object::View | vO2 | |||
| ) | const [virtual] |
Compares its two arguments for order.
Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second. Null values are evaluated as "less then" any non-null value. If the wrapped comparator is not specified, all non-null values must implement the Comparable interface.
| vO1 | the first object to be compared | |
| vO2 | the second object to be compared |
| ClassCastException | if the arguments' types prevent them from being compared by this Comparator. |
Implements Comparator.
Reimplemented in EntryComparator, and InverseComparator.
| virtual int32_t compareEntries | ( | QueryMap::Entry::View | vEntry1, | |
| QueryMap::Entry::View | vEntry2 | |||
| ) | const [virtual] |
Compare two entries using the underlying comparator.
If the wrapped comparator does not implement the QueryMapComparator interface, revert to the entry values comparison.
Implements QueryMapComparator.
Reimplemented in InverseComparator.
| static bool isKeyComparator | ( | Comparator::View | vComparator | ) | [static] |
Check whether the specified comparator expects to compare keys or values.
| vComparator | a Comparator to check |
| virtual Comparator::View getComparator | ( | ) | const [virtual] |
| static int32_t compareSafe | ( | Comparator::View | vComparator, | |
| Object::View | vO1, | |||
| Object::View | vO2 | |||
| ) | [static] |
Compares its two arguments for order.
Returns a negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second. Null values are evaluated as "less then" any non-null value. Non-null values must implement the coherence::util::Comparable interface.
| vComparator | a comparator to use for the comparison (optional) | |
| vO1 | the first object to be compared | |
| vO2 | the second object to be compared |
| ClassCastException | if the arguments are not Comparable |
FinalView<Comparator> f_vComparator [protected] |
The wrapped Comparator.
Could be null.