Rosetta 3.5
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Public Member Functions | Private Member Functions | Private Attributes | List of all members
core::graph::ArrayPool< T > Class Template Reference

#include <ArrayPool.hh>

Inheritance diagram for core::graph::ArrayPool< T >:
Inheritance graph
[legend]
Collaboration diagram for core::graph::ArrayPool< T >:
Collaboration graph
[legend]

Public Member Functions

 ArrayPool ()
 Creation and destruction. More...
 
 ArrayPool (platform::Size block_size)
 Constructor with block-size specification. More...
 
 ArrayPool (platform::Size block_size, platform::Size array_size)
 Constructor with block-size and array-size specification. More...
 
 ~ArrayPool ()
 
platform::Size array_size () const
 Methods to read information about the pool size. More...
 
platform::Size block_size () const
 Returns the number of arrays to allocate in each block. More...
 
platform::Size footprint () const
 Returns the number of bytes occupied by all allocated and not-yet allocated arrays. More...
 
void set_array_size (platform::Size size)
 Methods to modify the size of the pool. More...
 
void set_block_size (platform::Size size)
 
platform::Size nblocks () const
 Return the number of allocated array blocks. More...
 
platform::Size nallocated () const
 Return the number of allocated arrays. If this were multiplied by the array_size_, then you'd have the amount of space spent representing the T arrays but you wouldn't have the amount of space spent representing the negative space linked list. More...
 
platform::Size noutstanding () const
 Return the number of allocated arrays that have been requested by the user and are now "outstanding" in that they have to be returned before the array pool may be deleted. More...
 
bool empty () const
 
ArrayPoolElement< T > new_array ()
 Methods for allocating and deallocating arrays from this pool. More...
 
void deallocate_array (ArrayPoolElement< T > const &element)
 Free an ArrayPoolElement to the pool. The element is invalid after this call completes. More...
 

Private Member Functions

void create_new_block ()
 Add a new block to the pool and add the elements of this block to the negative space singly linked list. The block sizes and the array sizes must be set before this method is called and, so long as the ArrayPool is not empty, these sizes may not be altered. More...
 
void clear ()
 Deallocate all the allocated blocks. The pool must be empty before this should be called or dangling references are likely. More...
 
bool mine (NegSpaceElement< T > const *neg_element) const
 Determine if a given pointer to a negative-space element belongs to this pool. The compiler cannot ensure that when a ArrayPoolElement is handed to the deallocate_array method that it belongs to the pool being invoked upon. More...
 

Private Attributes

platform::Size block_size_
 
platform::Size array_size_
 
platform::Size nblocks_
 
platform::Size nnegative_
 
NegSpaceElement< T > neg_begin_
 
std::list< NegSpaceElement< T > * > neg_space_blocks_
 
std::list< T * > array_blocks_
 

Constructor & Destructor Documentation

template<class T>
core::graph::ArrayPool< T >::ArrayPool ( )
inline

Creation and destruction.

Default constructor uses a block size of 32

template<class T>
core::graph::ArrayPool< T >::ArrayPool ( platform::Size  block_size)
inline

Constructor with block-size specification.

template<class T>
core::graph::ArrayPool< T >::ArrayPool ( platform::Size  block_size,
platform::Size  array_size 
)
inline

Constructor with block-size and array-size specification.

template<class T>
core::graph::ArrayPool< T >::~ArrayPool ( )
inline

Member Function Documentation

template<class T>
platform::Size core::graph::ArrayPool< T >::array_size ( ) const
inline

Methods to read information about the pool size.

Returns the size of each array to be allocated.

template<class T>
platform::Size core::graph::ArrayPool< T >::block_size ( ) const
inline

Returns the number of arrays to allocate in each block.

template<class T>
void core::graph::ArrayPool< T >::clear ( )
inlineprivate

Deallocate all the allocated blocks. The pool must be empty before this should be called or dangling references are likely.

Referenced by core::graph::ArrayPool< Real >::set_array_size(), core::graph::ArrayPool< Real >::set_block_size(), and core::graph::ArrayPool< Real >::~ArrayPool().

template<class T>
void core::graph::ArrayPool< T >::create_new_block ( )
inlineprivate

Add a new block to the pool and add the elements of this block to the negative space singly linked list. The block sizes and the array sizes must be set before this method is called and, so long as the ArrayPool is not empty, these sizes may not be altered.

This array pool supports, but does not recommend using, array sizes of 0. The resulting ArrayPoolElements have Array0 objecst that point at null, and therefore, should never be dereferenced. However, there is nothing inherrently wrong with pointing at null, or with having an array that is never examined, and so it is supported.

Referenced by core::graph::ArrayPool< Real >::new_array().

template<class T>
void core::graph::ArrayPool< T >::deallocate_array ( ArrayPoolElement< T > const &  element)
inline

Free an ArrayPoolElement to the pool. The element is invalid after this call completes.

Referenced by core::scoring::EnergyGraph::deallocate_arraypoolelement().

template<class T>
bool core::graph::ArrayPool< T >::empty ( ) const
inline
template<class T>
platform::Size core::graph::ArrayPool< T >::footprint ( ) const
inline

Returns the number of bytes occupied by all allocated and not-yet allocated arrays.

Approximate the cost of each list element in the two std::lists as 4 times the cost of a pointer.

Referenced by core::scoring::EnergyGraph::count_dynamic_memory().

template<class T>
bool core::graph::ArrayPool< T >::mine ( NegSpaceElement< T > const *  neg_element) const
inlineprivate

Determine if a given pointer to a negative-space element belongs to this pool. The compiler cannot ensure that when a ArrayPoolElement is handed to the deallocate_array method that it belongs to the pool being invoked upon.

This method is too slow to include in release builds, but is here to ensure in debug mode that two pools don't accidentally start crossing their pointers and "sharing" data, since that would be disasterous.

Referenced by core::graph::ArrayPool< Real >::deallocate_array().

template<class T>
platform::Size core::graph::ArrayPool< T >::nallocated ( ) const
inline

Return the number of allocated arrays. If this were multiplied by the array_size_, then you'd have the amount of space spent representing the T arrays but you wouldn't have the amount of space spent representing the negative space linked list.

Referenced by core::graph::ArrayPool< Real >::deallocate_array(), core::graph::ArrayPool< Real >::empty(), and core::graph::ArrayPool< Real >::noutstanding().

template<class T>
platform::Size core::graph::ArrayPool< T >::nblocks ( ) const
inline

Return the number of allocated array blocks.

template<class T>
ArrayPoolElement< T > core::graph::ArrayPool< T >::new_array ( )
inline

Methods for allocating and deallocating arrays from this pool.

Request a new ArrayPoolElement from the pool. This method will enlarge the pool if it has grown to its capacity.

template<class T>
platform::Size core::graph::ArrayPool< T >::noutstanding ( ) const
inline

Return the number of allocated arrays that have been requested by the user and are now "outstanding" in that they have to be returned before the array pool may be deleted.

template<class T>
void core::graph::ArrayPool< T >::set_array_size ( platform::Size  size)
inline

Methods to modify the size of the pool.

Set the size of the arrays that the pool is meant to allocate.

The

Referenced by core::scoring::EnergyGraph::active_score_types().

template<class T>
void core::graph::ArrayPool< T >::set_block_size ( platform::Size  size)
inline

Member Data Documentation

template<class T>
std::list< T * > core::graph::ArrayPool< T >::array_blocks_
private
template<class T>
platform::Size core::graph::ArrayPool< T >::array_size_
private
template<class T>
platform::Size core::graph::ArrayPool< T >::block_size_
private
template<class T>
platform::Size core::graph::ArrayPool< T >::nblocks_
private
template<class T>
NegSpaceElement< T > core::graph::ArrayPool< T >::neg_begin_
private
template<class T>
std::list< NegSpaceElement< T > * > core::graph::ArrayPool< T >::neg_space_blocks_
private
template<class T>
platform::Size core::graph::ArrayPool< T >::nnegative_
private

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