class Array<T>
Available on all platforms
Sub classes | ||||
![]() | RegExpMatch |
|
An Array is a storage for values. You can access it using indexes or with its API.
Instance Fields
function concat(a:Array<T>):Array<T>
Returns a new Array by appending the elements of a
to the elements of
this
Array.
This operation does not modify this
Array.
If a
is the empty Array []
, a copy of this
Array is returned.
The length of the returned Array is equal to the sum of this.length
and a.length
.
If a
is null
, the result is unspecified.
function join(sep:String):String
Returns a string representation of this
Array, with sep
separating
each element.
The result of this operation is equal to Std.string(this[0]) + sep +
Std.string(this[1]) + sep + ... + sep + Std.string(this[this.length-1])
If this
is the empty Array []
, the result is the empty String ""
.
If this
has exactly one element, the result is equal to a call to
Std.string(this[0])
.
If sep
is null, the result is unspecified.
Removes the last element of this
Array and returns it.
This operation modifies this
Array in place.
If this
has at least one element, this.length
will decrease by 1.
If this
is the empty Array []
, null is returned and the length
remains 0.
Adds the element x
at the end of this
Array and returns the new
length of this
Array.
This operation modifies this
Array in place.
this.length
increases by 1.
Removes the first element of this
Array and returns it.
This operation modifies this
Array in place.
If this
has at least one element, this
.length and the index of each
remaining element is decreased by 1.
If this
is the empty Array []
, null
is returned and the length
remains 0.
function slice(pos:Int, ?end:Int):Array<T>
Creates a shallow copy of the range of this
Array, starting at and
including pos
, up to but not including end
.
This operation does not modify this
Array.
The elements are not copied and retain their identity.
If end
is omitted or exceeds this.length
, it defaults to the end of
this
Array.
If pos
or end
are negative, their offsets are calculated from the
end of this
Array by this.length + pos
and this.length + end
respectively. If this yields a negative value, 0 is used instead.
If pos
exceeds this.length
or if end
exceeds or equals pos
,
the result is []
.
function sort(f:T ->T ->Int):Void
Sorts this
Array according to the comparison function f
, where
f(x,y)
returns 0 if x == y, a positive Int if x > y and a
negative Int if x < y.
This operation modifies this
Array in place.
The sort operation is not guaranteed to be stable, which means that the
order of equal elements may not be retained. For a stable Array sorting
algorithm, haxe.ds.ArraySort.sort()
can be used instead.
If f
is null, the result is unspecified.
function splice(pos:Int, len:Int):Array<T>
Removes len
elements from this
Array, starting at and including
pos
, an returns them.
This operation modifies this
Array in place.
If len
is < 0 or pos
exceeds this
.length, the result is the empty
Array [].
If pos
is negative, its value is calculated from the end of this
Array by this.length + pos
. If this yields a negative value, 0 is
used instead.
If the sum of the resulting values for len
and pos
exceed
this.length
, this operation will affect the elements from pos
to the
end of this
Array.
The length of the returned Array is equal to the new length of this
Array subtracted from the original length of this
Array. In other
words, each element of the original this
Array either remains in
this
Array or becomes an element of the returned Array.