StateCache

public final class StateCache<PositionType, KeyType, CachedType> : CustomStringConvertible where PositionType : Comparable, KeyType : Hashable

A generic cache that can be used in your own IntermediateRepresentation

  • Creates a new instance of the cache

    Declaration

    Swift

    public init(memorySize: Int, breadth: Int)

    Parameters

    memory

    The requied memroy size

    breadth

    The required depth of the cache

  • Adds new entry to the cache. This may knock out something already in the cache.

    Declaration

    Swift

    public func remember(at position: PositionType, key: KeyType, value: CachedType)

    Parameters

    at

    The position for the cached entry

    key

    The key for the entry

    value

    The value to be cached

  • Retreives the cached entry with the specified key and position if any

    Declaration

    Swift

    public func recall(at position: PositionType, key: KeyType) -> CachedType?

    Parameters

    at

    The position

    key

    The desired key

    Return Value

    The entry at that position with that key or nil if nothing is cached

  • A human readable description of the cache

    Declaration

    Swift

    public var description: String { get }