namespace Chernobyl.DesignPatterns.Pool
{
///
/// A storage container that consists of several objects
/// that are stored together for reuse. This class abstracts away
/// how the pooled type is created, where it comes from, how it's
/// stored, and what happens to an object when it is returned to
/// the pool and retrieved from the pool.
///
/// The type of object to pool.
public interface IPool
{
///
/// Takes an object from the pool. If the pool has
/// no more objects to give or it does not want to
/// give an object out then null will be returned.
///
/// The object to fill with
/// the taken object.
/// True if there was an object that could be
/// taken from the pool and that object was assigned to
/// , false if otherwise.
bool Take(out PooledType objectToTake);
///
/// Returns a previously taken object to the pool.
///
/// The object to return
/// to the pool.
void Return(PooledType objectToReturn);
///
/// Adds an object to the pool.
///
/// The item to add to the pool
void Add(PooledType item);
///
/// Clears out the pool.
///
void Clear();
///
/// The number of objects in the pool.
///
int Count { get; }
///
/// Removes an item from the pool.
///
/// The item to remove.
/// True if the item was removed, false if
/// otherwise.
bool Remove(PooledType item);
}
}