kodkod.util.ints
Class IntRange

java.lang.Object
  extended by kodkod.util.ints.IntRange

public abstract class IntRange
extends java.lang.Object

Represents a range of integers, [min..max].

Author:
Emina Torlak
invariant:
min <= max
specfield:
min: int
max: int

Method Summary
 boolean contains(int i)
          Returns true if the given integer is within this range; otherwise returns false.
 boolean contains(IntRange range)
          Returns true if this range contains the given range.
 boolean equals(java.lang.Object o)
          Returns true if o is an int range with the same endpoints as this.
 int hashCode()
          Returns the hash code for this int range.
 boolean intersects(IntRange range)
          Returns true if this and the given range intersect.
abstract  int max()
          Returns the right endpoint of this range.
abstract  int min()
          Returns the left endpoint of this range.
 int size()
          Returns the number of element in this range.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Method Detail

min

public abstract int min()
Returns the left endpoint of this range.

Returns:
this.min

max

public abstract int max()
Returns the right endpoint of this range.

Returns:
this.max

size

public int size()
Returns the number of element in this range.

Returns:
this.max - this.min + 1

contains

public boolean contains(int i)
Returns true if the given integer is within this range; otherwise returns false.

Returns:
i in [min..max]

contains

public boolean contains(IntRange range)
Returns true if this range contains the given range.

Returns:
this.min <= range.min <= range.max <= this.max
Throws:
java.lang.NullPointerException - - range = null

intersects

public boolean intersects(IntRange range)
Returns true if this and the given range intersect.

Returns:
some i: int | this.contains(i) && range.contains(i)
Throws:
java.lang.NullPointerException - - range = null

equals

public boolean equals(java.lang.Object o)
Returns true if o is an int range with the same endpoints as this.

Overrides:
equals in class java.lang.Object
Returns:
o in IntRange && o.min==this.min && o.max==this.max

hashCode

public int hashCode()
Returns the hash code for this int range. The implementation is guaranteed to obey the Object contract.

Overrides:
hashCode in class java.lang.Object
Returns:
the hashcode for this intrange

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object