jopt.csp.util
Class IntIntervalSet

java.lang.Object
  extended byjopt.csp.util.IntSet
      extended byjopt.csp.util.IntIntervalSet
All Implemented Interfaces:
IntervalSet, NumSet
Direct Known Subclasses:
IntValIntervalSet

public class IntIntervalSet
extends IntSet
implements IntervalSet

A sorted set of integer intervals


Constructor Summary
IntIntervalSet()
          Creates a new set
 
Method Summary
 void add(int val)
          Adds a value to set
 void add(int start, int end)
          Adds a range of values to set
 void add(int start, int end, boolean notify)
          Adds a range of values to set
 void add(IntIntervalSet set)
          Adds a value to set
 void clear()
          Removes all values from the set
 java.lang.Object clone()
          Creates a duplicate of this set
 boolean contains(int val)
          Returns true if value is contained in set
 boolean equals(IntIntervalSet set)
          An equals method for comparing if two set objects are equivalent
 boolean equals(IntValIntervalSet set)
          An equals method for comparing if two set objects are equivalent
 int getFirstIntervalIndex()
          Returns first interval index in list
 IntIntervalSet getFreeIntervalsBetween(int start, int end)
          Returns an int interval set of all the intervals that are free between the specified start and end
 int getIntervalEnd(int idx)
          Returns end value for interval at a given index
 int getIntervalStart(int idx)
          Returns start value for interval at a given index
 int getLastIntervalIndex()
          Returns the last index in list
 IntIntervalSetListener getListener()
          Returns listener that is currently assigned to set
 int getMax()
          Returns maximum value for set
 int getMax(int intervalIdx)
          Returns the end of the interval at the specified index
 int getMin()
          Returns minimum value for set
 int getMin(int intervalIdx)
          Returns the start of the interval at the specified index
 int getNextHigher(int 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
 int getNextLower(int 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
 int indexOfValue(int val)
          Returns index of a value in the list
 void intersect(IntIntervalSet intersector)
          Removes any parts that both do not have in common from this.
 IntervalIterator intervals()
          Returns an iterator for intervals contained in set
 boolean isEmpty()
           
 boolean isIntervalContained(int start, int end)
           
 boolean isIntervalEmpty(int start, int end)
           
 void remove(int val)
          Removes a value from the set
 void remove(int start, int end)
          Removes a range of values from the set
 void remove(int start, int end, boolean notify)
          Removes a range of values from the set
 void removeEndingAt(int val)
          Removes all values below and including given value
 void removeStartingFrom(int val)
          Removes all values above and including given value
 void setListener(IntIntervalSetListener 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.IntSet
addAll, removeAll, removeEndingBefore, removeStartingAfter, retainAll
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

IntIntervalSet

public IntIntervalSet()
Creates a new set

Method Detail

size

public int size()
Returns the size of the set

Specified by:
size in interface NumSet

clear

public void clear()
Removes all values from the set

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

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


getIntervalEnd

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


getMin

public int getMin()
Returns minimum value for set

Specified by:
getMin in class IntSet

getMin

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


getMax

public int getMax()
Returns maximum value for set

Specified by:
getMax in class IntSet

getMax

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


isIntervalContained

public boolean isIntervalContained(int start,
                                   int end)

isIntervalEmpty

public boolean isIntervalEmpty(int start,
                               int end)

isEmpty

public boolean isEmpty()

getFreeIntervalsBetween

public IntIntervalSet getFreeIntervalsBetween(int start,
                                              int end)
Returns an int interval set of all the intervals that are free between the specified start and end

Parameters:
start - start of the interval
end - end of the interval
Returns:
an int interval set of all the intervals that are free between start and end

indexOfValue

public int indexOfValue(int val)
Returns index of a value in the list


contains

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

Specified by:
contains in class IntSet

add

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

Specified by:
add in class IntSet

add

public void add(IntIntervalSet set)
Adds a value to set


add

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

Specified by:
add in class IntSet

add

public void add(int start,
                int end,
                boolean notify)
Adds a range of values to set


intersect

public void intersect(IntIntervalSet intersector)
Removes any parts that both do not have in common from this.


remove

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

Specified by:
remove in class IntSet

remove

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

Specified by:
remove in class IntSet

remove

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


removeStartingFrom

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

Specified by:
removeStartingFrom in class IntSet

removeEndingAt

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

Specified by:
removeEndingAt in class IntSet

getNextHigher

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

Specified by:
getNextHigher in class IntSet

getNextLower

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

Specified by:
getNextLower in class IntSet

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 IntSet

setListener

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


getListener

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


toString

public java.lang.String toString()

equals

public boolean equals(IntIntervalSet set)
An equals method for comparing if two set objects are equivalent

Parameters:
set - IntIntervalSet to compare this to
Returns:
true if the objects are determined to be equal

equals

public boolean equals(IntValIntervalSet set)
An equals method for comparing if two set objects are equivalent

Parameters:
set - IntValIntervalSet to compare this to
Returns:
true if the objects are determined to be equal