SheafSystem  0.0.0.0
sheaf::ptr_linked_pool< T > Class Template Reference

A reallocatable pool of objects of type T. Objects in the pool are either "allocated" or linked together via pointers into a "free" list. Intended to support efficient allocation and deallocation of nodes in a graph or other dynamic data structure. There is an implicit constraint on T: it must have a next() feature. More...

#include <ptr_linked_pool.h>

Public Member Functions

size_t capacity () const
 The number of objects, either free or allocated, currently in the pool. More...
 
size_t free_size () const
 The size of free list. More...
 
size_t allocated_size () const
 The size of allocated list. More...
 
void reserve (size_t xcapacity)
 Makes capacity at least xcapacity. More...
 
void clear ()
 Deletes all the objects in the pool. More...
 
T * allocate ()
 Allocate next available object from the free list. More...
 
void deallocate (T *xobject)
 Deallocate xobject. More...
 
void print () const
 Prints the data members of this on cout. Intended for use debugging. More...
 
void print (std::ostream &xos) const
 Prints the data members of this on output stream xos. Intended for use debugging. More...
 
 ptr_linked_pool (size_t xcapacity=1024)
 Creates an instance with capacity xcapacity. More...
 
 ~ptr_linked_pool ()
 Destructor. More...
 

Detailed Description

template<typename T>
class sheaf::ptr_linked_pool< T >

A reallocatable pool of objects of type T. Objects in the pool are either "allocated" or linked together via pointers into a "free" list. Intended to support efficient allocation and deallocation of nodes in a graph or other dynamic data structure. There is an implicit constraint on T: it must have a next() feature.

Definition at line 42 of file d_tree_point_locator_node.h.

Constructor & Destructor Documentation

◆ ptr_linked_pool()

template<typename T >
sheaf::ptr_linked_pool< T >::ptr_linked_pool ( size_t  xcapacity = 1024)

Creates an instance with capacity xcapacity.

Postcondition

Definition at line 195 of file ptr_linked_pool.impl.h.

Referenced by sheaf::ptr_linked_pool< geometry::d_tree_point_locator_node< DC, DB > >::print().

◆ ~ptr_linked_pool()

Member Function Documentation

◆ allocate()

template<typename T >
T * sheaf::ptr_linked_pool< T >::allocate ( )

Allocate next available object from the free list.

Postcondition
  • result !=0

Definition at line 78 of file ptr_linked_pool.impl.h.

Referenced by sheaf::ptr_linked_pool< geometry::d_tree_point_locator_node< DC, DB > >::free_size(), and geometry::d_tree_point_locator_node< DC, DB >::insert_box().

◆ allocated_size()

template<typename T >
size_t sheaf::ptr_linked_pool< T >::allocated_size ( ) const

The size of allocated list.

Definition at line 60 of file ptr_linked_pool.impl.h.

Referenced by sheaf::ptr_linked_pool< geometry::d_tree_point_locator_node< DC, DB > >::capacity().

◆ capacity()

template<typename T >
size_t sheaf::ptr_linked_pool< T >::capacity ( ) const

The number of objects, either free or allocated, currently in the pool.

Definition at line 50 of file ptr_linked_pool.impl.h.

◆ clear()

template<typename T >
void sheaf::ptr_linked_pool< T >::clear ( )

Deletes all the objects in the pool.

Postcondition

Definition at line 309 of file ptr_linked_pool.impl.h.

Referenced by sheaf::ptr_linked_pool< geometry::d_tree_point_locator_node< DC, DB > >::reserve().

◆ deallocate()

template<typename T>
void sheaf::ptr_linked_pool< T >::deallocate ( T *  xobject)

Deallocate xobject.

Precondition
  • xobject != 0
  • -unexecutable( "xobject is allocated" )
Postcondition

Definition at line 118 of file ptr_linked_pool.impl.h.

Referenced by sheaf::ptr_linked_pool< geometry::d_tree_point_locator_node< DC, DB > >::allocate().

◆ free_size()

template<typename T >
size_t sheaf::ptr_linked_pool< T >::free_size ( ) const

◆ print() [1/2]

template<typename T >
void sheaf::ptr_linked_pool< T >::print ( ) const

◆ print() [2/2]

template<typename T >
void sheaf::ptr_linked_pool< T >::print ( std::ostream &  xos) const

Prints the data members of this on output stream xos. Intended for use debugging.

Definition at line 155 of file ptr_linked_pool.impl.h.

◆ reserve()

template<typename T >
void sheaf::ptr_linked_pool< T >::reserve ( size_t  xcapacity)

Makes capacity at least xcapacity.

Precondition
  • xcapacity > 0
Postcondition

Definition at line 228 of file ptr_linked_pool.impl.h.

Referenced by sheaf::ptr_linked_pool< geometry::d_tree_point_locator_node< DC, DB > >::~ptr_linked_pool().


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