MutList
Definitions
def
append!
[mar]
(
m :
m[a]
v :
MutList[a, r]
)
: Unit
\ r
with
Foldable[m]
Appends m to v i.e. inserts all elements from m into the end of v.
def
clear!
[ar]
(
v :
MutList[a, r]
)
: Unit
\ r
Removes all elements from the given mutable list v.
def
compress!
[ar]
(
v :
MutList[a, r]
)
: Unit
\ r
Compresses the given mutable list v if needed.
The mutable list will be shrunk to 1/2 of its size if the load factor is less than 1/4.
def
copy
[r1ar]
(
rc1 :
Region[r1]
v :
MutList[a, r]
)
: MutList[a, r1]
\ r + r1
Returns a shallow copy of the given mutable list v.
The capacity of the copy is equal to the length of the list.
def
count
[aefr]
(
f :
a -> Bool \ ef
v :
MutList[a, r]
)
: Int32
\ ef + r
Returns the number of elements in the given mutable list v that satisfies the given predicate f.
Returns 0 if the given mutable list v is empty.
def
exists
[aefr]
(
f :
a -> Bool \ ef
v :
MutList[a, r]
)
: Bool
\ ef + r
Returns true if the given predicate f holds for at least one element of the given mutable list v.
Returns false if the given mutable list v is empty.
def
find
[ar]
(
f :
a -> Bool
v :
MutList[a, r]
)
: Option[a]
\ r
Alias for findLeft.
def
findLeft
[ar]
(
f :
a -> Bool
v :
MutList[a, r]
)
: Option[a]
\ r
Optionally returns the left-most element in the given mutable list v that satisfies the given predicate f.
Returns None if no element satisfies the given predicate f.
Returns None if the given mutable list v is empty.
def
findRight
[ar]
(
f :
a -> Bool
v :
MutList[a, r]
)
: Option[a]
\ r
Optionally returns the right-most element in the given mutable list v that satisfies the given predicate f.
Returns None if no element satisfies the given predicate f.
Returns None if the given mutable list v is empty.
def
foldLeft
[baefr]
(
f :
b -> (a -> b \ ef)
s :
b
v :
MutList[a, r]
)
: b
\ ef + r
Applies f to a start value s and all elements in a going from left to right.
That is, the result is of the form: f(...f(f(s, a[0]), a[1])..., xn).
def
foldMap
[aefbr]
(
f :
a -> b \ ef
v :
MutList[a, r]
)
: b
\ ef + r
with
Monoid[b]
Returns the result of mapping each element and combining the results.
def
foldRight
[abefr]
(
f :
a -> (b -> b \ ef)
s :
b
v :
MutList[a, r]
)
: b
\ ef + r
Applies f to a start value s and all elements in a going from left to right.
That is, the result is of the form: f(...f(f(s, a[0]), a[1])..., xn).
The implementation is tail recursive.
def
foldRightWithCont
[aefrb]
(
f :
a -> ((Unit -> b \ ef + r) -> b \ ef + r)
z :
b
v :
MutList[a, r]
)
: b
\ ef + r
Applies f to a start value z and all elements in a going from left to right.
That is, the result is of the form: f(x1, ...f(xn-1, f(xn, z))...).
A foldRightWithCont allows early termination by not calling the continuation.
def
forAll
[aefr]
(
f :
a -> Bool \ ef
v :
MutList[a, r]
)
: Bool
\ ef + r
Returns true if the given predicate f holds for all elements of the given mutable list v.
Returns true if the given mutable list v is empty.
def
forEach
[aefr]
(
f :
a -> Unit \ ef
v :
MutList[a, r]
)
: Unit
\ ef + r
Applies f to all the elements in v.
def
forEachWithIndex
[aefr]
(
f :
Int32 -> (a -> Unit \ ef)
v :
MutList[a, r]
)
: Unit
\ ef + r
Applies f to all the elements in v along with that element's index.
def
head
[ar]
(
v :
MutList[a, r]
)
: Option[a]
\ r
Optionally returns the first element of the given mutable list v.
Returns None if the given mutable list v is empty.
def
indexOf
[ar]
(
x :
a
v :
MutList[a, r]
)
: Option[Int32]
\ r
with
Eq[a]
Alias for IndexOfLeft
def
indexOfLeft
[ar]
(
x :
a
v :
MutList[a, r]
)
: Option[Int32]
\ r
with
Eq[a]
Optionally returns the position of the first occurrence of x in v
searching from left to right.
def
indexOfRight
[ar]
(
x :
a
v :
MutList[a, r]
)
: Option[Int32]
\ r
with
Eq[a]
Optionally returns the position of the first occurrence of x in v
searching from right to left.
def
insert!
[ar]
(
x :
a
i :
Int32
v :
MutList[a, r]
)
: Unit
\ r
Inserts the given element x at the given position i in the given mutable list v.
Shifts elements as necessary. Possibly expensive operation.
If the given index i exceeds the length of the mutable list, the element is inserted at the last position.
def
isEmpty
[ar]
(
v :
MutList[a, r]
)
: Bool
\ r
Returns true if the given mutable list v is empty.
def
iterator
[r1ar2]
(
rc :
Region[r1]
l :
MutList[a, r2]
)
: Iterator[a, r1 + r2, r1]
\ r1 + r2
Returns an iterator over l.
Modifying l while using an iterator has undefined behavior and is dangerous.
def
join
[ar]
(
sep :
String
v :
MutList[a, r]
)
: String
\ r
with
ToString[a]
Returns the concatenation of the string representation
of each element in v with sep inserted between each element.
def
joinWith
[aefr]
(
f :
a -> String \ ef
sep :
String
v :
MutList[a, r]
)
: String
\ ef + r
Returns the concatenation of the string representation
of each element in v according to f with sep inserted between each element.
def
last
[ar]
(
v :
MutList[a, r]
)
: Option[a]
\ r
Optionally returns the last element of the given mutable list v.
Returns None if the given mutable list v is empty.
def
length
[ar]
(
v :
MutList[a, r]
)
: Int32
\ r
Returns the number of elements in the given mutable list v.
def
map
[r1aefbr]
(
rc1 :
Region[r1]
f :
a -> b \ ef
v :
MutList[a, r]
)
: MutList[b, r1]
\ ef + r + r1
Apply f to every element in v.
The result is a new mutable list.
def
mapWithIndex
[r1aefbr]
(
rc1 :
Region[r1]
f :
Int32 -> (a -> b \ ef)
v :
MutList[a, r]
)
: MutList[b, r1]
\ ef + r + r1
Returns the result of applying f to every element in v along with that element's index.
def
maximum
[ar]
(
v :
MutList[a, r]
)
: Option[a]
\ r
with
Order[a]
Optionally finds the largest element of v according to the Order on a.
Returns None if v is empty.
def
maximumBy
[ar]
(
cmp :
a -> (a -> Comparison)
v :
MutList[a, r]
)
: Option[a]
\ r
Optionally finds the largest element of v according to the given comparator cmp.
Returns None if v is empty.
def
memberOf
[ar]
(
x :
a
v :
MutList[a, r]
)
: Bool
\ r
with
Eq[a]
Returns true if the given element x is a member of the given mutable list v.
def
minimum
[ar]
(
v :
MutList[a, r]
)
: Option[a]
\ r
with
Order[a]
Optionally finds the smallest element of v according to the Order on a.
Returns None if v is empty.
def
minimumBy
[ar]
(
cmp :
a -> (a -> Comparison)
v :
MutList[a, r]
)
: Option[a]
\ r
Optionally finds the smallest element of v according to the given comparator cmp.
Returns None if v is empty.
def
new
[ra]
(
rc :
Region[r]
)
: MutList[a, r]
\ r
Returns a new empty mutable list with a default capacity.
def
nth
[ar]
(
i :
Int32
v :
MutList[a, r]
)
: Option[a]
\ r
Optionally returns the element at position i in the mutable list v.
def
pop!
[ar]
(
v :
MutList[a, r]
)
: Option[a]
\ r
Optionally removes and returns the last element in the given mutable list v.
def
push!
[ar]
(
x :
a
v :
MutList[a, r]
)
: Unit
\ r
Inserts the given element x at the end of the given mutable list v.
def
pushAll!
[mar]
(
m :
m[a]
v :
MutList[a, r]
)
: Unit
\ r
with
Foldable[m]
Appends m to v i.e. inserts all elements from m into the end of v.
def
range
[r]
(
rc :
Region[r]
b :
Int32
e :
Int32
)
: MutList[Int32, r]
\ r
Returns a mutable list of all integers between b (inclusive) and e (exclusive).
Returns an empty mutable list if b >= e.
def
reduceLeft
[aefr]
(
f :
a -> (a -> a \ ef)
v :
MutList[a, r]
)
: Option[a]
\ ef + r
Applies f to all elements in v going from left to right until a single value v is obtained. Returns Some(v).
Returns None if v is empty.
def
reduceRight
[aefr]
(
f :
a -> (a -> a \ ef)
v :
MutList[a, r]
)
: Option[a]
\ ef + r
Applies f to all elements in v going from right to left until a single value v is obtained. Returns Some(v).
Returns None if v is empty.
def
remove!
[ar]
(
i :
Int32
v :
MutList[a, r]
)
: Unit
\ r
Removes the element at the given position i in the given mutable list v.
Shifts elements as necessary. Possibly expensive operation.
If the given index i exceeds the length of the mutable list, no element is removed.
def
replace!
[ar]
(
from :
{ from = a }
to :
{ to = a }
v :
MutList[a, r]
)
: Unit
\ r
with
Eq[a]
Replaces all occurrences of the from with to in the given mutable list v.
def
reserve!
[ar]
(
n :
Int32
v :
MutList[a, r]
)
: Unit
\ r
Increases the capacity of the given mutable list v by at least n.
That is, after the call, the mutable list is guaranteed to have space for at least n additional elements.
The content of the mutable list is unchanged.
def
retain!
[ar]
(
f :
a -> Bool
v :
MutList[a, r]
)
: Unit
\ r
Removes all elements from the given mutable list v that do not satisfy the given predicate f.
def
reverse!
[ar]
(
v :
MutList[a, r]
)
: Unit
\ r
Reverses the order of the elements in the given mutable list v.
def
sameElements
[ar1r2]
(
v1 :
MutList[a, r1]
v2 :
MutList[a, r2]
)
: Bool
\ r1 + r2
with
Eq[a]
Returns true if the mutable lists v1 and v2 have the same elements in the same order, i.e. are structurally equal.
def
scan
[r1baefr2]
(
rc1 :
Region[r1]
f :
b -> (a -> b \ ef)
s :
b
v :
MutList[a, r2]
)
: MutList[b, r1]
\ ef + r2 + r1
Alias for scanLeft.
def
scanLeft
[r1baefr2]
(
rc1 :
Region[r1]
f :
b -> (a -> b \ ef)
s :
b
v :
MutList[a, r2]
)
: MutList[b, r1]
\ ef + r2 + r1
Accumulates the result of applying f to v going left to right.
def
scanRight
[r1abefr2]
(
rc1 :
Region[r1]
f :
a -> (b -> b \ ef)
s :
b
v :
MutList[a, r2]
)
: MutList[b, r1]
\ ef + r2 + r1
Accumulates the result of applying f to v going right to left.
def
shrink!
[ar]
(
v :
MutList[a, r]
)
: Unit
\ r
Shrinks the given mutable list v to its actual size.
def
shuffle
[r1a]
(
rc1 :
Region[r1]
rnd :
Random
v :
MutList[a, r1]
)
: MutList[a, r1]
\ IO
Shuffles v using the Fisher–Yates shuffle.
def
sort
[r1ar]
(
rc1 :
Region[r1]
v :
MutList[a, r]
)
: MutList[a, r1]
\ r + r1
with
Order[a]
Returns a sorted copy of MutList v, where the elements are ordered from low to high according to
their Order instance.
The sort is not stable, i.e., equal elements may appear in a different order than in the input v.
The sort implementation is a Quicksort.
def
sort!
[ar]
(
v :
MutList[a, r]
)
: Unit
\ r
with
Order[a]
Sort MutList v so that elements are ordered from low to high according to their Order instance.
The MutList is mutated in-place.
The sort is not stable, i.e., equal elements may appear in a different order than in the input v.
The sort implementation is a Quicksort.
def
sortBy
[r1abr]
(
rc1 :
Region[r1]
f :
a -> b
v :
MutList[a, r]
)
: MutList[a, r1]
\ r + r1
with
Order[b]
Returns a sorted copy of MutList v, where the elements are ordered from low to high according to
the Order instance for the values obtained by applying f to each element.
The sort is not stable, i.e., equal elements may appear in a different order than in the input v.
The sort implementation is a Quicksort.
def
sortBy!
[abr]
(
f :
a -> b
v :
MutList[a, r]
)
: Unit
\ r
with
Order[b]
Sort MutList v so that elements are ordered from low to high according to the Order instance for
the values obtained by applying f to each element. The MutList is mutated in-place.
The sort is not stable, i.e., equal elements may appear in a different order than in the input v.
The sort implementation is a Quicksort.
def
sortWith
[r1ar]
(
rc1 :
Region[r1]
cmp :
a -> (a -> Comparison)
v :
MutList[a, r]
)
: MutList[a, r1]
\ r + r1
Returns a sorted copy of MutList v, where the elements are ordered from low to high according to
the comparison function cmp.
The sort is not stable, i.e., equal elements may appear in a different order than in the input v.
The sort implementation is a Quicksort.
def
sortWith!
[ar]
(
cmp :
a -> (a -> Comparison)
v :
MutList[a, r]
)
: Unit
\ r
Sort MutList v so that elements are ordered from low to high according to the comparison function cmp.
The MutList is mutated in-place.
The sort is not stable, i.e., equal elements may appear in a different order than in the input v.
The sort implementation is a Quicksort.
def
sum
[r]
(
v :
MutList[Int32, r]
)
: Int32
\ r
Returns the sum of all elements in the MutList v.
def
sumWith
[aefr]
(
f :
a -> Int32 \ ef
v :
MutList[a, r]
)
: Int32
\ ef + r
Returns the sum of all elements in the MutList v according to the function f.
def
toArray
[r1ar2]
(
rc1 :
Region[r1]
v :
MutList[a, r2]
)
: Array[a, r1]
\ r2 + r1
Returns v as an array.
def
toChain
[ar]
(
xs :
MutList[a, r]
)
: Chain[a]
\ r
Returns the mutable list xs as a chain.
def
toList
[ar]
(
v :
MutList[a, r]
)
: List[a]
\ r
Returns v as an immutable list.
def
toMutDeque
[r1ar2]
(
rc1 :
Region[r1]
v :
MutList[a, r2]
)
: MutDeque[a, r1]
\ r2 + r1
Returns v as a MutDeque.
def
toString
[ar]
(
l :
MutList[a, r]
)
: String
\ r
with
ToString[a]
Returns a string representation of the given MutList l.
def
toVector
[ar]
(
xs :
MutList[a, r]
)
: Vector[a]
\ r
Returns xs as a vector.
def
transform!
[ar]
(
f :
a -> a
v :
MutList[a, r]
)
: Unit
\ r
Apply f to every element in v.
def
transformWithIndex!
[ar]
(
f :
Int32 -> (a -> a)
v :
MutList[a, r]
)
: Unit
\ r
Apply f to every element in v along with that element's index.
def
truncate!
[ar]
(
l :
Int32
v :
MutList[a, r]
)
: Unit
\ r
Truncates the given mutable list v to the given length l.
That is, after the operation, the mutable list has length at most l.
If the given length l is negative, all elements are removed.