gt:         set = new TIntHashSet();
context: package gnu.trove.set.hash;
  
  import gnu.trove.iterator.TIntIterator;
  import gnu.trove.procedure.TIntProcedure;
  import gnu.trove.set.TIntSet;
  import junit.framework.TestCase;
  
  import java.io.ByteArrayInputStream;
  import java.io.ByteArrayOutputStream;
  import java.io.ObjectInputStream;
  import java.io.ObjectOutputStream;
  import java.util.*;
  
  
  /**
   * Test the primitive HashSet classes.
   */
  public class TPrimitiveHashSetTest extends TestCase {
  
      public TPrimitiveHashSetTest(String name) {
          super(name);
      }
  
  
      public void setUp() throws Exception {
          super.setUp();
      }
  
  
      public void tearDown() throws Exception {
          super.tearDown();
      }
  
  
      public void testConstructors() throws Exception {
          TIntSet set = new TIntHashSet();
          assertNotNull(set);
  
          int[] ints = {1138, 42, 86, 99, 101};
          set.addAll(ints);
  
          TIntSet copy = new TIntHashSet(set);
          assertTrue("set not a copy: " + set + ", " + copy, set.equals(copy));
  
          TIntSet another = new TIntHashSet(20);
          another.addAll(ints);
          assertTrue("set not equal: " + set + ", " + copy, set.equals(another));
  
          another = new TIntHashSet(2, 1.0f);
          another.addAll(ints);
          assertTrue("set not equal: " + set + ", " + copy, set.equals(another));
  
          another = new TIntHashSet(ints);
          assertTrue("set not equal: " + set + ", " + copy, set.equals(another));
      }
  
  
      public void testIsEmpty() throws Exception {
          TIntSet s = new TIntHashSet();
          assertTrue("new set wasn't empty", s.isEmpty());
  
          s.add(1);
          assertTrue("set with element reports empty", !s.isEmpty());
          s.clear();
          assertTrue("cleared set reports not-empty", s.isEmpty());
      }
  
  
      public void testContains() throws Exception {
          TIntSet s = new TIntHashSet();
          int i = 100;
          s.add(i);
          assertTrue("contains failed", s.contains(i));
          assertFalse("contains failed", s.contains(1000));
      }
  
  
      @SuppressWarnings({"ForLoopReplaceableByForEach"})
      public void testContainsAll() throws Exception {
  
          int[] ints = {1138, 42, 13, 86, 99};
  
          TIntSet set = new TIntHashSet();
          set.addAll(ints);
  
          TIntSet other = new TIntHashSet();
          other.addAll(ints);
  
          List<Number> ints_list = new ArrayList<Number>();
          for (int element : ints) {
              ints_list.add(element);
          }
  
          for (int index = 0; index < ints.length; index++) {
              assertTrue(Integer.valueOf(ints[index]).toString(),
                      set.contains(ints[index]));
          }
  
          assertTrue("containsAll(Collection<?>) failed: " + set,
                  set.containsAll(ints_list));
          ints_list.remove(Integer.valueOf(42));
          ints_list.add(Long.valueOf(42));
          assertFalse("containsAll(Collection<?>) failed: " + set,
                  set.containsAll(ints_list));
  
          assertTrue("containsAll(TIntSet) failed (same set): " + set,
                  set.containsAll(set));
  
          assertTrue("containsAll(TIntSet) failed (other set): " + set,
                  set.containsAll(other));
  
          assertTrue("containsAll(int[]) failed: " + set,
                  set.containsAll(ints));
  
  
          int[] failed = {42, 86, 99, 123456};
  
          TIntSet failed_set = new TIntHashSet();
          failed_set.addAll(failed);
  
          List<Integer> failed_list = new ArrayList<Integer>();
          for (int element : failed) {
              failed_list.add(element);
          }
  
          assertFalse("containsAll(Collection<?>) failed (false positive): " + set,
                  set.containsAll(failed_list));
  
          assertFalse("containsAll(TIntSet) failed (false positive): " + set,
                  set.containsAll(failed_set));
  
          assertFalse("containsAll(int[]) failed (false positive): " + set,
                  set.containsAll(failed));
      }
  
  
      public void testAddAll() throws Exception {
  
          int[] ints = {1138, 42, 13, 86, 99, 101};
  
          TIntSet set;
  
          List<Integer> list = new ArrayList<Integer>();
          for (int element : ints) {
              list.add(Integer.valueOf(element));
          }
  
          set = new TIntHashSet();
          assertTrue("addAll(Collection<?>) failed: " + set, set.addAll(list));
          for (int element : ints) {
              assertTrue("contains failed: ", set.contains(element));
          }
  
          set = new TIntHashSet();
          assertTrue("addAll(int[]) failed: " + set, set.addAll(ints));
          for (int element : ints) {
              assertTrue("contains failed: ", set.contains(element));
          }
  
          TIntSet test_set = new TIntHashSet();
          assertTrue("addAll(TIntSet) failed: " + test_set, test_set.addAll(set));
          for (int element : ints) {
              assertTrue("contains failed: ", set.contains(element));
          }
  
  
      }
  
  
      public void testRetainAll() throws Exception {
  
          int[] ints = {1138, 42, 13, 86, 99, 101};
  
          TIntSet set = new TIntHashSet();
          set.addAll(ints);
  
          TIntSet other = new TIntHashSet();
          other.addAll(ints);
  
          int[] to_retain = {13, 86, 99, 1138};
  
          TIntSet retain_set = new TIntHashSet();
          retain_set.addAll(to_retain);
  
          List<Integer> retain_list = new ArrayList<Integer>();
          for (int element : to_retain) {
              retain_list.add(element);
          }
  
          assertFalse("retainAll(TIntSet) failed (same set): " + set,
                  set.retainAll(set));
          // Contains all the original elements
          assertTrue(set.toString(), set.containsAll(ints));
          assertTrue(retain_set.toString(), retain_set.containsAll(to_retain));
  
          assertTrue("retainAll(Collection<?>) failed: " + set,
                  set.retainAll(retain_list));
          // Contains just the expected elements
          assertFalse(set.toString(), set.containsAll(ints));
          assertTrue(set.toString(), set.containsAll(to_retain));
          assertTrue(retain_set.toString(), retain_set.containsAll(to_retain));
  
          // reset the set.
  