nw::ut::MoveArray Class

Syntax

template <typename TElement>
class MoveArray

Template Arguments

Name Description
TElement The array element type.

Description

Class for wrapping an array so it can be used like an STL vector.

The purpose is to safely use the array. This class is implemented to realize move semantics. Special implementations are used for copying and assigning. Ownership is moved rather than copying resources being managed.

One of the following three operational states will result at time of creation.

1. A fixed-length array whose size cannot be changed
2. A variable length array whose size is automatically extended by push_back and other such operations
3. An invalid state without an array

The instance of the ownership source is put into one of the state 3 above after ownership is moved. Instances created using the default constructor also result in state 3. If an instance in this state is coded in an if statement, false is returned. If instances in state 1 or 2 are coded in a conditional statement, true is returned.

State 2 above can be disabled by disabling the definition of "NW_MOVE_ARRAY_VARIABILITY_ENABLED" in the header "nw/ut/ut_Config.h".

typedef Definitions

reference Element reference.
difference_type Element difference.
value_type The type of this class's elements.
iterator Element iterator type.
const_iterator Element const iterator type.
reverse_iterator Element reverse iterator type.
const_reverse_iterator Element const reverse iterator type.

Member Constants

S MEMORY_ALIGNMENT const size_t

Member Variables

protected m_Allocator os::IAllocator *
protected m_Elements TElement *
protected m_End TElement *

Member Functions

Arrays and Memory Operations
reserve Reserves memory for the specified number of elements. GetArrayKind() only works when ARRAY_VARIABILITY is defined. Returns false if the requested size cannot be reserved. Memory reserved using reserve cannot be trimmed. Use shrink_to_fit in such cases.
push_back Adds an element to the end. Returns false in the return value if the element could not be added.
pop_back Destroys the last element.
assign Pads the specified number of elements with the argument element. Returns false in the return value if all elements could not be added.
swap Swaps array contents.
resize Changes the size. Returns false in the return value if the specified size could not be made.
erase Erases elements after the specified iterator.
clear Calls a destructor for all elements and sets the number of elements to 0. Allocated memory is not freed.
erase_find Searches for elements having the same value as the argument and deletes them.
erase_if Searches for elements meeting specified conditions and deletes them.
ShrinkToFit Trims reserved memory to match the current number of elements.
GetArrayKind Gets the type of array for which memory was allocated.
GetAllocator Gets an allocator.
Aliasing conforms to NintendoWare coding rules.
Size Gets the array size.
Begin Gets an iterator to the start element.
END Gets an iterator to the last element.
RBegin Gets a reverse iterator to the start element.
REnd Gets a reverse iterator to the last element.
Front Gets the array size.
Back Gets a reference to the last element.
Empty Gets a flag indicating if there are any elements. Note this does not mean whether or not there is allocated memory.
Capacity Gets the number of elements of memory that have been allocated.
Reserve Reserves memory for the specified number of elements.
PushBack Adds an element to the end.
PopBack Destroys the last element.
Assign Pads the specified number of elements with the argument element.
Swap Swaps array contents.
Resize Changes the size.
Erase Erases elements after the specified iterator.
Clear Calls a destructor for all elements and sets the number of elements to 0. Allocated memory is not freed.
EraseFind Searches for elements having the same value as the argument and deletes them.
EraseIf Searches for elements meeting specified conditions and deletes them.
For optimization
PushBackFast A fast version of push_back.
Other
MoveArray Constructor.
~MoveArray Destructor.
operator SafeBool Returns true if a valid array is owned.
operator= Assignment operator definition.
Elements Externally public accessor just for reading arrays.
operator[] Post-fix operator definition.
release Releases ownership of internal array memory.
Reset Resets the array to manage MoveArray.
size Gets the array size.
begin Gets an iterator to the start element.
end Gets an iterator to the last element.
rbegin Gets a reverse iterator to the start element.
rend Gets a reverse iterator to the last element.
front Gets a reference to the first element.
back Gets a reference to the last element.
empty Gets a flag indicating if there are any elements. Note this does not mean whether or not there is allocated memory.
capacity Gets the number of elements of memory that have been allocated.
CopyFrom Copies an array.
protected SetArrayKind Sets the array type.
protected SetCapacity Sets the number of allocations.
protected GetCapacity Gets the number of allocations.

See Also

nw::ut::ArrayKind


CONFIDENTIAL