in scala/collection/immutable
class ListMap
-
class ListMap[A,B]()
- extends Object
- with ScalaObject
- with Map[A,B]
-
Implementing classes or objects:
-
class Node(key: A, value: B) in scala/collection/immutable/ListMap-class
-
This class implements immutable maps using a list-based data
structure. Instances of
ListMap
represent
empty maps; they can be either created by calling the constructor
directly, or by applying the function ListMap.Empty
.
- Author:
-
Matthias Zenger
- Version:
-
1.0, 09/07/2003
Method Summary
|
|
def -(key: A): ListMap[A,B]
This creates a new mapping without the given key .
|
|
def elements: Iterator[Tuple2[A,B]]
This returns an iterator over key-value pairs.
|
|
def empty[C]: ListMap[A,C]
This method returns a new ListMap instance mapping keys of the
same type to values of type C .
|
override
|
def equals(obj: Any): Boolean
Compares two maps for equality.
|
|
def get(key: A): Option[B]
Check if this map maps key to a value and return the
value if it exists.
|
override
|
def hashCode(): Int
|
|
def size: Int
Returns the number of mappings in this map.
|
override
|
def toList: List[Tuple2[A,B]]
This return a list of key-value pairs.
|
|
def update(key: A, value: B): ListMap[A,B]
This method allows one to create a new map with an
additional mapping from key
to value .
|
Methods inherited from java/lang/Object-class
|
clone, eq, finalize, getClass, ne, notify, notifyAll, synchronized, wait, wait, wait |
Class Summary
|
protected
|
class Node(key: A, value: B)
|
empty
def empty[C]: ListMap[A,C]
-
This method returns a new ListMap instance mapping keys of the
same type to values of type
C
.
size
def size: Int
-
Returns the number of mappings in this map.
- Returns:
-
number of mappings.
get
def get(key: A): Option[B]
-
Check if this map maps
key
to a value and return the
value if it exists.
- Parameters:
key
-
the key of the mapping of interest
- Returns:
-
the value of the mapping, if it exists
update
def update(key: A, value: B): ListMap[A,B]
-
This method allows one to create a new map with an
additional mapping from
key
to value
. If the map contains already a
mapping for key
, it will be overridden by this
function.
-
def -(key: A): ListMap[A,B]
-
This creates a new mapping without the given
key
.
If the map does not contain a mapping for the given key, the
method returns the same map.
elements
def elements: Iterator[Tuple2[A,B]]
-
This returns an iterator over key-value pairs.
toList
override def toList: List[Tuple2[A,B]]
-
This return a list of key-value pairs.
equals
override def equals(obj: Any): Boolean
-
Compares two maps for equality.
Two maps are equal iff they contain exactly the
same key-value pairs.
hashCode
override def hashCode(): Int