test_class.declarator: set
test_class.modifier: protected
test_class.original_string: protected Set set;
test_class.type: Set
test_class.var_name: set
test_class.file: ontopia-engine/src/test/java/net/ontopia/utils/CompactHashSetTest.java
test_class.identifier: CompactHashSetTest
test_case.body: @Test
    public void testAdd() {
      set.add("hei");
  
      Assert.assertTrue("set with 1 element thinks it's empty", !set.isEmpty());
      Assert.assertTrue("set size != 1", set.size() == 1);
  
      Assert.assertTrue("add thinks object just added is not contained",
                 !set.add("hei"));
  
      Assert.assertTrue("set with 1 element thinks it's empty", !set.isEmpty());
      Assert.assertTrue("set size != 1", set.size() == 1);
  
      Assert.assertTrue("set thinks new object is already contained",
  	   set.add("hei2"));
  
      Assert.assertTrue("set size != 2", set.size() == 2);
  
      Assert.assertTrue("add thinks object just added is not contained",
                 !set.add("hei"));
      Assert.assertTrue("add thinks object just added is not contained",
                 !set.add("hei2"));
    }
test_case.class_method_signature: CompactHashSetTest.testAdd()
test_case.full_signature: @Test public void testAdd()
test_case.identifier: testAdd
test_case.invocations: add assertTrue isEmpty assertTrue size assertTrue add assertTrue isEmpty assertTrue size assertTrue add assertTrue size assertTrue add assertTrue add
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testAdd()
focal_class.declarator: INITIAL_SIZE = 3
focal_class.modifier: protected final static
focal_class.original_string: protected final static int INITIAL_SIZE = 3;
focal_class.type: int
focal_class.var_name: INITIAL_SIZE
focal_class.declarator: LOAD_FACTOR = 0.75
focal_class.modifier: protected final static
focal_class.original_string: protected final static double LOAD_FACTOR = 0.75;
focal_class.type: double
focal_class.var_name: LOAD_FACTOR
focal_class.declarator: nullObject = new Object()
focal_class.modifier: protected final static
focal_class.original_string: protected final static Object nullObject = new Object();
focal_class.type: Object
focal_class.var_name: nullObject
focal_class.declarator: deletedObject = new Object()
focal_class.modifier: protected final static
focal_class.original_string: protected final static Object deletedObject = new Object();
focal_class.type: Object
focal_class.var_name: deletedObject
focal_class.declarator: elements
focal_class.modifier: protected
focal_class.original_string: protected int elements;
focal_class.type: int
focal_class.var_name: elements
focal_class.declarator: freecells
focal_class.modifier: protected
focal_class.original_string: protected int freecells;
focal_class.type: int
focal_class.var_name: freecells
focal_class.declarator: objects
focal_class.modifier: protected
focal_class.original_string: protected E[] objects;
focal_class.type: E[]
focal_class.var_name: objects
focal_class.declarator: modCount
focal_class.modifier: protected
focal_class.original_string: protected int modCount;
focal_class.type: int
focal_class.var_name: modCount
focal_class.file: ontopia-engine/src/main/java/net/ontopia/utils/CompactHashSet.java
focal_class.identifier: CompactHashSet
focal_class.class_method_signature: CompactHashSet.CompactHashSet()
focal_class.full_signature: public  CompactHashSet()
focal_class.identifier: CompactHashSet
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.signature:  CompactHashSet()
focal_class.class_method_signature: CompactHashSet.CompactHashSet(int size)
focal_class.full_signature: public  CompactHashSet(int size)
focal_class.identifier: CompactHashSet
focal_class.modifiers: public
focal_class.parameters: (int size)
focal_class.signature:  CompactHashSet(int size)
focal_class.class_method_signature: CompactHashSet.CompactHashSet(Collection<E> c)
focal_class.full_signature: public  CompactHashSet(Collection<E> c)
focal_class.identifier: CompactHashSet
focal_class.modifiers: public
focal_class.parameters: (Collection<E> c)
focal_class.signature:  CompactHashSet(Collection<E> c)
focal_class.class_method_signature: CompactHashSet.iterator()
focal_class.full_signature: @Override public Iterator<E> iterator()
focal_class.identifier: iterator
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: Iterator<E>
focal_class.signature: Iterator<E> iterator()
focal_class.class_method_signature: CompactHashSet.size()
focal_class.full_signature: @Override public int size()
focal_class.identifier: size
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int size()
focal_class.class_method_signature: CompactHashSet.isEmpty()
focal_class.full_signature: @Override public boolean isEmpty()
focal_class.identifier: isEmpty
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean isEmpty()
focal_class.class_method_signature: CompactHashSet.contains(Object o)
focal_class.full_signature: @Override public boolean contains(Object o)
focal_class.identifier: contains
focal_class.modifiers: @Override public
focal_class.parameters: (Object o)
focal_class.return: boolean
focal_class.signature: boolean contains(Object o)
focal_class.class_method_signature: CompactHashSet.add(Object o)
focal_class.full_signature: @Override public boolean add(Object o)
focal_class.identifier: add
focal_class.modifiers: @Override public
focal_class.parameters: (Object o)
focal_class.return: boolean
focal_class.signature: boolean add(Object o)
focal_class.class_method_signature: CompactHashSet.remove(Object o)
focal_class.full_signature: @Override public boolean remove(Object o)
focal_class.identifier: remove
focal_class.modifiers: @Override public
focal_class.parameters: (Object o)
focal_class.return: boolean
focal_class.signature: boolean remove(Object o)
focal_class.class_method_signature: CompactHashSet.clear()
focal_class.full_signature: @Override public void clear()
focal_class.identifier: clear
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void clear()
focal_class.class_method_signature: CompactHashSet.toArray()
focal_class.full_signature: @Override public Object[] toArray()
focal_class.identifier: toArray
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: Object[]
focal_class.signature: Object[] toArray()
focal_class.class_method_signature: CompactHashSet.toArray(T[] a)
focal_class.full_signature: @Override public T[] toArray(T[] a)
focal_class.identifier: toArray
focal_class.modifiers: @Override public
focal_class.parameters: (T[] a)
focal_class.return: T[]
focal_class.signature: T[] toArray(T[] a)
focal_class.class_method_signature: CompactHashSet.dump()
focal_class.full_signature: public void dump()
focal_class.identifier: dump
focal_class.modifiers: public
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void dump()
focal_class.class_method_signature: CompactHashSet.rehash()
focal_class.full_signature: protected void rehash()
focal_class.identifier: rehash
focal_class.modifiers: protected
focal_class.parameters: ()
focal_class.return: void
focal_class.signature: void rehash()
focal_class.class_method_signature: CompactHashSet.rehash(int newCapacity)
focal_class.full_signature: protected void rehash(int newCapacity)
focal_class.identifier: rehash
focal_class.modifiers: protected
focal_class.parameters: (int newCapacity)
focal_class.return: void
focal_class.signature: void rehash(int newCapacity)
focal_class.superclass: extends java.util.AbstractSet<E>
focal_method.body: @Override
    public boolean add(Object o) {
      if (o == null) o = nullObject;
  
      int hash = o.hashCode();
      int index = (hash & 0x7FFFFFFF) % objects.length;
      int offset = 1;
      int deletedix = -1;
      
      // search for the object (continue while !null and !this object)
      while(objects[index] != null &&
            !(objects[index].hashCode() == hash &&
              objects[index].equals(o))) {
  
        // if there's a deleted object here we can put this object here,
        // provided it's not in here somewhere else already
        if (objects[index] == deletedObject)
          deletedix = index;
        
        index = ((index + offset) & 0x7FFFFFFF) % objects.length;
        offset = offset*2 + 1;
  
        if (offset == -1)
          offset = 2;
      }
      
      if (objects[index] == null) { // wasn't present already
        if (deletedix != -1) // reusing a deleted cell
          index = deletedix;
        else
          freecells--;
  
        modCount++;
        elements++;
  
        // here we face a problem regarding generics:
        // add(E o) is not possible because of the null Object. We cant do 'new E()' or '(E) new Object()'
        // so adding an empty object is a problem here
        // If (! o instanceof E) : This will cause a class cast exception
        // If (o instanceof E) : This will work fine
  
        objects[index] = (E) o;
        
        // do we need to rehash?
        if (1 - (freecells / (double) objects.length) > LOAD_FACTOR)
          rehash();
        return true;
      } else // was there already 
        return false;
    }
focal_method.class_method_signature: CompactHashSet.add(Object o)
focal_method.full_signature: @Override public boolean add(Object o)
focal_method.identifier: add
focal_method.invocations: hashCode hashCode equals rehash
focal_method.modifiers: @Override public
focal_method.parameters: (Object o)
focal_method.return: boolean
focal_method.signature: boolean add(Object o)