AbstractMapJournal

com.phasmidsoftware.visitor.misc.AbstractMapJournal
abstract class AbstractMapJournal[K, V](map: Map[K, V]) extends Journal[(K, V)]

An abstract class representing a map-based implementation of a Journal. This class provides mechanisms to manage key-value pairs immutably in a journal-like structure. It extends the Journal trait, implementing appendable and iterable behaviors.

The AbstractMapJournal relies on an underlying immutable Map to store key-value pairs, allowing retrieval, iteration, and the addition of elements in a functional style.

Type parameters

K

the type of keys maintained by this journal

V

the type of values associated with keys in this journal

Value parameters

map

the underlying immutable map containing the journal entries

Attributes

Constructor

Initializes the journal with an immutable map of key-value pairs

Graph
Supertypes
trait Journal[(K, V)]
trait Appendable[(K, V)]
trait AutoCloseable
class Object
trait Matchable
class Any
Show all
Known subtypes
class FunctionMapJournal[K, V]
class MapJournal[K, V]

Members list

Value members

Abstract methods

def unit(xs: Map[K, V]): AbstractMapJournal[K, V]

Creates a new instance of AbstractMapJournal with the given map.

Creates a new instance of AbstractMapJournal with the given map.

Value parameters

xs

the map to be used for initializing the new AbstractMapJournal instance

Attributes

Returns

a new instance of AbstractMapJournal containing the elements of the provided map

Concrete methods

def append(x: (K, V)): AbstractMapJournal[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

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

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

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

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

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 and Abstract methods

def close(): Unit

Attributes

Inherited from:
Journal