kodkod.util.ints
Interface IntCollection

All Known Subinterfaces:
IntSet, IntVector
All Known Implementing Classes:
AbstractIntCollection, AbstractIntSet, AbstractIntVector, ArrayIntSet, ArrayIntVector, IntBitSet, IntTreeSet

public interface IntCollection

The root interface in the int collection hierarchy. A collection represents a group of integers, known as its elements. Some collections allow duplicate elements and others do not. Some are ordered and others unordered. Some allow all integers and others only integers in a certain range.

Author:
Emina Torlak

Method Summary
 boolean add(int i)
          Ensures that this collection contains the given integer, and returns true if this collection has changed as a result of the call.
 boolean addAll(IntCollection c)
          Adds all of the elements in the specified collection to this collection.
 void clear()
          Removes all elements from this collection.
 boolean contains(int i)
          Returns true if i is an element in this collection.
 boolean containsAll(IntCollection c)
          Returns true if this collection contains all of the elements in the specified collection.
 boolean isEmpty()
          Returns true if this collection has no elements; otherwise returns false.
 IntIterator iterator()
          Returns an iterator over the elements in this collection.
 boolean remove(int i)
          Removes a single instance of the given integer from this collection, and returns true if this collection has changed as a result of the call.
 boolean removeAll(IntCollection c)
          Removes all of this collection's elements that are also contained in the specified collection.
 boolean retainAll(IntCollection c)
          Retains only the elements in this collection that are contained in the specified collection.
 int size()
          Returns the number of elements in this collection.
 int[] toArray()
          Returns an array containing all of the elements in this collection.
 int[] toArray(int[] array)
          Copies the elements of this collection into the specified array, provided that it is large enough, and returns it.
 

Method Detail

size

int size()
Returns the number of elements in this collection.

Returns:
number of elements in this collection.

isEmpty

boolean isEmpty()
Returns true if this collection has no elements; otherwise returns false.

Returns:
true if this collection has no elements, false otherwise.

iterator

IntIterator iterator()
Returns an iterator over the elements in this collection. There are no guarantees concerning the order in which the elements are returned (unless this collection is an instance of some class that provides a guarantee).

Returns:
an iterator over the elements in this collection

contains

boolean contains(int i)
Returns true if i is an element in this collection.

Returns:
true if i is an element in this collection.

add

boolean add(int i)
Ensures that this collection contains the given integer, and returns true if this collection has changed as a result of the call.

Returns:
true if this collection has changed as a result of the call
Throws:
java.lang.UnsupportedOperationException - - this is an unmodifiable collection
java.lang.IllegalArgumentException - - some aspect of the element prevents it from being added to this collection.

remove

boolean remove(int i)
Removes a single instance of the given integer from this collection, and returns true if this collection has changed as a result of the call.

Returns:
true if this collection has changed as a result of the call
Throws:
java.lang.UnsupportedOperationException - - this is an unmodifiable collection

containsAll

boolean containsAll(IntCollection c)
Returns true if this collection contains all of the elements in the specified collection.

Returns:
true if this collection contains all of the elements in the specified collection.
Throws:
java.lang.NullPointerException - - c = null

addAll

boolean addAll(IntCollection c)
Adds all of the elements in the specified collection to this collection. Returns true if this collection has changed as a result of the call.

Returns:
true if this collection has changed as a result of the call
Throws:
java.lang.NullPointerException - - c = null
java.lang.UnsupportedOperationException - - this is an unmodifiable collection
java.lang.IllegalArgumentException - - some aspect of an element of the specified collection prevents it from being added to this collection.

removeAll

boolean removeAll(IntCollection c)
Removes all of this collection's elements that are also contained in the specified collection. After this call returns, this collection will contain no elements in common with the specified collection. Returns true if this collection has changed as a result of the call.

Returns:
true if this collection has changed as a result of the call
Throws:
java.lang.NullPointerException - - c = null
java.lang.UnsupportedOperationException - - this is an unmodifiable collection

retainAll

boolean retainAll(IntCollection c)
Retains only the elements in this collection that are contained in the specified collection. In other words, removes from this collection all of its elements that are not contained in the specified collection. Returns true if this collection has changed as a result of the call.

Returns:
rue if this collection has changed as a result of the call
Throws:
java.lang.NullPointerException - - c = null
java.lang.UnsupportedOperationException - - this is an unmodifiable collection

clear

void clear()
Removes all elements from this collection.

Throws:
java.lang.UnsupportedOperationException - - this is an unmodifiable collection

toArray

int[] toArray()
Returns an array containing all of the elements in this collection.

Returns:
an array containing all of the elements in this collection.

toArray

int[] toArray(int[] array)
Copies the elements of this collection into the specified array, provided that it is large enough, and returns it. If the array is not large enough, the effect of this method is the same as calling toArray().

Returns:
the given array, filled with the elements from this collection, if the it is large enough; otherwise a new array containing all of the elements in this collection.
Throws:
java.lang.NullPointerException - - array = null