Package org.eclipse.equinox.p2.core

## Class WeakPool<T>

- java.lang.Object
- - org.eclipse.equinox.p2.core.WeakPool<T>

All Implemented Interfaces:
  `IPool<T>`

    public class WeakPool<T>
    extends Object
    implements IPool<T>

An object pool backed by weak references. Objects stored in this pool will be garbage collected once all strong references to the objects are broken.

Since `WeakReference` are not particularly light-weight, a client could use a `StrongPool` if the pool will be short lived and explicitly nulled by the client.

Since:
  2.1

### Constructor Summary

Constructors
`WeakPool()`

### Method Summary

All Methods Instance Methods Concrete Methods
`T` `add​(T newObject)` Returns the first object from this pool which is equal to the given object.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### WeakPool

    public WeakPool()

### Method Detail

#### add

    public T add​(T newObject)

Description copied from interface: `IPool`
Returns the first object from this pool which is equal to the given object. If the pool contains no such object then the object is added to the pool and returned. If the object is `null`, `null` is returned.

Specified by:
  `add` in interface `IPool<T>`
Parameters:
  `newObject` - the object to add
Returns:
  a shared object that is equal to the given object or `null`