Package ghidra.util.datastruct

# Class WeakSet<T>

java.lang.Object
ghidra.util.datastruct.WeakSet<T>

All Implemented Interfaces:
  `Iterable<T>`, `Collection<T>`, `Set<T>`

public abstract class WeakSet<T> extends Object implements Set<T>

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected WeakHashMap<T,T>`
  `weakHashStorage`

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `WeakSet()`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `abstract boolean`
  `add(T t)`
  Add the given object to the set
  `abstract boolean`
  `addAll(Collection<? extends T> c)`
  `abstract void`
  `clear()`
  Remove all elements from this data structure
  `abstract boolean`
  `contains(Object t)`
  Returns true if the given object is in this data structure
  `boolean`
  `containsAll(Collection<?> c)`
  `abstract boolean`
  `isEmpty()`
  Return whether this data structure is empty
  `protected void`
  `maybeWarnAboutAnonymousValue(T t)`
  Looks for situations where clients may lose the values added to this class.
  `abstract boolean`
  `remove(Object t)`
  Remove the given object from the data structure
  `abstract boolean`
  `removeAll(Collection<?> c)`
  `abstract boolean`
  `retainAll(Collection<?> c)`
  `abstract int`
  `size()`
  Return the number of objects contained within this data structure
  `abstract Stream<T>`
  `stream()`
  Returns a stream of the values of this collection.
  `Object[]`
  `toArray()`
  `<T> T[]`
  `toArray(T[] a)`
  `abstract 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.util.Collection

  `parallelStream, removeIf, toArray`

  ### Methods inherited from interface java.lang.Iterable

  `forEach`

  ### Methods inherited from interface java.util.Set

  `equals, hashCode, iterator, spliterator`

- ## Field Details

  - ### weakHashStorage

    protected WeakHashMap<T,T> weakHashStorage

- ## Constructor Details

  - ### WeakSet

    public WeakSet()

- ## Method Details

  - ### maybeWarnAboutAnonymousValue

    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 boolean add(T t)
    Add the given object to the set
    Specified by:
      `add` in interface `Collection<T>`
    Specified by:
      `add` in interface `Set<T>`
    Parameters:
      `t` - the object to add

  - ### remove

    public abstract boolean remove(Object t)
    Remove the given object from the data structure
    Specified by:
      `remove` in interface `Collection<T>`
    Specified by:
      `remove` in interface `Set<T>`
    Parameters:
      `t` - the object to remove

  - ### contains

    public abstract boolean contains(Object t)
    Returns true if the given object is in this data structure
    Specified by:
      `contains` in interface `Collection<T>`
    Specified by:
      `contains` in interface `Set<T>`
    Parameters:
      `t` - the object
    Returns:
      true if the given object is in this data structure

  - ### clear

    public abstract void clear()
    Remove all elements from this data structure
    Specified by:
      `clear` in interface `Collection<T>`
    Specified by:
      `clear` in interface `Set<T>`

  - ### size

    public abstract int size()
    Return the number of objects contained within this data structure
    Specified by:
      `size` in interface `Collection<T>`
    Specified by:
      `size` in interface `Set<T>`
    Returns:
      the size

  - ### isEmpty

    public abstract boolean isEmpty()
    Return whether this data structure is empty
    Specified by:
      `isEmpty` in interface `Collection<T>`
    Specified by:
      `isEmpty` in interface `Set<T>`
    Returns:
      whether this data structure is empty

  - ### values

    public abstract 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.

  - ### toArray

    public Object[] toArray()
    Specified by:
      `toArray` in interface `Collection<T>`
    Specified by:
      `toArray` in interface `Set<T>`

  - ### toArray

    public <T> T[] toArray(T[] a)
    Specified by:
      `toArray` in interface `Collection<T>`
    Specified by:
      `toArray` in interface `Set<T>`

  - ### containsAll

    public boolean containsAll(Collection<?> c)
    Specified by:
      `containsAll` in interface `Collection<T>`
    Specified by:
      `containsAll` in interface `Set<T>`

  - ### addAll

    public abstract boolean addAll(Collection<? extends T> c)
    Specified by:
      `addAll` in interface `Collection<T>`
    Specified by:
      `addAll` in interface `Set<T>`

  - ### retainAll

    public abstract boolean retainAll(Collection<?> c)
    Specified by:
      `retainAll` in interface `Collection<T>`
    Specified by:
      `retainAll` in interface `Set<T>`

  - ### removeAll

    public abstract boolean removeAll(Collection<?> c)
    Specified by:
      `removeAll` in interface `Collection<T>`
    Specified by:
      `removeAll` in interface `Set<T>`

  - ### stream

    public abstract Stream<T> stream()
    Returns a stream of the values of this collection.
    Specified by:
      `stream` in interface `Collection<T>`
    Returns:
      a stream of the values of this collection.