InDesign SDK  20.5
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
K2Allocator< T > Class Template Reference

#include <K2Allocator.h>

Classes

struct  rebind
 

Public Types

typedef uint32 size_type
 
typedef std::ptrdiff_t difference_type
 
typedef T * pointer
 
typedef const T * const_pointer
 
typedef T & reference
 
typedef const T & const_reference
 
typedef T value_type
 

Public Member Functions

 K2Allocator ()
 
template<class U >
 K2Allocator (const K2Allocator< U > &)
 
pointer address (reference x) const
 
const_pointer address (const_reference x) const
 
pointer allocate (size_type n, const void *hint=nil)
 
void deallocate (pointer p, size_type)
 
size_type max_size () const
 
void construct (pointer p, const T &val)
 
void destroy (pointer p)
 

Detailed Description

template<class T>
class K2Allocator< T >

Allocators represent a special memory model and are an abstraction used to translate the need to use memory into a raw call for memory. K2Allocator is the default allocator used by the new K2 collections (like K2Vector). This class would be deprecated soon along with the other K2 containers.

Constructor & Destructor Documentation

template<class T>
K2Allocator< T >::K2Allocator()
inline

Default constructor. Creates an empty allocator.

Member Function Documentation

template<class T>
pointer K2Allocator< T >::address (reference x) const
inline

Returns address of values.

Parameters
x[IN] - a value.
Returns
the address of the specified value.
template<class T >
K2Allocator< T >::pointer K2Allocator< T >::allocate (size_type n,
const void * hint = nil 
)
inline

Allocates but doesn't initialize n elements of type T.

Parameters
n[IN] - number of element of type T to allocate space for.
hint[IN] - not used.
template<class T>
void K2Allocator< T >::construct (pointer p,
const T & val 
)
inline

Initializes the storage of one element to which p refers with value.

Parameters
p[IN] - pointer to the storage.
val[IN] - value for initialization.
template<class T>
void K2Allocator< T >::deallocate (pointer p,
size_type  
)
inline

Frees the storage to which p refers. The storage p has to be allocated by allocate() of the same or an equal allocator. The elements should have been destroyed already.

Parameters
p[IN] - pointer to the storage to be freed.
template<class T>
void K2Allocator< T >::destroy (pointer p)
inline

Destroys the object to which p refers without deallocating the storage. Simply calls the destructor for the object.

Parameters
p[IN] - pointer to the object.
template<class T>
size_type K2Allocator< T >::max_size () const
inline

Returns the maximum number of elements that can be allocated.

Returns
the maximum number of elements that can be allocated.