A* Pathfinding Project  4.0.8
The A* Pathfinding Project for Unity 3D
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Properties Events Macros Groups Pages
Memory Class Reference

Various utilities for handling arrays and memory. More...

Detailed Description

Various utilities for handling arrays and memory.

Static Public Member Functions

static void MemSet< T > (T[] array, T value, int byteSize)
 Sets all values in an array to a specific value faster than a loop.
 
static void MemSet< T > (T[] array, T value, int totalSize, int byteSize)
 Sets all values in an array to a specific value faster than a loop.
 
static T[] ShrinkArray< T > (T[] arr, int newLength)
 Returns a new array with at most length newLength.
 

Member Function Documentation

static void MemSet< T > ( T[]  array,
value,
int  byteSize 
)
static

Sets all values in an array to a specific value faster than a loop.

Only faster for large arrays. Slower for small ones. Tests indicate it becomes faster somewhere when the length of the array grows above around 100. For large arrays this can be magnitudes faster. Up to 40 times faster has been measured.

Note
Only works on primitive value types such as int, long, float, etc.
Parameters
arraythe array to fill
valuethe value to fill the array with
byteSizesize in bytes of every element in the array. e.g 4 bytes for an int, or 8 bytes for a long. It can be efficiently got using the sizeof built-in function.
//Set all values to 8 in the array
int[] arr = new int[20000];
Pathfinding.Util.Memory.MemSet<int> (arr, 8, sizeof(int));
See Also
System.Buffer.BlockCopy
Type Constraints
T :struct 
static void MemSet< T > ( T[]  array,
value,
int  totalSize,
int  byteSize 
)
static

Sets all values in an array to a specific value faster than a loop.

Only faster for large arrays. Slower for small ones. Tests indicate it becomes faster somewhere when the length of the array grows above around 100. For large arrays this can be magnitudes faster. Up to 40 times faster has been measured.

Note
Only works on primitive value types such as int, long, float, etc.
Parameters
arraythe array to fill
valuethe value to fill the array with
byteSizesize in bytes of every element in the array. e.g 4 bytes for an int, or 8 bytes for a long.
totalSizeall indices in the range [0, totalSize-1] will be set

It can be efficiently got using the sizeof built-in function.

//Set all values to 8 in the array
int[] arr = new int[20000];
Pathfinding.Util.Memory.MemSet<int> (arr, 8, sizeof(int));
See Also
System.Buffer.BlockCopy
Type Constraints
T :struct 
static T [] ShrinkArray< T > ( T[]  arr,
int  newLength 
)
static

Returns a new array with at most length newLength.

The array will contain a copy of all elements of arr up to but excluding the index newLength.


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