Package sc.util

Class CoalescedHashSet<T>

  • All Implemented Interfaces:
    java.io.Serializable, java.lang.Cloneable, ISet<T>

    public class CoalescedHashSet<T>
    extends java.lang.Object
    implements java.lang.Cloneable, java.io.Serializable, ISet<T>
    This is a faster implementation of the basic operations for a table whose size is known roughly before populating, elements are never removed, hash functions are relatively good. No hash-table entries are created for adding a new item. Items are put into a slot based on their hash code. If that spot is filled, we start at the top of the list and put it in the first entry spot. So a full list can have O(N) insert and O(N) lookup. Resizing is expensive so avoid that.
    See Also:
    Serialized Form
    • Constructor Detail

      • CoalescedHashSet

        public CoalescedHashSet​(T[] elements)
      • CoalescedHashSet

        public CoalescedHashSet​(int sz)
    • Method Detail

      • contains

        public boolean contains​(T obj)
        Specified by:
        contains in interface ISet<T>
      • size

        public int size()
        Specified by:
        size in interface ISet<T>
      • add

        public boolean add​(T obj)
        Specified by:
        add in interface ISet<T>
      • containsAny

        public boolean containsAny​(ISet<T> other)
        Specified by:
        containsAny in interface ISet<T>
      • iterator

        public java.util.Iterator<T> iterator()
        Specified by:
        iterator in interface ISet<T>
      • addAll

        public void addAll​(ISet<T> s)