Function resizeArray

bool resizeArray(T) (
  Allocator allocator,
  ref T[] array,
  in size_t length
);

Parameters

NameDescription
T Element type of the array being created.
allocator The allocator used for getting memory.
array A reference to the array being changed.
length New array length.

Returns

true upon success, false if memory could not be reallocated. In the latter

Example

int[] p;

defaultAllocator.resizeArray(p, 20);
assert(p.length == 20);

defaultAllocator.resizeArray(p, 30);
assert(p.length == 30);

defaultAllocator.resizeArray(p, 10);
assert(p.length == 10);

defaultAllocator.resizeArray(p, 0);
assert(p is null);