Ion
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
ion::base::Array2< T > Class Template Reference

Simple rectangular 2D array class with range-checked indexing, templatized by the element type. More...

#include "array2.h"

Inheritance diagram for ion::base::Array2< T >:
Collaboration diagram for ion::base::Array2< T >:

Public Member Functions

 Array2 ()
 The default constructor creates an empty (0x0) array. More...
 
 Array2 (size_t width, size_t height)
 Constructor that creates an array of specified size with undefined elements. More...
 
 Array2 (size_t width, size_t height, const T &initial_value)
 Constructor that creates an array of specified size with elements all set to initial_value. More...
 
 ~Array2 () override
 
size_t GetWidth () const
 
size_t GetHeight () const
 
size_t GetSize () const
 
bool Set (size_t column, size_t row, const T &val)
 Sets one element of the array. More...
 
const TGet (size_t column, size_t row) const
 Returns the indexed element of the array. More...
 
TGetMutable (size_t column, size_t row)
 Returns a pointer the indexed element of the array. More...
 
const AllocatorPtrGetAllocator () const
 Returns the Allocator that was used for the instance. More...
 
const AllocatorPtrGetNonNullAllocator () const
 Return our allocator, or the default allocator if the instance was declared on the stack. More...
 
const AllocatorPtrGetAllocatorForLifetime (AllocationLifetime lifetime) const
 Convenience function that returns the Allocator to use to allocate an object with a specific lifetime. More...
 
void * operator new (size_t size)
 The standard no-parameter new operator uses the default Allocator. More...
 
void * operator new (size_t size, AllocationLifetime lifetime)
 This overloaded version of the new operator uses the AllocationManager's default Allocator for the specified lifetime. More...
 
void * operator new (size_t size, const AllocatorPtr &allocator)
 This overloaded version of the new operator takes the Allocator to use directly as a parameter. More...
 
void * operator new (size_t size, const AllocatorPtr &allocator, void *ptr)
 Special operator new for using placement new with Allocatables. More...
 
void * operator new (size_t size, void *ptr)
 The placement new operator is defined conventionally. More...
 
void operator delete (void *ptr)
 Define the delete operator to use specialized functions dealing with an Allocator. More...
 
void operator delete (void *ptr, AllocationLifetime lifetime)
 Windows requires these (or it issues C4291 warnings). More...
 
void operator delete (void *ptr, const AllocatorPtr &allocator)
 
void operator delete (void *ptr, void *ptr2)
 The placement delete operator does nothing, as usual. More...
 

Detailed Description

template<typename T>
class ion::base::Array2< T >

Simple rectangular 2D array class with range-checked indexing, templatized by the element type.

Definition at line 31 of file array2.h.

Constructor & Destructor Documentation

template<typename T>
ion::base::Array2< T >::Array2 ( )
inline

The default constructor creates an empty (0x0) array.

Definition at line 34 of file array2.h.

template<typename T>
ion::base::Array2< T >::Array2 ( size_t  width,
size_t  height 
)
inline

Constructor that creates an array of specified size with undefined elements.

Definition at line 38 of file array2.h.

template<typename T>
ion::base::Array2< T >::Array2 ( size_t  width,
size_t  height,
const T initial_value 
)
inline

Constructor that creates an array of specified size with elements all set to initial_value.

Definition at line 45 of file array2.h.

template<typename T>
ion::base::Array2< T >::~Array2 ( )
inlineoverride

Definition at line 51 of file array2.h.

Member Function Documentation

template<typename T>
const T& ion::base::Array2< T >::Get ( size_t  column,
size_t  row 
) const
inline

Returns the indexed element of the array.

Logs an error message and returns an invalid reference if the indices are not valid.

Definition at line 71 of file array2.h.

const AllocatorPtr& ion::base::Allocatable::GetAllocator ( ) const
inlineinherited

Returns the Allocator that was used for the instance.

This will be NULL if the instance was declared on the stack or created with normal placement new.

Definition at line 68 of file allocatable.h.

References allocator_.

Referenced by ion::base::DataContainer::CreateAndCopy(), ion::text::DynamicFontImage::FindContainingImageDataIndex(), and ion::text::DynamicFontImage::FindImageDataIndex().

template<typename T>
size_t ion::base::Array2< T >::GetHeight ( ) const
inline

Definition at line 54 of file array2.h.

template<typename T>
T* ion::base::Array2< T >::GetMutable ( size_t  column,
size_t  row 
)
inline

Returns a pointer the indexed element of the array.

Logs an error message and returns a NULL pointer if the indices are not valid.

Definition at line 79 of file array2.h.

const AllocatorPtr& ion::base::Allocatable::GetNonNullAllocator ( ) const
inlineinherited

Return our allocator, or the default allocator if the instance was declared on the stack.

Definition at line 72 of file allocatable.h.

References allocator_, and ion::base::AllocationManager::GetNonNullAllocator().

template<typename T>
size_t ion::base::Array2< T >::GetSize ( ) const
inline

Definition at line 55 of file array2.h.

template<typename T>
size_t ion::base::Array2< T >::GetWidth ( ) const
inline

Definition at line 53 of file array2.h.

void ion::base::Allocatable::operator delete ( void *  ptr)
inlineinherited

Define the delete operator to use specialized functions dealing with an Allocator.

Definition at line 109 of file allocatable.h.

void ion::base::Allocatable::operator delete ( void *  ptr,
AllocationLifetime  lifetime 
)
inlineinherited

Windows requires these (or it issues C4291 warnings).

Definition at line 112 of file allocatable.h.

void ion::base::Allocatable::operator delete ( void *  ptr,
const AllocatorPtr allocator 
)
inlineinherited

Definition at line 113 of file allocatable.h.

void ion::base::Allocatable::operator delete ( void *  ptr,
void *  ptr2 
)
inlineinherited

The placement delete operator does nothing, as usual.

Definition at line 118 of file allocatable.h.

void* ion::base::Allocatable::operator new ( size_t  size)
inlineinherited

The standard no-parameter new operator uses the default Allocator.

Definition at line 84 of file allocatable.h.

void* ion::base::Allocatable::operator new ( size_t  size,
AllocationLifetime  lifetime 
)
inlineinherited

This overloaded version of the new operator uses the AllocationManager's default Allocator for the specified lifetime.

Definition at line 88 of file allocatable.h.

void* ion::base::Allocatable::operator new ( size_t  size,
const AllocatorPtr allocator 
)
inlineinherited

This overloaded version of the new operator takes the Allocator to use directly as a parameter.

If the Allocator pointer is NULL, this uses the default Allocator.

Definition at line 95 of file allocatable.h.

void* ion::base::Allocatable::operator new ( size_t  size,
const AllocatorPtr allocator,
void *  ptr 
)
inlineinherited

Special operator new for using placement new with Allocatables.

Definition at line 100 of file allocatable.h.

void* ion::base::Allocatable::operator new ( size_t  size,
void *  ptr 
)
inlineinherited

The placement new operator is defined conventionally.

Definition at line 105 of file allocatable.h.

template<typename T>
bool ion::base::Array2< T >::Set ( size_t  column,
size_t  row,
const T val 
)
inline

Sets one element of the array.

Does nothing but log an error message and return false if the indices are not valid.

Definition at line 59 of file array2.h.


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