Page Speed Optimization Libraries  1.13.35.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Types | Public Member Functions | List of all members
net_instaweb::Pool< T > Class Template Reference

#include "pool.h"

Public Types

typedef PoolElement< T >::Position iterator
 We can iterate over a pool using this iterator type.
 
typedef std::list< T * >
::const_iterator 
const_iterator
 

Public Member Functions

bool empty () const
 Is pool empty?
 
size_t size () const
 Size of pool.
 
iterator begin ()
 Iterator pointing to beginning of pool.
 
const_iterator begin () const
 const Iterator pointing to beginning of pool
 
iterator end ()
 Iterator pointing just past end of pool.
 
const_iterator end () const
 Iterator pointing just past end of pool.
 
void Add (T *object)
 Add object to pool. The object must not currently reside in a pool. More...
 
T * Remove (T *object)
 
T * oldest () const
 Return oldest object in pool, or NULL.
 
T * RemoveOldest ()
 
void DeleteAll ()
 DeleteAll: delete all elements of pool.
 
void Clear ()
 Clear: clear pool without deleting elements.
 

Detailed Description

template<class T>
class net_instaweb::Pool< T >

A pool holds references to objects of type T that provide a pool_position method (which they can do by extending PoolElement in pool_element.h, or by providing a getter method of type PoolElement::Position* pool_position() (an abstract settable pointer for a PoolElement::Position). Pool objects are maintained in insertion order.

We can insert and remove references from a pool, ask for an arbitrary reference contained in a pool, and clear or delete all pool elements. By default on destruction we delete pool elements using DeleteAll(); if a pool does not acquire object ownership, we should instead .Clear() it before destruction.

Member Function Documentation

template<class T>
void net_instaweb::Pool< T >::Add ( T *  object)
inline

Add object to pool. The object must not currently reside in a pool.

We need to get an iterator to the last element. We locally bind to avoid potential compiler trouble.

template<class T>
T* net_instaweb::Pool< T >::Remove ( T *  object)
inline

Remove specified object from pool. The object must have previously been inserted into this pool. Returns object.

template<class T>
T* net_instaweb::Pool< T >::RemoveOldest ( )
inline

Remove the least-recently-inserted object from the pool. Potentially cheaper than Remove(Oldest()).


The documentation for this class was generated from the following file: