org.apache.uima.internal.util
Class IntSet

java.lang.Object
  extended by org.apache.uima.internal.util.IntSet

public class IntSet
extends java.lang.Object

This class implements a set of integers. It does not implement the Set interface for performance reasons, though methods with the same name are equivalent.


Constructor Summary
IntSet()
          Creates a new instance of this set.
 
Method Summary
 boolean add(int element)
          Adds the specified int to this set.
 boolean contains(int element)
          Tests if this set contains the specified element.
 boolean equals(java.lang.Object o)
          Tests if two sets are equal.
 int get(int n)
           
 int hashCode()
           
 int indexOf(int element)
           
 void remove(int n)
          Removes the n-th element in this set.
 int size()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

IntSet

public IntSet()
Creates a new instance of this set.

Method Detail

add

public boolean add(int element)
Adds the specified int to this set.

Parameters:
element - the integer to be added.
Returns:
true if this set did not already contain this element, false otherwise.

contains

public boolean contains(int element)
Tests if this set contains the specified element.

Parameters:
element - the element to be tested.
Returns:
true if the element is contained in this set, false otherwise.

size

public int size()
Returns:
the size of this set.

get

public int get(int n)
Returns:
the n-th element in this set.

remove

public void remove(int n)
Removes the n-th element in this set.


equals

public boolean equals(java.lang.Object o)
Tests if two sets are equal. This is the case if the two sets are of the same size, and every element in one set in contained in the other set.
Note that in order to increase performance, before the sets are actually compared the way described above, the sums of the elements in both sets are calculated, ignoring possible int overflows. If the sums are not equal, the two sets cannot be equal. In case the sums are equal, the two sets are compared element by element.

Overrides:
equals in class java.lang.Object
Parameters:
s - the set to be tested for equality with this set.
Returns:
true if the sets are equal, false otherwise.

hashCode

public int hashCode()
Overrides:
hashCode in class java.lang.Object

indexOf

public int indexOf(int element)


Copyright © 2011. All Rights Reserved.