A non-empty map: an ordered, immutable, non-empty collection of key-value tuples with LinearSeq
performance characteristics.
The purpose of NonEmptyMap
is to allow you to express in a type that a Map
is non-empty, thereby eliminating the
need for (and potential exception from) a run-time check for non-emptiness. For a non-empty sequence with IndexedSeq
performance, see Every
.
== Constructing NonEmptyMap
s ==
You can construct a NonEmptyMap
by passing one or more elements to the NonEmptyMap.apply
factory method:
scala> NonEmptyMap(1 -> "one", 2 -> "two", 3 -> "three") res0: org.scalactic.anyvals.NonEmptyMap[Int, String] = NonEmptyMap(1 -> "one", 2 -> "two", 3 -> "three")
== Working with NonEmptyMap
s ==
NonEmptyMap
does not extend Scala's Map
or Traversable
traits because these require that
implementations may be empty. For example, if you invoke tail
on a Seq
that contains just one element,
you'll get an empty Seq
:
scala> Map(1 -> "one").tail res6: Map[Int] = Map()
On the other hand, many useful methods exist on Map
that when invoked on a non-empty Seq
are guaranteed
to not result in an empty Map
. For convenience, NonEmptyMap
defines a method corresponding to every such Map
method. Here are an example:
NonEmptyMap(1 -> "one", 2 -> "two", 3 -> "three").map(t => (t._1 + 1, t._2)) // Result: NonEmptyMap(2 -> "one", 3 -> "two", 4 -> "three")
NonEmptyMap
does not currently define any methods corresponding to Map
methods that could result in
an empty Map
. However, an implicit converison from NonEmptyMap
to Map
is defined in the NonEmptyMap
companion object that will be applied if you attempt to call one of the missing methods. As a
result, you can invoke filter
on an NonEmptyMap
, even though filter
could result
in an empty map—but the result type will be Map
instead of NonEmptyMap
:
NonEmptyMap(1 -> "one", 2 -> "two", 3 -> "three").filter(_._1 < 10) // Result: Map(1 -> "one", 2 -> "two", 3 -> "three") NonEmptyMap(1 -> "one", 2 -> "two", 3 -> "three").filter(_._ 1> 10) // Result: Map()
You can use NonEmptyMap
s in for
expressions. The result will be an NonEmptyMap
unless
you use a filter (an if
clause). Because filters are desugared to invocations of filter
, the
result type will switch to a Map
at that point. Here are some examples:
scala> import org.scalactic.anyvals._ import org.scalactic.anyvals._ scala> for ((i, j) <- NonEmptyMap(1 -> "one", 2 -> "two", 3 -> "three")) yield (i + 1, j) res0: org.scalactic.anyvals.NonEmptyMap[Int, String] = NonEmptyMap(2 -> "one", 3 -> "two", 4 -> "three") scala> for ((i, j) <- NonEmptyMap(1, 2, 3) if i < 10) yield (i + 1, j) res1: Map[Int, String] = Map(2 -> "one", 3 -> "two", 4 -> "three")
- Type parameters:
- K
the type of key contained in this
NonEmptyMap
- V
the type of value contained in this
NonEmptyMap
- Companion:
- object
- Source:
- NonEmptyMap.scala
Value members
Concrete methods
Returns a new NonEmptyMap
with the given entry added.
Returns a new NonEmptyMap
with the given entry added.
- Value parameters:
- entry
the entry to add to this
NonEmptyMap
- Returns:
a new
NonEmptyMap
consisting of all entries of thisNonEmptyMap
andentry
.- Source:
- NonEmptyMap.scala
Returns a new NonEmptyMap
with the given entries added.
Returns a new NonEmptyMap
with the given entries added.
- Value parameters:
- entries
the entries to add to this
NonEmptyMap
- Returns:
a new
NonEmptyMap
consisting of all entries of thisNonEmptyMap
andentries
.- Source:
- NonEmptyMap.scala
Returns a new NonEmptyMap
containing the entries of this NonEmptyMap
and the entries of the passed NonEmptyMap
.
The entry type of the resulting NonEmptyMap
is the most specific superclass encompassing the entry types of this and the passed NonEmptyMap
.
Returns a new NonEmptyMap
containing the entries of this NonEmptyMap
and the entries of the passed NonEmptyMap
.
The entry type of the resulting NonEmptyMap
is the most specific superclass encompassing the entry types of this and the passed NonEmptyMap
.
- Type parameters:
- V1
the value type of the returned
NonEmptyMap
- Value parameters:
- other
the
NonEmptyMap
to append
- Returns:
a new
NonEmptyMap
that contains all the elements of thisNonEmptyMap
and all elements ofother
.- Source:
- NonEmptyMap.scala
Returns a new NonEmptyMap
containing the entries of this NonEmptyMap
and the entries of the passed Every
.
The entry type of the resulting NonEmptyMap
is the most specific superclass encompassing the entry types of this NonEmptyMap
and the passed Every
.
Returns a new NonEmptyMap
containing the entries of this NonEmptyMap
and the entries of the passed Every
.
The entry type of the resulting NonEmptyMap
is the most specific superclass encompassing the entry types of this NonEmptyMap
and the passed Every
.
- Type parameters:
- V1
the value type of the returned
NonEmptyMap
- Value parameters:
- other
the
Every
to append
- Returns:
a new
NonEmptyMap
that contains all the entries of thisNonEmptyMap
and all elements ofother
.- Source:
- NonEmptyMap.scala
Returns a new NonEmptyMap
containing the entries of this NonEmptyMap
and the entries of the passed GenTraversableOnce
.
The entry type of the resulting NonEmptyMap
is the most specific superclass encompassing the entry types of this NonEmptyMap
and the passed GenTraversableOnce
.
Returns a new NonEmptyMap
containing the entries of this NonEmptyMap
and the entries of the passed GenTraversableOnce
.
The entry type of the resulting NonEmptyMap
is the most specific superclass encompassing the entry types of this NonEmptyMap
and the passed GenTraversableOnce
.
- Type parameters:
- V1
the value type of the returned
NonEmptyMap
- Value parameters:
- other
the
GenTraversableOnce
to append
- Returns:
a new
NonEmptyMap
that contains all the elements of thisNonEmptyMap
followed by all elements ofother
.- Source:
- NonEmptyMap.scala
As with ++
, returns a new NonEmptyMap
containing the entries of this NonEmptyMap
and the entries of the passed NonEmptyMap
.
The entry type of the resulting NonEmptyMap
is the most specific superclass encompassing the entry types of this and the passed NonEmptyMap
.
As with ++
, returns a new NonEmptyMap
containing the entries of this NonEmptyMap
and the entries of the passed NonEmptyMap
.
The entry type of the resulting NonEmptyMap
is the most specific superclass encompassing the entry types of this and the passed NonEmptyMap
.
It differs from ++
in that the right operand determines the type of the resulting collection rather than the left one. Mnemonic: the COLon is on the side of the new COLlection type.
- Type parameters:
- V1
the value type of the returned
NonEmptyMap
- Value parameters:
- other
the
NonEmptyMap
to add
- Returns:
a new
NonEmptyMap
that contains all the elements of thisNonEmptyMap
and all elements ofother
.- Source:
- NonEmptyMap.scala
As with ++
, returns a new NonEmptyMap
containing the entries of this NonEmptyMap
and the entries of the passed Every
.
The entry type of the resulting NonEmptyMap
is the most specific superclass encompassing the entry types of this NonEmptyMap
and the passed Every
.
As with ++
, returns a new NonEmptyMap
containing the entries of this NonEmptyMap
and the entries of the passed Every
.
The entry type of the resulting NonEmptyMap
is the most specific superclass encompassing the entry types of this NonEmptyMap
and the passed Every
.
It differs from ++
in that the right operand determines the type of the resulting collection rather than the left one. Mnemonic: the COLon is on the side of the new COLlection type.
- Type parameters:
- V1
the value type of the returned
NonEmptyMap
- Value parameters:
- other
the
Every
to append
- Returns:
a new
NonEmptyMap
that contains all the entries of thisNonEmptyMap
and all elements ofother
.- Source:
- NonEmptyMap.scala
Returns a new NonEmptyMap
containing the entries of this NonEmptyMap
and the entries of the passed GenTraversableOnce
.
The entry type of the resulting NonEmptyMap
is the most specific superclass encompassing the entry types of this NonEmptyMap
and the passed GenTraversableOnce
.
Returns a new NonEmptyMap
containing the entries of this NonEmptyMap
and the entries of the passed GenTraversableOnce
.
The entry type of the resulting NonEmptyMap
is the most specific superclass encompassing the entry types of this NonEmptyMap
and the passed GenTraversableOnce
.
- Type parameters:
- V1
the value type of the returned
NonEmptyMap
- Value parameters:
- other
the
GenTraversableOnce
to append
- Returns:
a new
NonEmptyMap
that contains all the elements of thisNonEmptyMap
followed by all elements ofother
.- Source:
- NonEmptyMap.scala
Returns a new NonEmptyMap
with the given entry added.
Returns a new NonEmptyMap
with the given entry added.
Note that :-ending operators are right associative. A mnemonic for +:
vs. :+
is: the COLon goes on the COLlection side.
- Value parameters:
- entry
the element to add to this
NonEmptyMap
- Returns:
a new
NonEmptyMap
consisting ofelement
followed by all elements of thisNonEmptyMap
.- Source:
- NonEmptyMap.scala
Appends all entries of this NonEmptyMap
to a string builder. The written text will consist of a concatenation of the result of invoking toString
on of every entry of this NonEmptyMap
, without any separator string.
Appends all entries of this NonEmptyMap
to a string builder. The written text will consist of a concatenation of the result of invoking toString
on of every entry of this NonEmptyMap
, without any separator string.
- Value parameters:
- sb
the string builder to which entries will be appended
- Returns:
the string builder,
sb
, to which entries were appended.- Source:
- NonEmptyMap.scala
Appends all entries of this NonEmptyMap
to a string builder using a separator string. The written text will consist of a concatenation of the
result of invoking toString
on of every element of this NonEmptyMap
, separated by the string sep
.
Appends all entries of this NonEmptyMap
to a string builder using a separator string. The written text will consist of a concatenation of the
result of invoking toString
on of every element of this NonEmptyMap
, separated by the string sep
.
- Value parameters:
- sb
the string builder to which entries will be appended
- sep
the separator string
- Returns:
the string builder,
sb
, to which elements were appended.- Source:
- NonEmptyMap.scala
Appends all entries of this NonEmptyMap
to a string builder using start, end, and separator strings. The written text will consist of a concatenation of
the string start
; the result of invoking toString
on all elements of this NonEmptyMap
,
separated by the string sep
; and the string end
Appends all entries of this NonEmptyMap
to a string builder using start, end, and separator strings. The written text will consist of a concatenation of
the string start
; the result of invoking toString
on all elements of this NonEmptyMap
,
separated by the string sep
; and the string end
- Value parameters:
- sb
the string builder to which elements will be appended
- sep
the separator string
- start
the ending string
- Returns:
the string builder,
sb
, to which elements were appended.- Source:
- NonEmptyMap.scala
Selects an value by its key in the NonEmptyMap
.
Selects an value by its key in the NonEmptyMap
.
- Returns:
the value of this
NonEmptyMap
at keyk
.- Source:
- NonEmptyMap.scala
Finds the first entry of this NonEmptyMap
for which the given partial function is defined, if any, and applies the partial function to it.
Finds the first entry of this NonEmptyMap
for which the given partial function is defined, if any, and applies the partial function to it.
- Value parameters:
- pf
the partial function
- Returns:
an
Option
containingpf
applied to the first entry for which it is defined, orNone
if the partial function was not defined for any entry.- Source:
- NonEmptyMap.scala
Indicates whether this NonEmptyMap
contains a binding for given key.
Indicates whether this NonEmptyMap
contains a binding for given key.
- Value parameters:
- key
the key to look for
- Returns:
true if this
NonEmptyMap
has a binding that is equal (as determined by==)
tokey
, false otherwise.- Source:
- NonEmptyMap.scala
Copies entries of this NonEmptyMap
to an array. Fills the given array arr
with entries of this NonEmptyMap
. Copying
will stop once either the end of the current NonEmptyMap
is reached, or the end of the array is reached.
Copies entries of this NonEmptyMap
to an array. Fills the given array arr
with entries of this NonEmptyMap
. Copying
will stop once either the end of the current NonEmptyMap
is reached, or the end of the array is reached.
- Value parameters:
- arr
the array to fill
- Source:
- NonEmptyMap.scala
Copies entries of this NonEmptyMap
to an array. Fills the given array arr
with entries of this NonEmptyMap
, beginning at
index start
. Copying will stop once either the end of the current NonEmptyMap
is reached, or the end of the array is reached.
Copies entries of this NonEmptyMap
to an array. Fills the given array arr
with entries of this NonEmptyMap
, beginning at
index start
. Copying will stop once either the end of the current NonEmptyMap
is reached, or the end of the array is reached.
- Value parameters:
- arr
the array to fill
- start
the starting index
- Source:
- NonEmptyMap.scala
Copies entries of this NonEmptyMap
to an array. Fills the given array arr
with at most len
entries of this NonEmptyMap
, beginning at
index start
. Copying will stop once either the end of the current NonEmptyMap
is reached, the end of the array is reached, or
len
elements have been copied.
Copies entries of this NonEmptyMap
to an array. Fills the given array arr
with at most len
entries of this NonEmptyMap
, beginning at
index start
. Copying will stop once either the end of the current NonEmptyMap
is reached, the end of the array is reached, or
len
elements have been copied.
- Value parameters:
- arr
the array to fill
- len
the maximum number of elements to copy
- start
the starting index
- Source:
- NonEmptyMap.scala
Copies all elements of this NonEmptyMap
to a buffer.
Copies all elements of this NonEmptyMap
to a buffer.
- Value parameters:
- buf
the buffer to which elements are copied
- Source:
- NonEmptyMap.scala
Counts the number of elements in this NonEmptyMap
that satisfy a predicate.
Counts the number of elements in this NonEmptyMap
that satisfy a predicate.
- Value parameters:
- p
the predicate used to test elements.
- Returns:
the number of elements satisfying the predicate
p
.- Source:
- NonEmptyMap.scala
Indicates whether a predicate holds for at least one of the entries of this NonEmptyMap
.
Indicates whether a predicate holds for at least one of the entries of this NonEmptyMap
.
- Value parameters:
- p
the predicate used to test entries.
- Returns:
true
if the given predicatep
holds for some of the entries of thisNonEmptyMap
, otherwisefalse
.- Source:
- NonEmptyMap.scala
Finds the first entry of this NonEmptyMap
that satisfies the given predicate, if any.
Finds the first entry of this NonEmptyMap
that satisfies the given predicate, if any.
- Value parameters:
- p
the predicate used to test elements
- Returns:
an
Some
containing the first element in thisNonEmptyMap
that satisfiesp
, orNone
if none exists.- Source:
- NonEmptyMap.scala
Builds a new NonEmptyMap
by applying a function to all entries of this NonEmptyMap
and using the entries of the resulting NonEmptyMap
s.
Builds a new NonEmptyMap
by applying a function to all entries of this NonEmptyMap
and using the entries of the resulting NonEmptyMap
s.
- Type parameters:
- K1
the key type of the returned
NonEmptyMap
- V1
the value type of the returned
NonEmptyMap
- Value parameters:
- f
the function to apply to each entry.
- Returns:
a new
NonEmptyMap
containing entries obtained by applying the given functionf
to each entry of thisNonEmptyMap
and concatenating the entries of resultingNonEmptyMap
s.- Source:
- NonEmptyMap.scala
Folds the entries of this NonEmptyMap
using the specified associative binary operator.
Folds the entries of this NonEmptyMap
using the specified associative binary operator.
The order in which operations are performed on entries is unspecified and may be nondeterministic.
- Type parameters:
- U
a type parameter for the binary operator, a supertype of (K, V).
- Value parameters:
- op
a binary operator that must be associative
- z
a neutral element for the fold operation; may be added to the result an arbitrary number of times, and must not change the result (e.g.,
Nil
for list concatenation, 0 for addition, or 1 for multiplication.)
- Returns:
the result of applying fold operator
op
between all the elements andz
- Source:
- NonEmptyMap.scala
Applies a binary operator to a start value and all elements of this NonEmptyMap
, going left to right.
Applies a binary operator to a start value and all elements of this NonEmptyMap
, going left to right.
- Type parameters:
- B
the result type of the binary operator.
- Value parameters:
- op
the binary operator.
- z
the start value.
- Returns:
the result of inserting
op
between consecutive entries of thisNonEmptyMap
, going left to right, with the start value,z
, on the left:op(...op(op(z, x_1), x_2), ..., x_n)
where x1, ..., xn are the elements of this
NonEmptyMap
.- Source:
- NonEmptyMap.scala
Applies a binary operator to all entries of this NonEmptyMap
and a start value, going right to left.
Applies a binary operator to all entries of this NonEmptyMap
and a start value, going right to left.
- Type parameters:
- B
the result of the binary operator
- Value parameters:
- op
the binary operator
- z
the start value
- Returns:
the result of inserting
op
between consecutive entries of thisNonEmptyMap
, going right to left, with the start value,z
, on the right:op(x_1, op(x_2, ... op(x_n, z)...))
where x1, ..., xn are the elements of this
NonEmptyMap
.- Source:
- NonEmptyMap.scala
Indicates whether a predicate holds for all entries of this NonEmptyMap
.
Indicates whether a predicate holds for all entries of this NonEmptyMap
.
- Value parameters:
- p
the predicate used to test entries.
- Returns:
true
if the given predicatep
holds for all entries of thisNonEmptyMap
, otherwisefalse
.- Source:
- NonEmptyMap.scala
Applies a function f
to all entries of this NonEmptyMap
.
Applies a function f
to all entries of this NonEmptyMap
.
- Value parameters:
- f
the function that is applied for its side-effect to every entry. The result of function
f
is discarded.
- Source:
- NonEmptyMap.scala
Partitions this NonEmptyMap
into a map of NonEmptyMap
s according to some discriminator function.
Partitions this NonEmptyMap
into a map of NonEmptyMap
s according to some discriminator function.
- Value parameters:
- f
the discriminator function.
- Returns:
A map from keys to
NonEmptyMap
s such that the following invariant holds:(nonEmptyMap.toMap partition f)(k) = xs filter (x => f(x) == k)
That is, every key
k
is bound to aNonEmptyMap
of those elementsx
for whichf(x)
equalsk
.- Source:
- NonEmptyMap.scala
Partitions entries into fixed size NonEmptyMap
s.
Partitions entries into fixed size NonEmptyMap
s.
- Value parameters:
- size
the number of entries per group
- Returns:
An iterator producing
NonEmptyMap
s of sizesize
, except the last will be truncated if the entries don't divide evenly.- Source:
- NonEmptyMap.scala
Returns true
to indicate this NonEmptyMap
has a definite size, since all NonEmptyMap
s are strict collections.
Returns true
to indicate this NonEmptyMap
has a definite size, since all NonEmptyMap
s are strict collections.
- Source:
- NonEmptyMap.scala
Selects the first element of this NonEmptyMap
.
Selects the first element of this NonEmptyMap
.
- Returns:
the first element of this
NonEmptyMap
.- Source:
- NonEmptyMap.scala
Selects the first element of this NonEmptyMap
and returns it wrapped in a Some
.
Selects the first element of this NonEmptyMap
and returns it wrapped in a Some
.
- Returns:
the first element of this
NonEmptyMap
, wrapped in aSome
.- Source:
- NonEmptyMap.scala
Tests whether this NonEmptyMap
contains given key.
Tests whether this NonEmptyMap
contains given key.
- Value parameters:
- key
the key to test
- Returns:
true if this
NonEmptyMap
contains a binding for the givenkey
,false
otherwise.- Source:
- NonEmptyMap.scala
Returns false
to indicate this NonEmptyMap
, like all NonEmptyMap
s, is non-empty.
Returns false
to indicate this NonEmptyMap
, like all NonEmptyMap
s, is non-empty.
- Returns:
false
- Source:
- NonEmptyMap.scala
Returns true
to indicate this NonEmptyMap
, like all NonEmptyMap
s, can be traversed repeatedly.
Returns true
to indicate this NonEmptyMap
, like all NonEmptyMap
s, can be traversed repeatedly.
- Returns:
true
- Source:
- NonEmptyMap.scala
Creates and returns a new iterator over all elements contained in this NonEmptyMap
.
Creates and returns a new iterator over all elements contained in this NonEmptyMap
.
- Returns:
the new iterator
- Source:
- NonEmptyMap.scala
Selects the last entry of this NonEmptyMap
.
Selects the last entry of this NonEmptyMap
.
- Returns:
the last entry of this
NonEmptyMap
.- Source:
- NonEmptyMap.scala
Returns the last element of this NonEmptyMap
, wrapped in a Some
.
Returns the last element of this NonEmptyMap
, wrapped in a Some
.
- Returns:
the last element, wrapped in a
Some
.- Source:
- NonEmptyMap.scala
Builds a new NonEmptyMap
by applying a function to all entries of this NonEmptyMap
.
Builds a new NonEmptyMap
by applying a function to all entries of this NonEmptyMap
.
- Type parameters:
- K1
the key type of the returned
NonEmptyMap
.- V1
the value type of the returned
NonEmptyMap
.
- Value parameters:
- f
the function to apply to each element.
- Returns:
a new
NonEmptyMap
resulting from applying the given functionf
to each element of thisNonEmptyMap
and collecting the results.- Source:
- NonEmptyMap.scala
Finds the largest entry.
Finds the largest entry.
- Returns:
the largest entry of this
NonEmptyMap
.- Source:
- NonEmptyMap.scala
Finds the largest result after applying the given function to every entry.
Finds the largest result after applying the given function to every entry.
- Returns:
the largest result of applying the given function to every entry of this
NonEmptyMap
.- Source:
- NonEmptyMap.scala
Finds the smallest entry.
Finds the smallest entry.
- Returns:
the smallest entry of this
NonEmptyMap
.- Source:
- NonEmptyMap.scala
Finds the smallest result after applying the given function to every entry.
Finds the smallest result after applying the given function to every entry.
- Returns:
the smallest result of applying the given function to every entry of this
NonEmptyMap
.- Source:
- NonEmptyMap.scala
Displays all entries of this NonEmptyMap
in a string.
Displays all entries of this NonEmptyMap
in a string.
- Returns:
a string representation of this
NonEmptyMap
. In the resulting string, the result of invokingtoString
on all entries of thisNonEmptyMap
follow each other without any separator string.- Source:
- NonEmptyMap.scala
Displays all entries of this NonEmptyMap
in a string using a separator string.
Displays all entries of this NonEmptyMap
in a string using a separator string.
- Value parameters:
- sep
the separator string
- Returns:
a string representation of this
NonEmptyMap
. In the resulting string, the result of invokingtoString
on all entries of thisNonEmptyMap
are separated by the stringsep
.- Source:
- NonEmptyMap.scala
Displays all entries of this NonEmptyMap
in a string using start, end, and separator strings.
Displays all entries of this NonEmptyMap
in a string using start, end, and separator strings.
- Value parameters:
- end
the ending string.
- sep
the separator string.
- start
the starting string.
- Returns:
a string representation of this
NonEmptyMap
. The resulting string begins with the stringstart
and ends with the stringend
. Inside, In the resulting string, the result of invokingtoString
on all entries of thisNonEmptyMap
are separated by the stringsep
.- Source:
- NonEmptyMap.scala
Returns true
to indicate this NonEmptyMap
, like all NonEmptyMap
s, is non-empty.
Returns true
to indicate this NonEmptyMap
, like all NonEmptyMap
s, is non-empty.
- Returns:
true
- Source:
- NonEmptyMap.scala
The result of multiplying all the entries of this NonEmptyMap
.
The result of multiplying all the entries of this NonEmptyMap
.
This method can be invoked for any NonEmptyMap[T]
for which an implicit Numeric[T]
exists.
- Returns:
the product of all elements
- Source:
- NonEmptyMap.scala
Reduces the entries of this NonEmptyMap
using the specified associative binary operator.
Reduces the entries of this NonEmptyMap
using the specified associative binary operator.
The order in which operations are performed on entries is unspecified and may be nondeterministic.
- Type parameters:
- U
a type parameter for the binary operator, a supertype of T.
- Value parameters:
- op
a binary operator that must be associative.
- Returns:
the result of applying reduce operator
op
between all the elements of thisNonEmptyMap
.- Source:
- NonEmptyMap.scala
Applies a binary operator to all entries of this NonEmptyMap
, going left to right.
Applies a binary operator to all entries of this NonEmptyMap
, going left to right.
- Type parameters:
- U
the result type of the binary operator.
- Value parameters:
- op
the binary operator.
- Returns:
the result of inserting
op
between consecutive entries of thisNonEmptyMap
, going left to right:op(...op(op(x_1, x_2), x_3), ..., x_n)
where x1, ..., xn are the elements of this
NonEmptyMap
.- Source:
- NonEmptyMap.scala
Applies a binary operator to all entries of this NonEmptyMap
, going left to right, returning the result in a Some
.
Applies a binary operator to all entries of this NonEmptyMap
, going left to right, returning the result in a Some
.
- Type parameters:
- U
the result type of the binary operator.
- Value parameters:
- op
the binary operator.
- Returns:
a
Some
containing the result ofreduceLeft(op)
- Source:
- NonEmptyMap.scala
Applies a binary operator to all entries of this NonEmptyMap
, going right to left.
Applies a binary operator to all entries of this NonEmptyMap
, going right to left.
- Type parameters:
- U
the result of the binary operator
- Value parameters:
- op
the binary operator
- Returns:
the result of inserting
op
between consecutive entries of thisNonEmptyMap
, going right to left:op(x_1, op(x_2, ... op(x_{n-1}, x_n)...))
where x1, ..., xn are the entries of this
NonEmptyMap
.- Source:
- NonEmptyMap.scala
Applies a binary operator to all entries of this NonEmptyMap
, going right to left, returning the result in a Some
.
Applies a binary operator to all entries of this NonEmptyMap
, going right to left, returning the result in a Some
.
- Type parameters:
- U
the result of the binary operator
- Value parameters:
- op
the binary operator
- Returns:
a
Some
containing the result ofreduceRight(op)
- Source:
- NonEmptyMap.scala
Checks if the given GenIterable
contains the same entries in the same order as this NonEmptyMap
.
Checks if the given GenIterable
contains the same entries in the same order as this NonEmptyMap
.
- Value parameters:
- that
the
GenIterable
with which to compare
- Returns:
true
, if both thisNonEmptyMap
and the givenGenIterable
contain the same entries in the same order,false
otherwise.- Source:
- NonEmptyMap.scala
Checks if the given Every
contains the same entries in the same order as this NonEmptyMap
.
Checks if the given Every
contains the same entries in the same order as this NonEmptyMap
.
- Value parameters:
- that
the
Every
with which to compare
- Returns:
true
, if both this and the givenEvery
contain the same entries in the same order,false
otherwise.- Source:
- NonEmptyMap.scala
Checks if the given NonEmptyMap
contains the same entries in the same order as this NonEmptyMap
.
Checks if the given NonEmptyMap
contains the same entries in the same order as this NonEmptyMap
.
- Value parameters:
- that
the
NonEmptyMap
with which to compare
- Returns:
true
, if both this and the givenNonEmptyMap
contain the same entries in the same order,false
otherwise.- Source:
- NonEmptyMap.scala
Computes a prefix scan of the entries of this NonEmptyMap
.
Computes a prefix scan of the entries of this NonEmptyMap
.
Note: The neutral element z may be applied more than once.
- Value parameters:
- op
a binary operator that must be associative
- z
a neutral element for the scan operation; may be added to the result an arbitrary number of times, and must not change the result (e.g.,
Nil
for list concatenation, 0 for addition, or 1 for multiplication.)
- Returns:
a new
NonEmptyMap
containing the prefix scan of the elements in thisNonEmptyMap
- Source:
- NonEmptyMap.scala
The size of this NonEmptyMap
.
The size of this NonEmptyMap
.
Note: length
and size
yield the same result, which will be >
= 1.
- Returns:
the number of elements in this
NonEmptyMap
.- Source:
- NonEmptyMap.scala
Groups entries in fixed size blocks by passing a “sliding window” over them (as opposed to partitioning them, as is done in grouped.)
Groups entries in fixed size blocks by passing a “sliding window” over them (as opposed to partitioning them, as is done in grouped.)
- Value parameters:
- size
the number of entries per group
- Returns:
an iterator producing
NonEmptyMap
s of sizesize
, except the last and the only element will be truncated if there are fewer entries thansize
.- Source:
- NonEmptyMap.scala
Groups entries in fixed size blocks by passing a “sliding window” over them (as opposed to partitioning them, as is done in grouped.),
moving the sliding window by a given step
each time.
Groups entries in fixed size blocks by passing a “sliding window” over them (as opposed to partitioning them, as is done in grouped.),
moving the sliding window by a given step
each time.
- Value parameters:
- size
the number of entries per group
- step
the distance between the first entries of successive groups
- Returns:
an iterator producing
NonEmptyMap
s of sizesize
, except the last and the only element will be truncated if there are fewer elements thansize
.- Source:
- NonEmptyMap.scala
Returns "NonEmptyMap"
, the prefix of this object's toString
representation.
Returns "NonEmptyMap"
, the prefix of this object's toString
representation.
- Returns:
the string
"NonEmptyMap"
- Source:
- NonEmptyMap.scala
The result of summing all the elements of this NonEmptyMap
.
The result of summing all the elements of this NonEmptyMap
.
This method can be invoked for any NonEmptyMap[T]
for which an implicit Numeric[T]
exists.
- Returns:
the sum of all elements
- Source:
- NonEmptyMap.scala
Converts this NonEmptyMap
into a collection of type Col
by copying all entries.
Converts this NonEmptyMap
into a collection of type Col
by copying all entries.
- Type parameters:
- Col
the collection type to build.
- Returns:
a new collection containing all entries of this
NonEmptyMap
.- Source:
- NonEmptyMap.scala
Converts this NonEmptyMap
to an array.
Converts this NonEmptyMap
to an array.
- Returns:
an array containing all entries of this
NonEmptyMap
. AClassTag
must be available for the entry type of thisNonEmptyMap
.- Source:
- NonEmptyMap.scala
Converts this NonEmptyMap
to a mutable buffer.
Converts this NonEmptyMap
to a mutable buffer.
- Returns:
a buffer containing all entries of this
NonEmptyMap
.- Source:
- NonEmptyMap.scala
Converts this NonEmptyMap
to an immutable IndexedSeq
.
Converts this NonEmptyMap
to an immutable IndexedSeq
.
- Returns:
an immutable
IndexedSeq
containing all entries of thisNonEmptyMap
.- Source:
- NonEmptyMap.scala
Converts this NonEmptyMap
to an iterable collection.
Converts this NonEmptyMap
to an iterable collection.
- Returns:
an
Iterable
containing all entries of thisNonEmptyMap
.- Source:
- NonEmptyMap.scala
Returns an Iterator
over the entries in this NonEmptyMap
.
Returns an Iterator
over the entries in this NonEmptyMap
.
- Returns:
an
Iterator
containing all entries of thisNonEmptyMap
.- Source:
- NonEmptyMap.scala
Converts this NonEmptyMap
to an immutable IndexedSeq
.
Converts this NonEmptyMap
to an immutable IndexedSeq
.
- Returns:
an immutable
IndexedSeq
containing all entries of thisNonEmptyMap
.- Source:
- NonEmptyMap.scala
Converts this NonEmptyMap
to a set.
Converts this NonEmptyMap
to a set.
- Returns:
a set containing all entries of this
NonEmptyMap
.- Source:
- NonEmptyMap.scala
Converts this NonEmptyMap
to a stream.
Converts this NonEmptyMap
to a stream.
- Returns:
a stream containing all entries of this
NonEmptyMap
.- Source:
- NonEmptyMap.scala
Returns a string representation of this NonEmptyMap
.
Returns a string representation of this NonEmptyMap
.
- Returns:
the string
"NonEmptyMap"
followed by the result of invokingtoString
on thisNonEmptyMap
's elements, surrounded by parentheses.- Definition Classes
- Any
- Source:
- NonEmptyMap.scala
Converts this NonEmptyMap
to a Vector
.
Converts this NonEmptyMap
to a Vector
.
- Returns:
a
Vector
containing all entries of thisNonEmptyMap
.- Source:
- NonEmptyMap.scala
Converts this NonEmptyMap
of pairs into two Iterable
s of the first and second half of each pair.
Converts this NonEmptyMap
of pairs into two Iterable
s of the first and second half of each pair.
- Type parameters:
- L
the type of the first half of the element pairs
- R
the type of the second half of the element pairs
- Value parameters:
- asPair
an implicit conversion that asserts that the element type of this
NonEmptyMap
is a pair.
- Returns:
a pair of
NonEmptyMap
s, containing the first and second half, respectively, of each element pair of thisNonEmptyMap
.- Source:
- NonEmptyMap.scala
Converts this NonEmptyMap
of triples into three NonEmptyMap
s of the first, second, and and third entry of each triple.
Converts this NonEmptyMap
of triples into three NonEmptyMap
s of the first, second, and and third entry of each triple.
- Type parameters:
- L
the type of the first member of the entry triples
- R
the type of the third member of the entry triples
- Value parameters:
- asTriple
an implicit conversion that asserts that the entry type of this
NonEmptyMap
is a triple.
- Returns:
a triple of
NonEmptyMap
s, containing the first, second, and third member, respectively, of each entry triple of thisNonEmptyMap
.- Source:
- NonEmptyMap.scala
A copy of this NonEmptyMap
with one single replaced entry.
A copy of this NonEmptyMap
with one single replaced entry.
- Value parameters:
- key
the key of the replacement
- value
the replacing value
- Returns:
a copy of this
NonEmptyMap
with the value atkey
replaced by the givenvalue
.- Source:
- NonEmptyMap.scala
Returns a NonEmptyMap
formed from this NonEmptyMap
and an iterable collection by combining corresponding
entries in pairs. If one of the two collections is shorter than the other, placeholder entries will be used to extend the
shorter collection to the length of the longer.
Returns a NonEmptyMap
formed from this NonEmptyMap
and an iterable collection by combining corresponding
entries in pairs. If one of the two collections is shorter than the other, placeholder entries will be used to extend the
shorter collection to the length of the longer.
- Type parameters:
- O
the type of the second half of the returned pairs
- V1
the subtype of the value type of this
NonEmptyMap
- Value parameters:
- other
the
Iterable
providing the second half of each result pair- otherElem
the element to be used to fill up the result if
that
Iterable
is shorter than thisNonEmptyMap
.- thisElem
the element to be used to fill up the result if this
NonEmptyMap
is shorter thanthat
Iterable
.
- Returns:
a new
NonEmptyMap
containing pairs consisting of corresponding entries of thisNonEmptyMap
andthat
. The length of the returned collection is the maximum of the lengths of thisNonEmptyMap
andthat
. If thisNonEmptyMap
is shorter thanthat
,thisElem
values are used to pad the result. Ifthat
is shorter than thisNonEmptyMap
,thatElem
values are used to pad the result.- Source:
- NonEmptyMap.scala
Zips this NonEmptyMap
with its indices.
Zips this NonEmptyMap
with its indices.
- Returns:
A new
NonEmptyMap
containing pairs consisting of all elements of thisNonEmptyMap
paired with their index. Indices start at 0.- Source:
- NonEmptyMap.scala