final class NEMap[K, +V] extends AnyVal
A non-empty map: an ordered, immutable, non-empty collection of key-value tuples with LinearSeq
performance characteristics.
The purpose of NEMap
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 Vector
.
Constructing NEMap
s
You can construct a NEMap
by passing one or more elements to the NEMap.apply
factory method:
scala> NEMap(1 -> "one", 2 -> "two", 3 -> "three") res0: org.scalactic.anyvals.NEMap[Int, String] = NEMap(1 -> "one", 2 -> "two", 3 -> "three")
Working with NEMap
s
NEMap
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, NEMap
defines a method corresponding to every such Map
method. Here are an example:
NEMap(1 -> "one", 2 -> "two", 3 -> "three").map(t => (t._1 + 1, t._2)) // Result: NEMap(2 -> "one", 3 -> "two", 4 -> "three")
NEMap
does not currently define any methods corresponding to Map
methods that could result in
an empty Map
. However, an implicit converison from NEMap
to Map
is defined in the NEMap
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 NEMap
, even though filter
could result
in an empty map—but the result type will be Map
instead of NEMap
:
NEMap(1 -> "one", 2 -> "two", 3 -> "three").filter(_._1 < 10) // Result: Map(1 -> "one", 2 -> "two", 3 -> "three") NEMap(1 -> "one", 2 -> "two", 3 -> "three").filter(_._ 1> 10) // Result: Map()
You can use NEMap
s in for
expressions. The result will be an NEMap
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) <- NEMap(1 -> "one", 2 -> "two", 3 -> "three")) yield (i + 1, j) res0: org.scalactic.anyvals.NEMap[Int, String] = NEMap(2 -> "one", 3 -> "two", 4 -> "three") scala> for ((i, j) <- NEMap(1, 2, 3) if i < 10) yield (i + 1, j) res1: Map[Int, String] = Map(2 -> "one", 3 -> "two", 4 -> "three")
- K
the type of key contained in this
NEMap
- V
the type of value contained in this
NEMap
- Alphabetic
- By Inheritance
- NEMap
- AnyVal
- Any
- Hide All
- Show All
- Public
- Protected
Value Members
- final def !=(arg0: Any): Boolean
- Definition Classes
- Any
- final def ##: Int
- Definition Classes
- Any
- def +[V1 >: V](entries: (K, V1)*): NEMap[K, V1]
Returns a new
NEMap
with the given entries added.Returns a new
NEMap
with the given entries added.- entries
the entries to add to this
NEMap
- returns
a new
NEMap
consisting of all entries of thisNEMap
andentries
.
- def +[V1 >: V](entry: (K, V1)): NEMap[K, V1]
Returns a new
NEMap
with the given entry added.Returns a new
NEMap
with the given entry added.- entry
the entry to add to this
NEMap
- returns
a new
NEMap
consisting of all entries of thisNEMap
andentry
.
- def ++[V1 >: V](other: IterableOnce[(K, V1)]): NEMap[K, V1]
Returns a new
NEMap
containing the entries of thisNEMap
and the entries of the passedTraversableOnce
.Returns a new
NEMap
containing the entries of thisNEMap
and the entries of the passedTraversableOnce
. The entry type of the resultingNEMap
is the most specific superclass encompassing the entry types of thisNEMap
and the passedTraversableOnce
.- V1
the value type of the returned
NEMap
- other
the
TraversableOnce
to append- returns
a new
NEMap
that contains all the elements of thisNEMap
followed by all elements ofother
.
- def ++[V1 >: V](other: Vector[(K, V1)]): NEMap[K, V1]
Returns a new
NEMap
containing the entries of thisNEMap
and the entries of the passedVector
.Returns a new
NEMap
containing the entries of thisNEMap
and the entries of the passedVector
. The entry type of the resultingNEMap
is the most specific superclass encompassing the entry types of thisNEMap
and the passedVector
.- V1
the value type of the returned
NEMap
- other
the
Vector
to append- returns
a new
NEMap
that contains all the entries of thisNEMap
and all elements ofother
.
- def ++[V1 >: V](other: NEMap[K, V1]): NEMap[K, V1]
Returns a new
NEMap
containing the entries of thisNEMap
and the entries of the passedNEMap
.Returns a new
NEMap
containing the entries of thisNEMap
and the entries of the passedNEMap
. The entry type of the resultingNEMap
is the most specific superclass encompassing the entry types of this and the passedNEMap
.- V1
the value type of the returned
NEMap
- other
the
NEMap
to append- returns
a new
NEMap
that contains all the elements of thisNEMap
and all elements ofother
.
- def ++:[V1 >: V](other: IterableOnce[(K, V1)]): NEMap[K, V1]
Returns a new
NEMap
containing the entries of thisNEMap
and the entries of the passedTraversableOnce
.Returns a new
NEMap
containing the entries of thisNEMap
and the entries of the passedTraversableOnce
. The entry type of the resultingNEMap
is the most specific superclass encompassing the entry types of thisNEMap
and the passedTraversableOnce
.- V1
the value type of the returned
NEMap
- other
the
TraversableOnce
to append- returns
a new
NEMap
that contains all the elements of thisNEMap
followed by all elements ofother
.
- def ++:[V1 >: V](other: Vector[(K, V1)]): NEMap[K, V1]
As with
++
, returns a newNEMap
containing the entries of thisNEMap
and the entries of the passedVector
.As with
++
, returns a newNEMap
containing the entries of thisNEMap
and the entries of the passedVector
. The entry type of the resultingNEMap
is the most specific superclass encompassing the entry types of thisNEMap
and the passedVector
.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.- V1
the value type of the returned
NEMap
- other
the
Vector
to append- returns
a new
NEMap
that contains all the entries of thisNEMap
and all elements ofother
.
- def ++:[V1 >: V](other: NEMap[K, V1]): NEMap[K, V1]
As with
++
, returns a newNEMap
containing the entries of thisNEMap
and the entries of the passedNEMap
.As with
++
, returns a newNEMap
containing the entries of thisNEMap
and the entries of the passedNEMap
. The entry type of the resultingNEMap
is the most specific superclass encompassing the entry types of this and the passedNEMap
.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.- V1
the value type of the returned
NEMap
- other
the
NEMap
to add- returns
a new
NEMap
that contains all the elements of thisNEMap
and all elements ofother
.
- def +:[V1 >: V](entry: (K, V1)): NEMap[K, V1]
Returns a new
NEMap
with the given entry added.Returns a new
NEMap
with the given entry added.Note that :-ending operators are right associative. A mnemonic for
+:
vs.:+
is: the COLon goes on the COLlection side.- entry
the element to add to this
NEMap
- returns
a new
NEMap
consisting ofelement
followed by all elements of thisNEMap
.
- final def ==(arg0: Any): Boolean
- Definition Classes
- Any
- def addString(sb: StringBuilder, start: String, sep: String, end: String): StringBuilder
Appends all entries of this
NEMap
to a string builder using start, end, and separator strings.Appends all entries of this
NEMap
to a string builder using start, end, and separator strings. The written text will consist of a concatenation of the stringstart
; the result of invokingtoString
on all elements of thisNEMap
, separated by the stringsep
; and the stringend
- sb
the string builder to which elements will be appended
- start
the ending string
- sep
the separator string
- returns
the string builder,
sb
, to which elements were appended.
- def addString(sb: StringBuilder, sep: String): StringBuilder
Appends all entries of this
NEMap
to a string builder using a separator string.Appends all entries of this
NEMap
to a string builder using a separator string. The written text will consist of a concatenation of the result of invokingtoString
on of every element of thisNEMap
, separated by the stringsep
.- sb
the string builder to which entries will be appended
- sep
the separator string
- returns
the string builder,
sb
, to which elements were appended.
- def addString(sb: StringBuilder): StringBuilder
Appends all entries of this
NEMap
to a string builder.Appends all entries of this
NEMap
to a string builder. The written text will consist of a concatenation of the result of invokingtoString
on of every entry of thisNEMap
, without any separator string.- sb
the string builder to which entries will be appended
- returns
the string builder,
sb
, to which entries were appended.
- def apply(k: K): V
Selects an value by its key in the
NEMap
.Selects an value by its key in the
NEMap
.- returns
the value of this
NEMap
at keyk
.
- final def asInstanceOf[T0]: T0
- Definition Classes
- Any
- def collectFirst[U](pf: PartialFunction[(K, V), U]): Option[U]
Finds the first entry of this
NEMap
for which the given partial function is defined, if any, and applies the partial function to it.Finds the first entry of this
NEMap
for which the given partial function is defined, if any, and applies the partial function to it.- 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.
- def contains(key: K): Boolean
Indicates whether this
NEMap
contains a binding for given key.Indicates whether this
NEMap
contains a binding for given key.- key
the key to look for
- returns
true if this
NEMap
has a binding that is equal (as determined by==)
tokey
, false otherwise.
- def copyToArray[V1 >: V](arr: Array[(K, V1)], start: Int, len: Int): Unit
Copies entries of this
NEMap
to an array.Copies entries of this
NEMap
to an array. Fills the given arrayarr
with at mostlen
entries of thisNEMap
, beginning at indexstart
. Copying will stop once either the end of the currentNEMap
is reached, the end of the array is reached, orlen
elements have been copied.- arr
the array to fill
- start
the starting index
- len
the maximum number of elements to copy
- def copyToArray[V1 >: V](arr: Array[(K, V1)], start: Int): Unit
Copies entries of this
NEMap
to an array.Copies entries of this
NEMap
to an array. Fills the given arrayarr
with entries of thisNEMap
, beginning at indexstart
. Copying will stop once either the end of the currentNEMap
is reached, or the end of the array is reached.- arr
the array to fill
- start
the starting index
- def copyToArray[V1 >: V](arr: Array[(K, V1)]): Unit
Copies entries of this
NEMap
to an array.Copies entries of this
NEMap
to an array. Fills the given arrayarr
with entries of thisNEMap
. Copying will stop once either the end of the currentNEMap
is reached, or the end of the array is reached.- arr
the array to fill
- def copyToBuffer[V1 >: V](buf: Buffer[(K, V1)]): Unit
Copies all elements of this
NEMap
to a buffer.Copies all elements of this
NEMap
to a buffer.- buf
the buffer to which elements are copied
- def count(p: ((K, V)) => Boolean): Int
Counts the number of elements in this
NEMap
that satisfy a predicate.Counts the number of elements in this
NEMap
that satisfy a predicate.- p
the predicate used to test elements.
- returns
the number of elements satisfying the predicate
p
.
- def exists(p: ((K, V)) => Boolean): Boolean
Indicates whether a predicate holds for at least one of the entries of this
NEMap
.Indicates whether a predicate holds for at least one of the entries of this
NEMap
.- p
the predicate used to test entries.
- returns
true
if the given predicatep
holds for some of the entries of thisNEMap
, otherwisefalse
.
- def find(p: ((K, V)) => Boolean): Option[(K, V)]
Finds the first entry of this
NEMap
that satisfies the given predicate, if any.Finds the first entry of this
NEMap
that satisfies the given predicate, if any.- p
the predicate used to test elements
- returns
an
Some
containing the first element in thisNEMap
that satisfiesp
, orNone
if none exists.
- def flatMap[K1, V1](f: ((K, V)) => NEMap[K1, V1]): NEMap[K1, V1]
Builds a new
NEMap
by applying a function to all entries of thisNEMap
and using the entries of the resultingNEMap
s.Builds a new
NEMap
by applying a function to all entries of thisNEMap
and using the entries of the resultingNEMap
s.- K1
the key type of the returned
NEMap
- V1
the value type of the returned
NEMap
- f
the function to apply to each entry.
- returns
a new
NEMap
containing entries obtained by applying the given functionf
to each entry of thisNEMap
and concatenating the entries of resultingNEMap
s.
- def fold[U >: (K, V)](z: U)(op: (U, U) => U): U
Folds the entries of this
NEMap
using the specified associative binary operator.Folds the entries of this
NEMap
using the specified associative binary operator.The order in which operations are performed on entries is unspecified and may be nondeterministic.
- U
a type parameter for the binary operator, a supertype of (K, V).
- 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.)- op
a binary operator that must be associative
- returns
the result of applying fold operator
op
between all the elements andz
- def foldLeft[B](z: B)(op: (B, (K, V)) => B): B
Applies a binary operator to a start value and all elements of this
NEMap
, going left to right.Applies a binary operator to a start value and all elements of this
NEMap
, going left to right.- B
the result type of the binary operator.
- z
the start value.
- op
the binary operator.
- returns
the result of inserting
op
between consecutive entries of thisNEMap
, going left to right, with the start value,z
, on the left:op(...op(op(z, x_1), x_2), ..., x_n)
where x_{1}, ..., x_{n} are the elements of thisNEMap
.
- def foldRight[B](z: B)(op: ((K, V), B) => B): B
Applies a binary operator to all entries of this
NEMap
and a start value, going right to left.Applies a binary operator to all entries of this
NEMap
and a start value, going right to left.- B
the result of the binary operator
- z
the start value
- op
the binary operator
- returns
the result of inserting
op
between consecutive entries of thisNEMap
, going right to left, with the start value,z
, on the right:op(x_1, op(x_2, ... op(x_n, z)...))
where x_{1}, ..., x_{n} are the elements of thisNEMap
.
- def forall(p: ((K, V)) => Boolean): Boolean
Indicates whether a predicate holds for all entries of this
NEMap
.Indicates whether a predicate holds for all entries of this
NEMap
.- p
the predicate used to test entries.
- returns
true
if the given predicatep
holds for all entries of thisNEMap
, otherwisefalse
.
- def foreach(f: ((K, V)) => Unit): Unit
Applies a function
f
to all entries of thisNEMap
.Applies a function
f
to all entries of thisNEMap
.- f
the function that is applied for its side-effect to every entry. The result of function
f
is discarded.
- def getClass(): Class[_ <: AnyVal]
- Definition Classes
- AnyVal → Any
- def groupBy(f: ((K, V)) => K): Map[K, NEMap[K, V]]
Partitions this
NEMap
into a map ofNEMap
s according to some discriminator function.Partitions this
NEMap
into a map ofNEMap
s according to some discriminator function.- f
the discriminator function.
- returns
A map from keys to
NEMap
s such that the following invariant holds:(NEMap.toMap partition f)(k) = xs filter (x => f(x) == k)
That is, every keyk
is bound to aNEMap
of those elementsx
for whichf(x)
equalsk
.
- def grouped(size: Int): Iterator[NEMap[K, V]]
Partitions entries into fixed size
NEMap
s.Partitions entries into fixed size
NEMap
s.- size
the number of entries per group
- returns
An iterator producing
NEMap
s of sizesize
, except the last will be truncated if the entries don't divide evenly.
- def hasDefiniteSize: Boolean
Returns
true
to indicate thisNEMap
has a definite size, since allNEMap
s are strict collections. - def head: (K, V)
Selects the first element of this
NEMap
.Selects the first element of this
NEMap
.- returns
the first element of this
NEMap
.
- def isDefinedAt(key: K): Boolean
Tests whether this
NEMap
contains given key.Tests whether this
NEMap
contains given key.- key
the key to test
- returns
true if this
NEMap
contains a binding for the givenkey
,false
otherwise.
- def isEmpty: Boolean
Returns
false
to indicate thisNEMap
, like allNEMap
s, is non-empty.Returns
false
to indicate thisNEMap
, like allNEMap
s, is non-empty.- returns
false
- final def isInstanceOf[T0]: Boolean
- Definition Classes
- Any
- def isTraversableAgain: Boolean
Returns
true
to indicate thisNEMap
, like allNEMap
s, can be traversed repeatedly.Returns
true
to indicate thisNEMap
, like allNEMap
s, can be traversed repeatedly.- returns
true
- def iterator: Iterator[(K, V)]
Creates and returns a new iterator over all elements contained in this
NEMap
.Creates and returns a new iterator over all elements contained in this
NEMap
.- returns
the new iterator
- def keySet: NESet[K]
- def last: (K, V)
Selects the last entry of this
NEMap
.Selects the last entry of this
NEMap
.- returns
the last entry of this
NEMap
.
- def map[K1, V1](f: ((K, V)) => (K1, V1)): NEMap[K1, V1]
Builds a new
NEMap
by applying a function to all entries of thisNEMap
.Builds a new
NEMap
by applying a function to all entries of thisNEMap
.- K1
the key type of the returned
NEMap
.- V1
the value type of the returned
NEMap
.- f
the function to apply to each element.
- returns
a new
NEMap
resulting from applying the given functionf
to each element of thisNEMap
and collecting the results.
- def max[U >: (K, V)](implicit cmp: Ordering[U]): (K, V)
Finds the largest entry.
Finds the largest entry.
- returns
the largest entry of this
NEMap
.
- def maxBy[U](f: ((K, V)) => U)(implicit cmp: Ordering[U]): (K, V)
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
NEMap
.
- def min[U >: (K, V)](implicit cmp: Ordering[U]): (K, V)
Finds the smallest entry.
Finds the smallest entry.
- returns
the smallest entry of this
NEMap
.
- def minBy[U](f: ((K, V)) => U)(implicit cmp: Ordering[U]): (K, V)
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
NEMap
.
- def mkString(start: String, sep: String, end: String): String
Displays all entries of this
NEMap
in a string using start, end, and separator strings.Displays all entries of this
NEMap
in a string using start, end, and separator strings.- start
the starting string.
- sep
the separator string.
- end
the ending string.
- returns
a string representation of this
NEMap
. 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 thisNEMap
are separated by the stringsep
.
- def mkString(sep: String): String
Displays all entries of this
NEMap
in a string using a separator string.Displays all entries of this
NEMap
in a string using a separator string.- sep
the separator string
- returns
a string representation of this
NEMap
. In the resulting string, the result of invokingtoString
on all entries of thisNEMap
are separated by the stringsep
.
- def mkString: String
Displays all entries of this
NEMap
in a string.Displays all entries of this
NEMap
in a string.- returns
a string representation of this
NEMap
. In the resulting string, the result of invokingtoString
on all entries of thisNEMap
follow each other without any separator string.
- def nonEmpty: Boolean
Returns
true
to indicate thisNEMap
, like allNEMap
s, is non-empty.Returns
true
to indicate thisNEMap
, like allNEMap
s, is non-empty.- returns
true
- def product[U >: (K, V)](implicit num: Numeric[U]): U
The result of multiplying all the entries of this
NEMap
.The result of multiplying all the entries of this
NEMap
.This method can be invoked for any
NEMap[T]
for which an implicitNumeric[T]
exists.- returns
the product of all elements
- def reduce[U >: (K, V)](op: (U, U) => U): U
Reduces the entries of this
NEMap
using the specified associative binary operator.Reduces the entries of this
NEMap
using the specified associative binary operator.The order in which operations are performed on entries is unspecified and may be nondeterministic.
- U
a type parameter for the binary operator, a supertype of T.
- op
a binary operator that must be associative.
- returns
the result of applying reduce operator
op
between all the elements of thisNEMap
.
- def reduceLeft[U >: (K, V)](op: (U, (K, V)) => U): U
Applies a binary operator to all entries of this
NEMap
, going left to right.Applies a binary operator to all entries of this
NEMap
, going left to right.- U
the result type of the binary operator.
- op
the binary operator.
- returns
the result of inserting
op
between consecutive entries of thisNEMap
, going left to right:op(...op(op(x_1, x_2), x_3), ..., x_n)
where x_{1}, ..., x_{n} are the elements of thisNEMap
.
- def reduceLeftOption[U >: (K, V)](op: (U, (K, V)) => U): Option[U]
Applies a binary operator to all entries of this
NEMap
, going left to right, returning the result in aSome
.Applies a binary operator to all entries of this
NEMap
, going left to right, returning the result in aSome
.- U
the result type of the binary operator.
- op
the binary operator.
- returns
a
Some
containing the result ofreduceLeft(op)
- def reduceOption[U >: (K, V)](op: (U, U) => U): Option[U]
- def reduceRight[U >: (K, V)](op: ((K, V), U) => U): U
Applies a binary operator to all entries of this
NEMap
, going right to left.Applies a binary operator to all entries of this
NEMap
, going right to left.- U
the result of the binary operator
- op
the binary operator
- returns
the result of inserting
op
between consecutive entries of thisNEMap
, going right to left:op(x_1, op(x_2, ... op(x_{n-1}, x_n)...))
where x_{1}, ..., x_{n} are the entries of thisNEMap
.
- def reduceRightOption[U >: (K, V)](op: ((K, V), U) => U): Option[U]
Applies a binary operator to all entries of this
NEMap
, going right to left, returning the result in aSome
.Applies a binary operator to all entries of this
NEMap
, going right to left, returning the result in aSome
.- U
the result of the binary operator
- op
the binary operator
- returns
a
Some
containing the result ofreduceRight(op)
- def sameElements[V1 >: V](that: NEMap[K, V1]): Boolean
Checks if the given
NEMap
contains the same entries in the same order as thisNEMap
.Checks if the given
NEMap
contains the same entries in the same order as thisNEMap
.- that
the
NEMap
with which to compare- returns
true
, if both this and the givenNEMap
contain the same entries in the same order,false
otherwise.
- def scan[V1 >: V](z: (K, V1))(op: ((K, V1), (K, V1)) => (K, V1)): NEMap[K, V1]
Computes a prefix scan of the entries of this
NEMap
.Computes a prefix scan of the entries of this
NEMap
.- 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.)- op
a binary operator that must be associative
- returns
a new
NEMap
containing the prefix scan of the elements in thisNEMap
- Note
The neutral element z may be applied more than once.
- def size: Int
The size of this
NEMap
.The size of this
NEMap
.- returns
the number of elements in this
NEMap
.
- Note
length
andsize
yield the same result, which will be>
= 1.
- def sliding(size: Int, step: Int): Iterator[NEMap[K, V]]
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.- size
the number of entries per group
- step
the distance between the first entries of successive groups
- returns
an iterator producing
NEMap
s of sizesize
, except the last and the only element will be truncated if there are fewer elements thansize
.
- def sliding(size: Int): Iterator[NEMap[K, V]]
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.)
- size
the number of entries per group
- returns
an iterator producing
NEMap
s of sizesize
, except the last and the only element will be truncated if there are fewer entries thansize
.
- def stringPrefix: String
Returns
"NEMap"
, the prefix of this object'stoString
representation.Returns
"NEMap"
, the prefix of this object'stoString
representation.- returns
the string
"NEMap"
- def sum[U >: (K, V)](implicit num: Numeric[U]): U
The result of summing all the elements of this
NEMap
.The result of summing all the elements of this
NEMap
.This method can be invoked for any
NEMap[T]
for which an implicitNumeric[T]
exists.- returns
the sum of all elements
- def tail: Map[K, V]
- def to[C1](factory: Factory[(K, V), C1]): C1
Converts this
NEMap
into a collection of typeCol
by copying all entries.Converts this
NEMap
into a collection of typeCol
by copying all entries.- C1
the collection type to build.
- returns
a new collection containing all entries of this
NEMap
.
- def toArray[U >: (K, V)](implicit classTag: ClassTag[U]): Array[U]
Converts this
NEMap
to an array.Converts this
NEMap
to an array.- returns
an array containing all entries of this
NEMap
. AClassTag
must be available for the entry type of thisNEMap
.
- def toBuffer[U >: (K, V)]: Buffer[U]
Converts this
NEMap
to a mutable buffer.Converts this
NEMap
to a mutable buffer.- returns
a buffer containing all entries of this
NEMap
.
- def toIndexedSeq: IndexedSeq[(K, V)]
Converts this
NEMap
to an immutableIndexedSeq
.Converts this
NEMap
to an immutableIndexedSeq
.- returns
an immutable
IndexedSeq
containing all entries of thisNEMap
.
- def toIterable: Iterable[(K, V)]
Converts this
NEMap
to an iterable collection.Converts this
NEMap
to an iterable collection.- returns
an
Iterable
containing all entries of thisNEMap
.
- def toIterator: Iterator[(K, V)]
Returns an
Iterator
over the entries in thisNEMap
.Returns an
Iterator
over the entries in thisNEMap
.- returns
an
Iterator
containing all entries of thisNEMap
.
- val toMap: Map[K, V]
- def toSeq: Seq[(K, V)]
Converts this
NEMap
to an immutableIndexedSeq
.Converts this
NEMap
to an immutableIndexedSeq
.- returns
an immutable
IndexedSeq
containing all entries of thisNEMap
.
- def toSet[U >: (K, V)]: Set[U]
Converts this
NEMap
to a set.Converts this
NEMap
to a set.- returns
a set containing all entries of this
NEMap
.
- def toString(): String
Returns a string representation of this
NEMap
.Returns a string representation of this
NEMap
.- returns
the string
"NEMap"
followed by the result of invokingtoString
on thisNEMap
's elements, surrounded by parentheses.
- Definition Classes
- NEMap → Any
- def toVector: Vector[(K, V)]
Converts this
NEMap
to aVector
.Converts this
NEMap
to aVector
.- returns
a
Vector
containing all entries of thisNEMap
.
- def unzip[L, R](implicit asPair: ((K, V)) => (L, R)): (Iterable[L], Iterable[R])
Converts this
NEMap
of pairs into twoIterable
s of the first and second half of each pair.Converts this
NEMap
of pairs into twoIterable
s of the first and second half of each pair.- L
the type of the first half of the element pairs
- R
the type of the second half of the element pairs
- asPair
an implicit conversion that asserts that the element type of this
NEMap
is a pair.- returns
a pair of
NEMap
s, containing the first and second half, respectively, of each element pair of thisNEMap
.
- def unzip3[L, M, R](implicit asTriple: ((K, V)) => (L, M, R)): (Iterable[L], Iterable[M], Iterable[R])
Converts this
NEMap
of triples into threeNEMap
s of the first, second, and and third entry of each triple.Converts this
NEMap
of triples into threeNEMap
s of the first, second, and and third entry of each triple.- L
the type of the first member of the entry triples
- R
the type of the third member of the entry triples
- asTriple
an implicit conversion that asserts that the entry type of this
NEMap
is a triple.- returns
a triple of
NEMap
s, containing the first, second, and third member, respectively, of each entry triple of thisNEMap
.
- def updated[V1 >: V](key: K, value: V1): NEMap[K, V1]
A copy of this
NEMap
with one single replaced entry.A copy of this
NEMap
with one single replaced entry.- key
the key of the replacement
- value
the replacing value
- returns
a copy of this
NEMap
with the value atkey
replaced by the givenvalue
.
- def zipAll[O, V1 >: V](other: Iterable[O], thisElem: (K, V1), otherElem: O): NEMap[(K, V1), O]
Returns a
NEMap
formed from thisNEMap
and an iterable collection by combining corresponding entries in pairs.Returns a
NEMap
formed from thisNEMap
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.- O
the type of the second half of the returned pairs
- V1
the subtype of the value type of this
NEMap
- other
the
Iterable
providing the second half of each result pair- thisElem
the element to be used to fill up the result if this
NEMap
is shorter thanthat
Iterable
.- otherElem
the element to be used to fill up the result if
that
Iterable
is shorter than thisNEMap
.- returns
a new
NEMap
containing pairs consisting of corresponding entries of thisNEMap
andthat
. The length of the returned collection is the maximum of the lengths of thisNEMap
andthat
. If thisNEMap
is shorter thanthat
,thisElem
values are used to pad the result. Ifthat
is shorter than thisNEMap
,thatElem
values are used to pad the result.
- def zipWithIndex[V1 >: V]: NEMap[(K, V1), Int]
Zips this
NEMap
with its indices.Zips this
NEMap
with its indices.- returns
A new
NEMap
containing pairs consisting of all elements of thisNEMap
paired with their index. Indices start at 0.