Class ObjectSets

java.lang.Object
it.unimi.dsi.fastutil.objects.ObjectSets

public final class ObjectSets
extends java.lang.Object
A class providing static methods and objects that do useful things with type-specific sets.
See Also:
Collections
  • Nested Class Summary

    Nested Classes
    Modifier and Type Class Description
    static class  ObjectSets.EmptySet<K>
    An immutable class representing the empty set and implementing a type-specific set interface.
    static class  ObjectSets.Singleton<K>
    An immutable class representing a type-specific singleton set.
    static class  ObjectSets.SynchronizedSet<K>
    A synchronized wrapper class for sets.
    static class  ObjectSets.UnmodifiableSet<K>
    An unmodifiable wrapper class for sets.
  • Field Summary

    Fields
    Modifier and Type Field Description
    static ObjectSets.EmptySet EMPTY_SET
    An empty set (immutable).
  • Method Summary

    Modifier and Type Method Description
    static <K> ObjectSet<K> emptySet()
    Returns an empty set (immutable).
    static <K> ObjectSet<K> singleton​(K element)
    Returns a type-specific immutable set containing only the specified element.
    static <K> ObjectSet<K> synchronize​(ObjectSet<K> s)
    Returns a synchronized type-specific set backed by the given type-specific set.
    static <K> ObjectSet<K> synchronize​(ObjectSet<K> s, java.lang.Object sync)
    Returns a synchronized type-specific set backed by the given type-specific set, using an assigned object to synchronize.
    static <K> ObjectSet<K> unmodifiable​(ObjectSet<? extends K> s)
    Returns an unmodifiable type-specific set backed by the given type-specific set.

    Methods inherited from class java.lang.Object

    equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • EMPTY_SET

      public static final ObjectSets.EmptySet EMPTY_SET
      An empty set (immutable). It is serializable and cloneable.
  • Method Details

    • emptySet

      public static <K> ObjectSet<K> emptySet()
      Returns an empty set (immutable). It is serializable and cloneable.

      This method provides a typesafe access to EMPTY_SET.

      Returns:
      an empty set (immutable).
    • singleton

      public static <K> ObjectSet<K> singleton​(K element)
      Returns a type-specific immutable set containing only the specified element. The returned set is serializable and cloneable.
      Parameters:
      element - the only element of the returned set.
      Returns:
      a type-specific immutable set containing just element.
    • synchronize

      public static <K> ObjectSet<K> synchronize​(ObjectSet<K> s)
      Returns a synchronized type-specific set backed by the given type-specific set.
      Parameters:
      s - the set to be wrapped in a synchronized set.
      Returns:
      a synchronized view of the specified set.
      See Also:
      Collections.synchronizedSet(Set)
    • synchronize

      public static <K> ObjectSet<K> synchronize​(ObjectSet<K> s, java.lang.Object sync)
      Returns a synchronized type-specific set backed by the given type-specific set, using an assigned object to synchronize.
      Parameters:
      s - the set to be wrapped in a synchronized set.
      sync - an object that will be used to synchronize the access to the set.
      Returns:
      a synchronized view of the specified set.
      See Also:
      Collections.synchronizedSet(Set)
    • unmodifiable

      public static <K> ObjectSet<K> unmodifiable​(ObjectSet<? extends K> s)
      Returns an unmodifiable type-specific set backed by the given type-specific set.
      Parameters:
      s - the set to be wrapped in an unmodifiable set.
      Returns:
      an unmodifiable view of the specified set.
      See Also:
      Collections.unmodifiableSet(Set)