jopt.csp.util
Class DoubleIntervalSet

java.lang.Object
  extended byjopt.csp.util.DoubleSet
      extended byjopt.csp.util.DoubleIntervalSet
All Implemented Interfaces:
IntervalSet, NumSet

public class DoubleIntervalSet
extends DoubleSet
implements IntervalSet

A sorted set of double intervals


Constructor Summary
DoubleIntervalSet()
          Creates a new set
 
Method Summary
 void add(double val)
          Adds a value to set
 void add(double start, double end)
          Adds a range of values to set
 void clear()
          Removes all values from the set
 java.lang.Object clone()
          Creates a duplicate of this set
 boolean contains(double val)
          Returns true if value is contained in set
 int getFirstIntervalIndex()
          Returns first interval index in list
 double getIntervalEnd(int idx)
          Returns end value for interval at a given index
 double getIntervalStart(int idx)
          Returns start value for interval at a given index
 int getLastIntervalIndex()
          Returns the last index in list
 DoubleIntervalSetListener getListener()
          Returns listener that is currently assigned to set
 double getMax()
          Returns maximum value for set.
 double getMax(int intervalIdx)
          Returns the end of the interval at the specified index
 double getMin()
          Returns minimum value for set.
 double getMin(int intervalIdx)
          Returns the start of the interval at the specified index
 double getNextHigher(double val)
          Returns the next higher value in the domain or current value if none exists
 int getNextIntervalIndex(int idx)
          Returns next interval index in list
 double getNextLower(double val)
          Returns the next lower value in the domain or current value if none exists
 int getPreviousIntervalIndex(int idx)
          Returns previous interval index in list
 IntervalIterator intervals()
          Returns an iterator for intervals contained in set
 void remove(double val)
          Removes a value from the set
 void remove(double start, double end)
          Removes a range of values from the set
 void removeEndingAt(double val)
          Removes all values below and including given value
 void removeEndingBefore(double val)
          Removes all values below given value
 void removeStartingAfter(double val)
          Removes all values above and including given value
 void removeStartingFrom(double val)
          Removes all values above and including given value
 void setListener(DoubleIntervalSetListener listener, int callback)
          Sets listener for set to be notified of changes
 int size()
          Returns the size of the set.
 java.lang.String toString()
           
 NumberIterator values()
          Returns an iterator containing all values in the set
 
Methods inherited from class jopt.csp.util.DoubleSet
addAll, removeAll, retainAll
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

DoubleIntervalSet

public DoubleIntervalSet()
Creates a new set

Method Detail

size

public int size()
Returns the size of the set.

Specified by:
size in interface NumSet
Returns:
As currently implemented, the size gives only 0, 1, or MAX_VALUE. This means that for three single-value intervals (three sparse values), while you might expect it to return 3, it instead returns MAX_VALUE.

clear

public void clear()
Removes all values from the set

Specified by:
clear in interface NumSet
Specified by:
clear in class DoubleSet

getFirstIntervalIndex

public int getFirstIntervalIndex()
Returns first interval index in list


getLastIntervalIndex

public int getLastIntervalIndex()
Returns the last index in list


getNextIntervalIndex

public int getNextIntervalIndex(int idx)
Returns next interval index in list

Parameters:
idx - Index previous to index that is to be found

getPreviousIntervalIndex

public int getPreviousIntervalIndex(int idx)
Returns previous interval index in list

Parameters:
idx - Index following index that is to be found

getIntervalStart

public double getIntervalStart(int idx)
Returns start value for interval at a given index


getIntervalEnd

public double getIntervalEnd(int idx)
Returns end value for interval at a given index


getMin

public double getMin()
Returns minimum value for set.

Specified by:
getMin in class DoubleSet
Returns:
Returns the minimum value for the set. If the set is empty, returns positive infinity.

getMin

public double getMin(int intervalIdx)
Returns the start of the interval at the specified index


getMax

public double getMax()
Returns maximum value for set.

Specified by:
getMax in class DoubleSet
Returns:
Returns the maximum value for the set. If the set is empty, returns negative infinity.

getMax

public double getMax(int intervalIdx)
Returns the end of the interval at the specified index


contains

public boolean contains(double val)
Returns true if value is contained in set

Specified by:
contains in class DoubleSet

add

public void add(double val)
Adds a value to set

Specified by:
add in class DoubleSet

add

public void add(double start,
                double end)
Adds a range of values to set

Specified by:
add in class DoubleSet

remove

public void remove(double val)
Removes a value from the set

Specified by:
remove in class DoubleSet

remove

public void remove(double start,
                   double end)
Removes a range of values from the set

Specified by:
remove in class DoubleSet

removeStartingAfter

public final void removeStartingAfter(double val)
Removes all values above and including given value

Specified by:
removeStartingAfter in class DoubleSet

removeEndingBefore

public final void removeEndingBefore(double val)
Removes all values below given value

Specified by:
removeEndingBefore in class DoubleSet

removeStartingFrom

public void removeStartingFrom(double val)
Removes all values above and including given value

Specified by:
removeStartingFrom in class DoubleSet

removeEndingAt

public void removeEndingAt(double val)
Removes all values below and including given value

Specified by:
removeEndingAt in class DoubleSet

getNextHigher

public double getNextHigher(double val)
Returns the next higher value in the domain or current value if none exists

Specified by:
getNextHigher in class DoubleSet

getNextLower

public double getNextLower(double val)
Returns the next lower value in the domain or current value if none exists

Specified by:
getNextLower in class DoubleSet

intervals

public IntervalIterator intervals()
Description copied from interface: IntervalSet
Returns an iterator for intervals contained in set

Specified by:
intervals in interface IntervalSet

values

public NumberIterator values()
Description copied from interface: NumSet
Returns an iterator containing all values in the set

Specified by:
values in interface NumSet

clone

public java.lang.Object clone()
Creates a duplicate of this set

Specified by:
clone in interface NumSet
Specified by:
clone in class DoubleSet

setListener

public void setListener(DoubleIntervalSetListener listener,
                        int callback)
Sets listener for set to be notified of changes


getListener

public DoubleIntervalSetListener getListener()
Returns listener that is currently assigned to set


toString

public java.lang.String toString()