jopt.csp.util
Class FloatIntervalSet

java.lang.Object
  extended byjopt.csp.util.FloatSet
      extended byjopt.csp.util.FloatIntervalSet
All Implemented Interfaces:
IntervalSet, NumSet

public class FloatIntervalSet
extends FloatSet
implements IntervalSet

A sorted set of float intervals


Constructor Summary
FloatIntervalSet()
          Creates a new set
 
Method Summary
 void add(float val)
          Adds a value to set
 void add(float start, float 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(float val)
          Returns true if value is contained in set
 int getFirstIntervalIndex()
          Returns first interval index in list
 float getIntervalEnd(int idx)
          Returns end value for interval at a given index
 float getIntervalStart(int idx)
          Returns start value for interval at a given index
 int getLastIntervalIndex()
          Returns the last index in list
 FloatIntervalSetListener getListener()
          Returns listener that is currently assigned to set
 float getMax()
          Returns maximum value for set.
 float getMax(int intervalIdx)
          Returns the end of the interval at the specified index
 float getMin()
          Returns minimum value for set.
 float getMin(int intervalIdx)
          Returns the start of the interval at the specified index
 float getNextHigher(float 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
 float getNextLower(float 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(float val)
          Removes a value from the set
 void remove(float start, float end)
          Removes a range of values from the set
 void removeEndingAt(float val)
          Removes all values below and including given value
 void removeEndingBefore(float val)
          Removes all values below given value
 void removeStartingAfter(float val)
          Removes all values above and including given value
 void removeStartingFrom(float val)
          Removes all values above and including given value
 void setListener(FloatIntervalSetListener 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.FloatSet
addAll, removeAll, retainAll
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FloatIntervalSet

public FloatIntervalSet()
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 FloatSet

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 float getIntervalStart(int idx)
Returns start value for interval at a given index


getIntervalEnd

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


getMin

public float getMin()
Returns minimum value for set.

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

getMin

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


getMax

public float getMax()
Returns maximum value for set.

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

getMax

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


contains

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

Specified by:
contains in class FloatSet

add

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

Specified by:
add in class FloatSet

add

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

Specified by:
add in class FloatSet

remove

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

Specified by:
remove in class FloatSet

remove

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

Specified by:
remove in class FloatSet

removeStartingAfter

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

Specified by:
removeStartingAfter in class FloatSet

removeEndingBefore

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

Specified by:
removeEndingBefore in class FloatSet

removeStartingFrom

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

Specified by:
removeStartingFrom in class FloatSet

removeEndingAt

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

Specified by:
removeEndingAt in class FloatSet

getNextHigher

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

Specified by:
getNextHigher in class FloatSet

getNextLower

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

Specified by:
getNextLower in class FloatSet

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 FloatSet

setListener

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


getListener

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


toString

public java.lang.String toString()