org.semanticweb.elk.util.collections.entryset
Class EntryHashSet<E extends org.semanticweb.elk.util.collections.entryset.Entry<E>>

java.lang.Object
  extended by java.util.AbstractCollection<E>
      extended by org.semanticweb.elk.util.collections.entryset.EntryHashSet<E>
Type Parameters:
E - the type of entries in the collection
All Implemented Interfaces:
Iterable<E>, Collection<E>

public class EntryHashSet<E extends org.semanticweb.elk.util.collections.entryset.Entry<E>>
extends AbstractCollection<E>

A duplicate-free collection of entries E#equals(Object). The main method is merging a entry into the collection, which returns an equal entry from the collection, if there is one, or, otherwise, inserts the input entry into the collection returning itself. Other methods include finding an entry in the collection that is equal to the given one, deleting such an entry from the collection, if found, and iterating over the entries. The implementation is largely based on the implementation of HashSet from the standard Java collection library.

Author:
"Yevgeny Kazakov"

Constructor Summary
EntryHashSet()
          Constructs an empty EntryHashSet with the default initial capacity (16), the default under-load factor (0.15), and the default over-load factor (0.75).
EntryHashSet(int initialCapacity)
          Constructs an empty EntryHashSet with the specified initial capacity, the default under-load factor (0.15), and the default over-load factor (0.75).
EntryHashSet(int initialCapacity, float underloadFactor, float overloadFactor)
          Constructs an empty EntryHashSet with the specified initial capacity, under-load factor, and over-load factor.
 
Method Summary
 void clear()
          Removes all entries from this set.
 Iterator<E> iterator()
           
 int size()
          Returns the number of entries in this set.
 
Methods inherited from class java.util.AbstractCollection
add, addAll, contains, containsAll, isEmpty, remove, removeAll, retainAll, toArray, toArray, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface java.util.Collection
equals, hashCode
 

Constructor Detail

EntryHashSet

public EntryHashSet(int initialCapacity,
                    float underloadFactor,
                    float overloadFactor)
Constructs an empty EntryHashSet with the specified initial capacity, under-load factor, and over-load factor. The over-load factor needs to be larger than twice the under-load factor (ideally even more).

Parameters:
initialCapacity - the initial capacity
underloadFactor - the under-load factor
overloadFactor - the over-load factor
Throws:
IllegalArgumentException - if the initial capacity is negative or the load factor is non-positive

EntryHashSet

public EntryHashSet(int initialCapacity)
Constructs an empty EntryHashSet with the specified initial capacity, the default under-load factor (0.15), and the default over-load factor (0.75).

Parameters:
initialCapacity - the initial capacity.
Throws:
IllegalArgumentException - if the initial capacity is negative.

EntryHashSet

public EntryHashSet()
Constructs an empty EntryHashSet with the default initial capacity (16), the default under-load factor (0.15), and the default over-load factor (0.75).

Method Detail

size

public int size()
Returns the number of entries in this set.

Specified by:
size in interface Collection<E extends org.semanticweb.elk.util.collections.entryset.Entry<E>>
Specified by:
size in class AbstractCollection<E extends org.semanticweb.elk.util.collections.entryset.Entry<E>>
Returns:
the number of entries in this set

clear

public void clear()
Removes all entries from this set. The set will be empty after this call returns.

Specified by:
clear in interface Collection<E extends org.semanticweb.elk.util.collections.entryset.Entry<E>>
Overrides:
clear in class AbstractCollection<E extends org.semanticweb.elk.util.collections.entryset.Entry<E>>

iterator

public Iterator<E> iterator()
Specified by:
iterator in interface Iterable<E extends org.semanticweb.elk.util.collections.entryset.Entry<E>>
Specified by:
iterator in interface Collection<E extends org.semanticweb.elk.util.collections.entryset.Entry<E>>
Specified by:
iterator in class AbstractCollection<E extends org.semanticweb.elk.util.collections.entryset.Entry<E>>


Copyright © 2011-2013 Department of Computer Science, University of Oxford. All Rights Reserved.