Module org.hsqldb

Class HashSet<E>

  • All Implemented Interfaces:
    Collection<E>, Set<E>
    Direct Known Subclasses:
    OrderedHashSet

    public class HashSet<E>
    extends org.hsqldb.map.BaseHashMap
    implements Set<E>
    This class does not store null keys.
    Since:
    1.7.2
    Author:
    Fred Toussi (fredt@users dot sourceforge.net)
    • Field Summary

      • Fields inherited from class org.hsqldb.map.BaseHashMap

        ACCESS_MAX, emptyObjectArray
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean add​(E key)
      returns true if element is added
      boolean addAll​(E[] keys)
      returns true if any element is added
      boolean addAll​(E[] keys, int start, int limit)
      returns true if any added
      boolean addAll​(Collection<? extends E> c)
      returns true if any element is added
      int capacity()  
      boolean contains​(java.lang.Object key)  
      boolean containsAll​(Collection<E> col)  
      E get​(E key)  
      int getCommonElementCount​(Set<E> other)  
      E getOrAdd​(E key)
      returns existing value or null if added can be used as an Object cache
      Iterator<E> iterator()  
      boolean remove​(E key)
      returns true if removed
      boolean removeAll​(E[] keys)
      returns true if all were removed
      boolean removeAll​(Collection<E> c)
      returns true if all were removed
      java.lang.Object[] toArray()  
      <T> T[] toArray​(T[] a)  
      java.lang.String toString()
      Returns a String like "[Drei, zwei, Eins]", exactly like java.util.HashSet.
      • Methods inherited from class org.hsqldb.map.BaseHashMap

        clear, clone, isEmpty, size
      • Methods inherited from class java.lang.Object

        equals, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • HashSet

        public HashSet()
      • HashSet

        public HashSet​(int initialCapacity)
                throws java.lang.IllegalArgumentException
        Throws:
        java.lang.IllegalArgumentException
      • HashSet

        public HashSet​(int initialCapacity,
                       ObjectComparator<E> comparator)
                throws java.lang.IllegalArgumentException
        Throws:
        java.lang.IllegalArgumentException
      • HashSet

        public HashSet​(E[] valueList)
    • Method Detail

      • contains

        public boolean contains​(java.lang.Object key)
        Specified by:
        contains in interface Collection<E>
      • containsAll

        public boolean containsAll​(Collection<E> col)
      • getOrAdd

        public E getOrAdd​(E key)
        returns existing value or null if added can be used as an Object cache
      • get

        public E get​(E key)
      • add

        public boolean add​(E key)
        returns true if element is added
        Specified by:
        add in interface Collection<E>
        Parameters:
        key - the element
        Returns:
        true if added
      • addAll

        public boolean addAll​(Collection<? extends E> c)
        returns true if any element is added
        Specified by:
        addAll in interface Collection<E>
        Parameters:
        c - the Collection to add
        Returns:
        true if any element is added
      • addAll

        public boolean addAll​(E[] keys)
        returns true if any element is added
        Parameters:
        keys - the array of elements to add
        Returns:
        true if any element is added
      • addAll

        public boolean addAll​(E[] keys,
                              int start,
                              int limit)
        returns true if any added
        Parameters:
        keys - array of keys to add
        start - first index to add
        limit - limit of index to add
        Returns:
        true if any element was added
      • remove

        public boolean remove​(E key)
        returns true if removed
        Specified by:
        remove in interface Collection<E>
        Parameters:
        key - Object to remove
        Returns:
        true if removed
      • removeAll

        public boolean removeAll​(Collection<E> c)
        returns true if all were removed
        Parameters:
        c - Collection of elements to remove
        Returns:
        true if all removed
      • removeAll

        public boolean removeAll​(E[] keys)
        returns true if all were removed
        Parameters:
        keys - E[]
        Returns:
        boolean
      • capacity

        public int capacity()
      • getCommonElementCount

        public int getCommonElementCount​(Set<E> other)
      • toArray

        public <T> T[] toArray​(T[] a)
      • toArray

        public java.lang.Object[] toArray()
      • toString

        public java.lang.String toString()
        Returns a String like "[Drei, zwei, Eins]", exactly like java.util.HashSet.
        Overrides:
        toString in class java.lang.Object
        Returns:
        String representation