View source code
Display the source code in std/array.d from which this page was generated on
github.
Improve this page
Quickly fork, edit online, and submit a pull request for this page.
Requires a signed-in GitHub account. This works well for small changes.
If you'd like to make larger changes you may want to consider using
local clone.
Page wiki
View or edit the community-maintained wiki page associated with this page.
Module std.array
Functions and types that manipulate built-in arrays and associative arrays.
This module provides all kinds of functions to create, manipulate or convert arrays:
Function Name | Description |
---|---|
array |
Returns a copy of the input in a newly allocated dynamic array. |
|
Returns a new Appender initialized with a given array.
|
|
Returns a newly allocated associative array from a range of key/value tuples. |
|
Construct a range iterating over an associative array by key/value tuples. |
|
Inserts into an existing array at a given position. |
|
Concatenates a range of ranges into one array. |
|
Returns a new array of type T .
|
|
Returns a new array with all occurrences of a certain subrange replaced. |
|
Returns a new array with the first occurrence of a certain subrange replaced. |
|
Replaces all occurrences of a certain subrange and puts the result into a given array. |
|
Replaces all occurrences of a certain subrange and puts the result into an output range. |
|
Returns a new array with the last occurrence of a certain subrange replaced. |
|
Returns a new array with a given slice replaced. |
|
Creates a new array out of several copies of an input array or range. |
|
Checks if the initial segments of two arrays refer to the same place in memory. |
|
Checks if the final segments of two arrays refer to the same place in memory. |
|
Eagerly split a range or string into an array.
|
|
Returns a new array of type T without initializing its elements.
|
Functions
Name | Description |
---|---|
appender
|
Convenience function that returns a object initialized
with . Don't use null for the pointer, use the other
version of instead.
|
appender
|
Convenience function that returns an object initialized
with .
|
array
|
Allocates an array and initializes it with copies of the elements
of range .
|
array
|
Convert a narrow string to an array type that fully supports random access.
This is handled as a special case and always returns a dchar[] ,
const(dchar)[] , or immutable(dchar)[] depending on the constness of
the input.
|
assocArray
|
Returns a newly allocated associative array from a range of key/value tuples. |
byPair
|
Construct a range iterating over an associative array by key/value tuples.
|
insertInPlace
|
Inserts (which must be an input range or any number of
implicitly convertible items) in at position .
|
join
|
Concatenates all of the ranges in together into one array using
as the separator if present.
|
minimallyInitializedArray
|
Returns a new array of type T allocated on the garbage collected heap.
|
replace
|
Replace occurrences of with in . Returns a new
array without changing the contents of , or the original array
if no match is found.
|
replace
|
Replaces elements from with indices ranging from
(inclusive) to (exclusive) with the range . Returns a new
array without changing the contents of .
|
replaceFirst
|
Replaces the first occurrence of with in a . Returns a
new array without changing the contents of , or the original
array if no match is found.
|
replaceInPlace
|
Replaces elements from with indices ranging from
(inclusive) to (exclusive) with the range . Expands or
shrinks the array as needed.
|
replaceInto
|
Same as above, but outputs the result via OutputRange .
If no match is found the original array is transferred to as is.
|
replaceLast
|
Replaces the last occurrence of with in a . Returns a
new array without changing the contents of , or the original
array if no match is found.
|
replaceSlice
|
Returns a new array that is with replaced by
.
|
replicate
|
Returns an array that consists of (which must be an input
range) repeated times. This function allocates, fills, and
returns a new array . For a lazy version, refer to std.range.repeat.
|
sameHead
|
Returns whether the front s of and both refer to the
same place in memory, making one of the arrays a slice of the other which
starts at index 0 .
|
sameTail
|
Returns whether the back s of and both refer to the
same place in memory, making one of the arrays a slice of the other which
end at index $ .
|
split
|
Eagerly split the string into an array of words, using whitespace as
delimiter. Runs of whitespace are merged together (no empty words are produced).
|
split
|
Eagerly splits into an array , using as the delimiter.
|
uninitializedArray
|
Returns a new array of type T allocated on the garbage collected heap
without initializing its elements. This can be a useful optimization if every
element will be immediately initialized. T may be a multidimensional
array . In this case sizes may be specified for any number of dimensions from 0
to the number in T .
|
uninitializedArray
|
Structs
Name | Description |
---|---|
Appender
|
Implements an output range that appends data to an array . This is
recommended over a ~= when appending many elements because it is more
efficient.
|
RefAppender
|
An appender that can update an array in-place. It forwards all calls to an
underlying appender implementation. Any calls made to the appender also update
the pointer to the original array passed in.
|
Aliases
Name | Type | Description |
---|---|---|
splitter
|
Alias for std.algorithm.iteration.splitter. |
Authors
Andrei Alexandrescu and Jonathan M Davis