MapJournal

com.phasmidsoftware.visitor.misc.MapJournal
See theMapJournal companion object
case class MapJournal[K, V](map: Map[K, V]) extends AbstractMapJournal[K, V]

A MapJournal is a concrete implementation of the Journal trait that maintains a collection of elements represented as key-value pairs using a Map.

This class provides functionality to append new elements, retrieve elements by key, and iterate over the contents of the journal. It ensures immutability by returning a new instance when modifications, such as appending, are performed.

Type parameters

K

the type of keys maintained by the map

V

the type of values associated with the keys

Value parameters

map

the underlying map storing the key-value pairs of the journal

Attributes

Companion
object
Graph
Supertypes
trait Serializable
trait Product
trait Equals
class AbstractMapJournal[K, V]
trait Journal[(K, V)]
trait Appendable[(K, V)]
trait AutoCloseable
class Object
trait Matchable
class Any
Show all

Members list

Value members

Concrete methods

override def append(x: (K, V)): MapJournal[K, V]

Appends the specified element to this Appendable object, returning a new instance of the Appendable with the element included.

Appends the specified element to this Appendable object, returning a new instance of the Appendable with the element included.

Value parameters

x

the element to be appended

Attributes

Returns

a new Appendable[X] instance containing the existing elements and the newly appended element

Definition Classes
def close(): Unit
def unit(xs: Map[K, V]): MapJournal[K, V]

Creates a new MapJournal instance containing the specified key-value pairs.

Creates a new MapJournal instance containing the specified key-value pairs.

This method is a utility for constructing a MapJournal from an existing Map.

Value parameters

xs

the key-value pairs to be included in the new MapJournal

Attributes

Returns

a new instance of MapJournal containing the provided key-value pairs

Inherited methods

def apply(key: K): V

Retrieves the value associated with the specified key from the underlying map.

Retrieves the value associated with the specified key from the underlying map.

Value parameters

key

the key to look up in the map

Attributes

Returns

the value associated with the specified key

Throws
NoSuchElementException

if the key does not exist in the map

Inherited from:
AbstractMapJournal
def entries: Iterable[(K, V)]

Retrieves the entries of the underlying map as an iterable collection of key-value pairs.

Retrieves the entries of the underlying map as an iterable collection of key-value pairs.

Attributes

Returns

an Iterable containing all key-value pairs present in the map

Inherited from:
AbstractMapJournal
def get(key: K): Option[V]

Retrieves the value associated with the specified key from the underlying map.

Retrieves the value associated with the specified key from the underlying map.

Value parameters

key

the key to look up in the map

Attributes

Returns

an Option containing the value associated with the key, or None if the key does not exist

Inherited from:
AbstractMapJournal
def keys: Iterable[K]

Retrieves the keys of the underlying map as an iterable collection.

Retrieves the keys of the underlying map as an iterable collection.

Attributes

Returns

an Iterable containing all the keys present in the map

Inherited from:
AbstractMapJournal
def productElementNames: Iterator[String]

An iterator over the names of all the elements of this product.

An iterator over the names of all the elements of this product.

Attributes

Inherited from:
Product
def productIterator: Iterator[Any]

An iterator over all the elements of this product.

An iterator over all the elements of this product.

Attributes

Returns

in the default implementation, an Iterator[Any]

Inherited from:
Product
def values: Iterable[V]

Retrieves the values of the underlying map as an iterable collection.

Retrieves the values of the underlying map as an iterable collection.

Attributes

Returns

an Iterable containing all the values present in the map

Inherited from:
AbstractMapJournal