MutDeque
Definitions
def
foldLeft
[baefr]
(
f :
b -> (a -> b \ ef)
s :
b
d :
MutDeque[a, r]
)
: b
\ ef + r
Applies f
to a start value s
and all elements in d
going from left to right.
That is, the result is of the form: f(...f(f(s, x1), x2)..., xn)
.
def
foldMap
[aefbr]
(
f :
a -> b \ ef
d :
MutDeque[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
d :
MutDeque[a, r]
)
: b
\ ef + r
Applies f
to a start value s
and all elements in d
going from right to left.
That is, the result is of the form: f(x1, ...f(xn-1, f(xn, s))...)
.
def
foldRightWithCont
[aefrb]
(
f :
a -> ((Unit -> b \ ef + r) -> b \ ef + r)
s :
b
d :
MutDeque[a, r]
)
: b
\ ef + r
Applies f
to a start value z
and all elements in d
going from right to left.
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
forEach
[aefr]
(
f :
a -> Unit \ ef
d :
MutDeque[a, r]
)
: Unit
\ ef + r
Apply the effectful function f
to all the elements in the MutDeque d
.
def
forEachWithIndex
[aefr]
(
f :
Int32 -> (a -> Unit \ ef)
d :
MutDeque[a, r]
)
: Unit
\ ef + r
Apply the effectful function f
to all the elements in the MutDeque d
along with that element's index.
def
isEmpty
[ar]
(
d :
MutDeque[a, r]
)
: Bool
\ r
Returns true
if d
is empty.
def
iterator
[r1ar2]
(
rc :
Region[r1]
d :
MutDeque[a, r2]
)
: Iterator[a, r1 + r2, r1]
\ r1 + r2
Returns an iterator over d
.
Modifying d
while using an iterator has undefined behavior and is dangerous.
def
join
[ar]
(
sep :
String
d :
MutDeque[a, r]
)
: String
\ r
with
ToString[a]
Returns the concatenation of the string representation
of each element in d
with sep
inserted between each element.
def
joinWith
[aefr]
(
f :
a -> String \ ef
sep :
String
d :
MutDeque[a, r]
)
: String
\ ef + r
Returns the concatenation of the string representation
of each element in d
according to f
with sep
inserted between each element.
def
new
[ra]
(
rc :
Region[r]
)
: MutDeque[a, r]
\ r
Returns an empty MutDeque.
def
peekBack
[ar]
(
d :
MutDeque[a, r]
)
: Option[a]
\ r
Optionally returns the back element. Does not remove it.
def
peekFront
[ar]
(
d :
MutDeque[a, r]
)
: Option[a]
\ r
Optionally returns the front element. Does not remove it.
def
popBack
[ar]
(
d :
MutDeque[a, r]
)
: Option[a]
\ r
Returns Some(x)
where x
is the element at the back. Returns None
if d
is empty.
def
popFront
[ar]
(
d :
MutDeque[a, r]
)
: Option[a]
\ r
Returns Some(x)
where x
is the element at the front. Returns None
if d
is empty.
def
pushBack
[ar]
(
x :
a
d :
MutDeque[a, r]
)
: Unit
\ r
Pushes x
to the back of d
.
def
pushFront
[ar]
(
x :
a
d :
MutDeque[a, r]
)
: Unit
\ r
Pushes x
to the front of d
.
def
sameElements
[tr1r2]
(
d1 :
MutDeque[t, r1]
d2 :
MutDeque[t, r2]
)
: Bool
\ r1 + r2
with
Eq[t]
Returns true
if MutDeque
s a
and b
have the same elements in the same order, i.e. are structurally equal.
def
shuffle
[r1ar2]
(
rc1 :
Region[r1]
rnd :
Random
d :
MutDeque[a, r2]
)
: MutDeque[a, r1]
\ IO
Shuffles a copy of d
using the Fisher–Yates shuffle.
def
size
[ar]
(
d :
MutDeque[a, r]
)
: Int32
\ r
Returns the number of elements in d
.
def
sum
[r]
(
d :
MutDeque[Int32, r]
)
: Int32
\ r
Returns the sum of all elements in the deque d
.
def
sumWith
[aefr]
(
f :
a -> Int32 \ ef
d :
MutDeque[a, r]
)
: Int32
\ ef + r
Returns the sum of all elements in the deque d
according to the function f
.
def
toArray
[r1ar2]
(
rc1 :
Region[r1]
d :
MutDeque[a, r2]
)
: Array[a, r1]
\ r2 + r1
Returns d
as an array.
def
toList
[ar]
(
d :
MutDeque[a, r]
)
: List[a]
\ r
Returns d
as a List
.
def
toString
[ar]
(
d :
MutDeque[a, r]
)
: String
\ r
with
ToString[a]
Returns a string representation of the given MutDeque d
.
def
toVector
[ar]
(
d :
MutDeque[a, r]
)
: Vector[a]
\ r
Returns d
as a vector.