Show / Hide Table of Contents

Class ChainedComparer

Composite comparer implementation based on a collection of comparers.

Inheritance
object
ChainedComparer
Implements
IQueryCacheComparer
IEntryAwareComparer
IComparer
IPortableObject
Inherited Members
object.Equals(object, object)
object.GetType()
object.MemberwiseClone()
object.ReferenceEquals(object, object)
Namespace: Tangosol.Util.Comparator
Assembly: Coherence.dll
Syntax
public class ChainedComparer : IQueryCacheComparer, IEntryAwareComparer, IComparer, IPortableObject
Remarks

The comparers in the array assumed to be sorted according to their priorities; only in a case when the n-th comparer cannot determine the order of the passed objects:

comparers[n].Compare(o1, o2) == 0

the (n+1)-th comparer will be applied to calculate the value.

Constructors

ChainedComparer()

Default constructor.

Declaration
public ChainedComparer()

ChainedComparer(IComparer[])

Construct a ChainedComparer.

Declaration
public ChainedComparer(IComparer[] comparers)
Parameters
Type Name Description
IComparer[] comparers

The comparer array.

Fields

m_comparers

The IComparer array.

Declaration
protected IComparer[] m_comparers
Field Value
Type Description
IComparer[]

Properties

Comparers

Obtain the underlying IComparer array.

Declaration
public virtual IComparer[] Comparers { get; }
Property Value
Type Description
IComparer[]

The IComparer array.

Methods

Compare(object, object)

Compares its two arguments for order.

Declaration
public virtual int Compare(object o1, object o2)
Parameters
Type Name Description
object o1

The first object to be compared.

object o2

The second object to be compared.

Returns
Type Description
int

A negative integer, zero, or a positive integer as the first argument is less than, equal to, or greater than the second.

CompareEntries(IQueryCacheEntry, IQueryCacheEntry)

Compare two entries based on the rules specified by IComparer.

Declaration
public virtual int CompareEntries(IQueryCacheEntry entry1, IQueryCacheEntry entry2)
Parameters
Type Name Description
IQueryCacheEntry entry1

The first entry to compare values from; read-only.

IQueryCacheEntry entry2

The second entry to compare values from; read-only.

Returns
Type Description
int

A negative integer, zero, or a positive integer as the first entry denotes a value that is is less than, equal to, or greater than the value denoted by the second entry.

Remarks

This implementation simply passes on this invocation to the wrapped IComparer objects if they too implement this interface, or invokes their default Compare method passing the values extracted from the passed entries.

Equals(object)

Determine if two ChainedComparer objects are equal.

Declaration
public override bool Equals(object o)
Parameters
Type Name Description
object o

The other comparator.

Returns
Type Description
bool

true if the passed object is equal to this ChainedComparator.

Overrides
object.Equals(object)

GetHashCode()

Return the hash code for this comparator.

Declaration
public override int GetHashCode()
Returns
Type Description
int

The hash code value for this comparator.

Overrides
object.GetHashCode()

IsKeyComparer()

Specifies whether this comparer expects to compare keys or values.

Declaration
public bool IsKeyComparer()
Returns
Type Description
bool

true iff all the underlying compares implement the IEntryAwareComparer interface and all

IsKeyComparator()
calls return true.

ReadExternal(IPofReader)

Restore the contents of a user type instance by reading its state using the specified IPofReader object.

Declaration
public virtual void ReadExternal(IPofReader reader)
Parameters
Type Name Description
IPofReader reader

The IPofReader from which to read the object's state.

Exceptions
Type Condition
IOException

If an I/O error occurs.

ToString()

Returns a human-readable description for this ChainedComparer.

Declaration
public override string ToString()
Returns
Type Description
string

A string description of the ChainedComparer.

Overrides
object.ToString()

WriteExternal(IPofWriter)

Save the contents of a POF user type instance by writing its state using the specified IPofWriter object.

Declaration
public virtual void WriteExternal(IPofWriter writer)
Parameters
Type Name Description
IPofWriter writer

The IPofWriter to which to write the object's state.

Exceptions
Type Condition
IOException

If an I/O error occurs.

Implements

IQueryCacheComparer
IEntryAwareComparer
IComparer
IPortableObject
In this article
Back to top Copyright © 2000, 2024, Oracle and/or its affiliates.