com.samskivert.util
Interface IntSet

All Superinterfaces:
Collection<Integer>, Interable, Iterable<Integer>, Set<Integer>
All Known Implementing Classes:
ArrayIntSet, Collections.SynchronizedIntSet, HashIntMap.IntKeySet

public interface IntSet
extends Set<Integer>, Interable

A set that holds integers and provides accessors that eliminate the need to create and manipulate superfluous Integer objects. It extends the Set interface and therefore provides all of the standard methods (in which Integer objects will be converted to ints).


Method Summary
 boolean add(int value)
          Adds the specified element to this set if it is not already present (optional operation).
 boolean contains(int value)
          Returns true if this set contains the specified element.
 Interator interator()
          Return an Interator that iterates over the ints in this set.
 boolean remove(int value)
          Removes the specified element from this set if it is present (optional operation).
 int[] toIntArray()
          Returns an array containing all of the elements in this set.
 
Methods inherited from interface java.util.Set
add, addAll, clear, contains, containsAll, equals, hashCode, isEmpty, iterator, remove, removeAll, retainAll, size, toArray, toArray
 

Method Detail

contains

boolean contains(int value)
Returns true if this set contains the specified element.

Parameters:
value - element whose presence in this set is to be tested.
Returns:
true if this set contains the specified element.

add

boolean add(int value)
Adds the specified element to this set if it is not already present (optional operation). If this set already contains the specified element, the call leaves this set unchanged and returns false. In combination with the restriction on constructors, this ensures that sets never contain duplicate elements.

Parameters:
value - element to be added to this set.
Returns:
true if this set did not already contain the specified element.
Throws:
UnsupportedOperationException - if the add method is not supported by this set.

remove

boolean remove(int value)
Removes the specified element from this set if it is present (optional operation). Returns true if the set contained the specified element (or equivalently, if the set changed as a result of the call). (The set will not contain the specified element once the call returns.)

Parameters:
value - element to be removed from this set, if present.
Returns:
true if the set contained the specified element.
Throws:
UnsupportedOperationException - if the remove method is not supported by this set.

interator

Interator interator()
Return an Interator that iterates over the ints in this set.

Specified by:
interator in interface Interable

toIntArray

int[] toIntArray()
Returns an array containing all of the elements in this set. Obeys the general contract of the Collection.toArray method.

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


Copyright © 2000-2008 Michael Bayne. All Rights Reserved.