kodkod.util.ints
Class AbstractIntVector

java.lang.Object
  extended by kodkod.util.ints.AbstractIntCollection
      extended by kodkod.util.ints.AbstractIntVector
All Implemented Interfaces:
IntCollection, IntVector
Direct Known Subclasses:
ArrayIntVector

public abstract class AbstractIntVector
extends AbstractIntCollection
implements IntVector

A skeletal implementation of the IntVector interface.

Author:
Emina Torlak
specfield:
length: int
elements: [0..size) ->one int

Method Summary
 boolean add(int element)
          Calls this.add(this.size(), element)
 void add(int index, int element)
          Throws UnsupportedOperationException
 boolean addAll(IntCollection c)
          Returns the result of calling this.addAll(size(), c).
 boolean addAll(int index, IntCollection c)
          Throws an UnsupportedOperationException.
 boolean contains(int element)
          Iterates through this.ints and returns true if it finds i, otherwise returns false.
 boolean equals(java.lang.Object o)
          Compares the specified object with this vector for equality.
 int hashCode()
          Returns the hash code value for this vector.
 int indexOf(int element)
          Returns the index in this vector of the first occurrence of the specified element, or -1 if this vector does not contain this element.
 IntIterator iterator()
          Calls this.iterator(0, length())
 IntIterator iterator(int fromIndex, int toIndex)
          Returns an iterator over the elements in this vector in proper sequence, starting fromIndex<\tt>, inclusive, and ending at toIndex<\tt>, exclusive.
 int lastIndexOf(int element)
          Returns the index in this vector of the last occurrence of the specified element, or -1 if this vector does not contain this element.
 int removeAt(int index)
          Throws an UnsupportedOperationException.
 int set(int index, int element)
          Throws UnsupportedOperationException.
 java.lang.String toString()
          
 
Methods inherited from class kodkod.util.ints.AbstractIntCollection
clear, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface kodkod.util.ints.IntVector
clear, get, isEmpty, remove, removeAll, retainAll, size, toArray, toArray
 
Methods inherited from interface kodkod.util.ints.IntCollection
containsAll
 

Method Detail

contains

public boolean contains(int element)
Iterates through this.ints and returns true if it finds i, otherwise returns false.

Specified by:
contains in interface IntCollection
Specified by:
contains in interface IntVector
Overrides:
contains in class AbstractIntCollection
Returns:
true if i is in this collection, otherwise returns false.
See Also:
IntVector.contains(int)

set

public int set(int index,
               int element)
Throws UnsupportedOperationException.

Specified by:
set in interface IntVector
Returns:
this.elements[index]
See Also:
IntVector.set(int,int)

indexOf

public int indexOf(int element)
Returns the index in this vector of the first occurrence of the specified element, or -1 if this vector does not contain this element.

Specified by:
indexOf in interface IntVector
Returns:
element in this.elements[int] => min(this.elements.element), -1
See Also:
IntVector.indexOf(int)

lastIndexOf

public int lastIndexOf(int element)
Returns the index in this vector of the last occurrence of the specified element, or -1 if this vector does not contain this element.

Specified by:
lastIndexOf in interface IntVector
Returns:
element in this.elements[int] => max(this.elements.element), -1
See Also:
IntVector.lastIndexOf(int)

add

public boolean add(int element)
Calls this.add(this.size(), element)

Specified by:
add in interface IntCollection
Specified by:
add in interface IntVector
Overrides:
add in class AbstractIntCollection
Returns:
true if this collection has changed as a result of the call
See Also:
IntVector.add(int), IntVector.add(int,int)

add

public void add(int index,
                int element)
Throws UnsupportedOperationException

Specified by:
add in interface IntVector
See Also:
IntVector.add(int, int)

addAll

public boolean addAll(IntCollection c)
Returns the result of calling this.addAll(size(), c).

Specified by:
addAll in interface IntCollection
Specified by:
addAll in interface IntVector
Overrides:
addAll in class AbstractIntCollection
Returns:
this.addAll(size(), c)
See Also:
AbstractIntCollection.addAll(kodkod.util.ints.IntCollection)

addAll

public boolean addAll(int index,
                      IntCollection c)
Throws an UnsupportedOperationException.

Specified by:
addAll in interface IntVector
Returns:
this.elements != this.elements
See Also:
IntVector.addAll(int, kodkod.util.ints.IntCollection)

removeAt

public int removeAt(int index)
Throws an UnsupportedOperationException.

Specified by:
removeAt in interface IntVector
Returns:
this.elements[index]
See Also:
IntVector.removeAt(int)

iterator

public IntIterator iterator()
Calls this.iterator(0, length())

Specified by:
iterator in interface IntCollection
Specified by:
iterator in interface IntVector
Returns:
an iterator over the elements in this collection
See Also:
IntVector.iterator(), IntVector.iterator(int,int)

iterator

public IntIterator iterator(int fromIndex,
                            int toIndex)
Returns an iterator over the elements in this vector in proper sequence, starting fromIndex<\tt>, inclusive, and ending at toIndex<\tt>, exclusive. If fromIndex<\tt> is less than toIndex<\tt>, then the iterator will return the elements in the descending order.

Specified by:
iterator in interface IntVector
Returns:
an iterator over the elements in this vector in proper sequence, starting at fromIndex<\tt>, inclusive, and ending at toIndex<\tt>.
See Also:
IntVector.iterator(int, int)

hashCode

public int hashCode()
Returns the hash code value for this vector.

Specified by:
hashCode in interface IntVector
Overrides:
hashCode in class java.lang.Object
Returns:
the hash code value for this vector.
See Also:
Object.hashCode(), Object.equals(Object), equals(Object)

equals

public boolean equals(java.lang.Object o)
Compares the specified object with this vector for equality. Returns true if and only if the specified object is also an int vector, both vectors have the same size, and all corresponding pairs of elements in the two vectors are equal.

Specified by:
equals in interface IntVector
Overrides:
equals in class java.lang.Object
Returns:
true if the specified object is equal to this vector.

toString

public java.lang.String toString()

Overrides:
toString in class java.lang.Object
See Also:
Object.toString()