FunctionMapJournal

com.phasmidsoftware.visitor.misc.FunctionMapJournal
See theFunctionMapJournal companion object
case class FunctionMapJournal[K, V](xs: Map[K, V])(f: K => V) extends AbstractMapJournal[K, V], FunctionMappedJournal[K, V]

FunctionMapJournal is a case class that represents a specialized implementation of AbstractMapJournal, which maintains a journal of key-value pairs along with a function that can derive values based on keys. It extends both AbstractMapJournal and FunctionMappedJournal, providing a combination of stateful journal behavior and functional operations.

Type parameters

K

the type of the keys in the journal

V

the type of the values in the journal

Value parameters

f

a function that, given a key, computes its corresponding value

xs

a map containing the initial key-value pairs in the journal

Attributes

Companion
object
Graph
Supertypes
trait Serializable
trait Product
trait Equals
trait FunctionMappedJournal[K, V]
trait K => V
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

Appends a new entry to the journal by applying the stored function f to the given key h. The resulting key-value pair is then appended to the internal map, producing a new instance of FunctionMapJournal that reflects the updated state.

Appends a new entry to the journal by applying the stored function f to the given key h. The resulting key-value pair is then appended to the internal map, producing a new instance of FunctionMapJournal that reflects the updated state.

Value parameters

k

the key for which the function f will be applied to generate its corresponding value

Attributes

Returns

a new FunctionMapJournal[K, V] instance containing the updated mapping

override def apply(key: K): V

Applies the function f to the given key and returns the resulting value. This method uses the stored function f to compute the value associated with the provided key. TESTME is this method ever actually invoked? It seems like we always invoke apply((K,V)) CONSIDER if this method isn't invoked, then we don't need the f parameter in the declaration.

Applies the function f to the given key and returns the resulting value. This method uses the stored function f to compute the value associated with the provided key. TESTME is this method ever actually invoked? It seems like we always invoke apply((K,V)) CONSIDER if this method isn't invoked, then we don't need the f parameter in the declaration.

Value parameters

key

the key for which the value is to be computed using the stored function f

Attributes

Returns

the value corresponding to the provided key, computed by the function f

Definition Classes
Function1 -> AbstractMapJournal
def close(): Unit
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

Inherited methods

def andThen[A](g: V => A): K => A

Composes two instances of Function1 in a new Function1, with this function applied first.

Composes two instances of Function1 in a new Function1, with this function applied first.

Type parameters

A

the result type of function g

Value parameters

g

a function R => A

Attributes

Returns

a new function f such that f(x) == g(apply(x))

Inherited from:
Function1
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

Inherited from:
AbstractMapJournal
def compose[A](g: A => K): A => V

Composes two instances of Function1 in a new Function1, with this function applied last.

Composes two instances of Function1 in a new Function1, with this function applied last.

Type parameters

A

the type to which function g can be applied

Value parameters

g

a function A => T1

Attributes

Returns

a new function f such that f(x) == apply(g(x))

Inherited from:
Function1
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
override def toString(): String

Returns a string representation of the object.

Returns a string representation of the object.

The default representation is platform dependent.

Attributes

Returns

a string representation of the object.

Definition Classes
Function1 -> Any
Inherited from:
Function1
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