Algorithm
Development Kit 1.0

algs.model.gametree
Interface IComparator

All Superinterfaces:
java.util.Comparator<java.lang.Integer>

public interface IComparator
extends java.util.Comparator<java.lang.Integer>

Defines a comparator function for scores on a gameTree board.

Provides default implementations of MIN and MAX.

Since:
1.0
Version:
1.0, 6/15/08
Author:
George Heineman

Field Summary
static IComparator MAX
          MAX comparator takes highest score.
static IComparator MIN
          MIN comparator takes lowest score.
 
Method Summary
 int initialValue()
          Defines the initial value to use when iterating over a set of scores (using the comparator).
 IComparator opposite()
          Return opposite comparator.
 
Methods inherited from interface java.util.Comparator
compare, equals
 

Field Detail

MAX

static final IComparator MAX
MAX comparator takes highest score. If a new GameState is compared against a non-existing one (that is, m1 == null), then the new MoveEvaluation is selected.


MIN

static final IComparator MIN
MIN comparator takes lowest score. If a new GameState is compared against a non-existing one (that is, m1 == null), then the new MoveEvaluation is selected.

Method Detail

initialValue

int initialValue()
Defines the initial value to use when iterating over a set of scores (using the comparator).

For example, for MAX the initial value is to be Integer.MIN_VALUE.


opposite

IComparator opposite()
Return opposite comparator.

Designed to be used with MIN and MAX.


Algorithm Development Kit 1.0

This code supports the Algorithms in a Nutshell book, published by O'Reilly Media, Inc. in November 2008. Please visit the book web page to learn of any changes to the code repository or to record a potential defect.