All Packages  Class Hierarchy  This Package  Previous  Next  Index

Interface jdsl.core.api.ComparatorBased

public interface ComparatorBased
Interface to support containers that rely on an underlying ordering of the elements. Since the PriorityQueue and Dictionary interfaces are not written to force use of comparators, containers that do use them need to implement this interface, as well.

Any class implementing ComparatorBased should provide require that the class be constructed with a Comparator (for example, as a parameter to the constructor), and should not allow the class to be created without one (for example, no zero argument constructor). Any class allowing itself to be constructed without a comparator should throw an InvalidComparatorException from any method that fails because a comparator has not been set.

See Also:
InvalidComparatorException

Method Index

 o comparator()
Returns the Comparator used by this ComparatorBased container.
 o setComparator(Comparator)
This method establishes a ContainerInterfaces.Comparator that an ordered container should use to compare its elements.

Methods

 o setComparator
 public abstract Comparator setComparator(Comparator c) throws NotEmptyContainerException
This method establishes a ContainerInterfaces.Comparator that an ordered container should use to compare its elements. It must be called after a container is instantiated. It should not be called on a non-empty container.

Parameters:
c - A jdsl.core.api.Comparator appropriate to the elements stored by the container
Returns:
The old Comparator
Throws: NotEmptyContainerException
if the container has elements in it when setComparator(.) is called.
 o comparator
 public abstract Comparator comparator()
Returns the Comparator used by this ComparatorBased container.

Parameters:
c - A jdsl.core.api.Comparator appropriate to the elements stored by the container
Returns:
The old Comparator

All Packages  Class Hierarchy  This Package  Previous  Next  Index