Class WeakSet<T>

  • All Implemented Interfaces:
    java.lang.Iterable<T>
    Direct Known Subclasses:
    CopyOnReadWeakSet

    public abstract class WeakSet<T>
    extends java.lang.Object
    implements java.lang.Iterable<T>
    • Field Summary

      Fields 
      ChangeModifier and Type Field Description
      NEWprotected java.util.WeakHashMap<T,​T> weakHashStorage  
    • Constructor Summary

      Constructors 
      ChangeConstructor Description
      WeakSet()  
    • Method Summary

      All Methods Instance Methods Abstract Methods Concrete Methods 
      ChangeModifier and Type Method Description
      abstract void add​(T t)
      Add the given object to the set.
      abstract void clear()
      Remove all elements from this data structure
      abstract boolean contains​(T t)
      Returns true if the given object is in this data structure
      abstract boolean isEmpty()
      Return whether this data structure is empty.
      NEWprotected void maybeWarnAboutAnonymousValue​(T t)
      Looks for situations where clients may lose the values added to this class.
      abstract void remove​(T t)
      Remove the given object from the data structure
      abstract int size()
      Return the number of objects contained within this data structure
      java.util.stream.Stream<T> stream()
      Returns a stream of the values of this collection.
      abstract java.util.Collection<T> values()
      Returns a Collection view of this set.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, iterator, spliterator
    • Field Detail

      • weakHashStorage NEW

        protected java.util.WeakHashMap<T,​T> weakHashStorage

Constructor Detail

  • Method Detail

    • maybeWarnAboutAnonymousValue NEW

      protected void maybeWarnAboutAnonymousValue​(T t)
      Looks for situations where clients may lose the values added to this class. This most often happens when a client adds an anonymous, local listener to an object that is using a WeakSet to store its listeners. Our policy is to implement listeners at the class field level so that they will not be flagged by this method.
      Parameters:
      t - The object to check
    • add

      public abstract void add​(T t)
      Add the given object to the set.
    • remove

      public abstract void remove​(T t)
      Remove the given object from the data structure
    • contains

      public abstract boolean contains​(T t)
      Returns true if the given object is in this data structure
    • clear

      public abstract void clear()
      Remove all elements from this data structure
    • size

      public abstract int size()
      Return the number of objects contained within this data structure
    • isEmpty

      public abstract boolean isEmpty()
      Return whether this data structure is empty.
    • values

      public abstract java.util.Collection<T> values()
      Returns a Collection view of this set. The returned Collection is backed by this set.
      Returns:
      a Collection view of this set. The returned Collection is backed by this set.
    • stream

      public java.util.stream.Stream<T> stream()
      Returns a stream of the values of this collection.
      Returns:
      a stream of the values of this collection.