SSJ  3.3.1
Stochastic Simulation in Java
Public Member Functions | List of all members
MultiDimComparable< T > Interface Template Reference

This interface is an extension (or variant) of the Comparable interface in Java. More...

Inheritance diagram for MultiDimComparable< T >:
[legend]

Public Member Functions

int getStateDimension ()
 This method returns the number \(d\) of coordinates for which the method compareTo can be invoked for this object. More...
 
int compareTo (T other, int j)
 Similar to compareTo in the class Comparable, except that one specifies the index \(j\) of the criterion on which the objects are to be compared. More...
 

Detailed Description

This interface is an extension (or variant) of the Comparable interface in Java.

In the Comparable interface, the objects can be compared in only one way, so there is a single total ordering between the objects. Here, there is a choice of \(d\) different ways (or criteria, or coordinates) to compare the objects. These coordinates are indexed by \(j = 0,…,d-1\). The coordinate \(j\) that is to used by the comparison must be specified as the second argument in the method compareTo(other, j). This interface must be implemented in particular by objects that are to be sorted via a MultiDimSortComparable.

The objects that are compared may really have a multidimensional behavior, or they may not. For example, an object that contains an array can implement this interface by defining compareTo(other, j) so that it compares the elements of index j in the arrays from the two objects. As another example, if an object represents a person and contains some information on that person, the method compareTo may compare two persons based on the age, or height, er weight, etc., and \(j\) specifies which one. It can also be used to compare in different ways, like comparing the birth date including the birth year to know who is younger or comparing the birth date without the year to know who has his next birthday first.

For details on how to use these comparisons in algorithms that require an ordinary Java Comparator, such as the sort methods in class Arrays, see MultiDimComparator.

Member Function Documentation

◆ compareTo()

int compareTo ( other,
int  j 
)

Similar to compareTo in the class Comparable, except that one specifies the index \(j\) of the criterion on which the objects are to be compared.

It compares objects of type T based on coordinate \(j\). The method must return a negative integer, zero, or a positive integer depending on whether the current object is less than, equal to, or greater than o, based on coordinate \(j\). If \(j\) is outside the range \(\{0,…,d-1\}\), this method should throw an IllegalArgumentException.

◆ getStateDimension()

int getStateDimension ( )

This method returns the number \(d\) of coordinates for which the method compareTo can be invoked for this object.

That is, compareTo (other, j) can be called only for \(\mathtt{j}=0,…,\mathtt{dimension()-1}\).

Implemented in MarkovChainDouble, and MarkovChainComparable.


The documentation for this interface was generated from the following file: