CPCache

final class CPCache(delayedQ: ArrayBuffer[() => Unit])

A map-like type that is used by CPSceneObjectContext for game-wide and scene-wide user-data containers.

The instances of this class are created and managed by the game engine and available via CPSceneObjectContext.getSceneCache and CPSceneObjectContext.getGameCache methods. Scene and game caches can be used to exchange and store user-defined data between frames of the same scene or between scenes of the game. Note that by default these caches are in-memory only and not persistent between game executions. One coule, however, add persistence using one of the lifecycle methods available through CPLifecycle type that is extended by both CPSceneObject and CPScene types.

Note that all mutating operations will be queued up and executed at the end of the current frame processing. Specifically, any changes will be "visible" to other scene objects only on the next frame.

Value parameters:
delayedQ

Queue for delayed operations. Used internally by the game engine.

See also:
Source:
CPCache.scala
class Object
trait Matchable
class Any

Value members

Concrete methods

def apply[T](key: String): T

Retrieves the value which is associated with the given key.

Retrieves the value which is associated with the given key.

Value parameters:
key

The key.

Throws:
NoSuchElementException

Thrown if there is no mapping for given key.

Source:
CPCache.scala
def clear(): Unit

Removes all mappings from this cache.

Removes all mappings from this cache.

Note that all mutating operations will be queued up and executed at the end of the current frame processing. Specifically, any changes will be "visible" to other scene objects only on the next frame.

Source:
CPCache.scala
def contains(key: String): Boolean

Tests whether this cache contains a binding for a key.

Tests whether this cache contains a binding for a key.

Value parameters:
key

The key.

Source:
CPCache.scala
def filterInPlace(f: (String, AnyRef) => Boolean): Unit

Retains only those mappings for which the predicate f returns true.

Retains only those mappings for which the predicate f returns true.

Note that all mutating operations will be queued up and executed at the end of the current frame processing. Specifically, any changes will be "visible" to other scene objects only on the next frame.

Value parameters:
f

The test predicate.

Source:
CPCache.scala
def get[T](key: String): Option[T]

Optionally returns the value associated with a key.

Optionally returns the value associated with a key.

Value parameters:
key

Key value.

Returns:

An option value containing the value associated with key in this cache, or None if none exists.

Source:
CPCache.scala
def isEmpty: Boolean

Tests whether the cache is empty.

Tests whether the cache is empty.

Returns:

true if the cache contains no elements, false otherwise.

Source:
CPCache.scala
def iterator: Iterator[(String, AnyRef)]

Gets iterator can be used only once.

Gets iterator can be used only once.

Source:
CPCache.scala
def mapValuesInPlace(f: (String, AnyRef) => AnyRef): Unit

Applies a transformation function to all values contained in this cache. The transformation function produces new values from existing keys associated values.

Applies a transformation function to all values contained in this cache. The transformation function produces new values from existing keys associated values.

Note that all mutating operations will be queued up and executed at the end of the current frame processing. Specifically, any changes will be "visible" to other scene objects only on the next frame.

Value parameters:
f

The transformation to apply

Source:
CPCache.scala
def put(key: String, value: AnyRef): Unit

Adds a new key/value pair to this cache. If the map already contains a mapping for the key, it will be overridden by the new value.

Adds a new key/value pair to this cache. If the map already contains a mapping for the key, it will be overridden by the new value.

Note that all mutating operations will be queued up and executed at the end of the current frame processing. Specifically, any changes will be "visible" to other scene objects only on the next frame.

Value parameters:
key

The key to update.

value

The new value.

Source:
CPCache.scala
def remove(key: String): Unit

Removes a key from this cache.

Removes a key from this cache.

Note that all mutating operations will be queued up and executed at the end of the current frame processing. Specifically, any changes will be "visible" to other scene objects only on the next frame.

Value parameters:
key

The key to be removed.

Source:
CPCache.scala