CachedUnificator
A Unificator decorator that memoizes the results of mgu and merge calls made on decorated, in a shared LRU cache of at most cacheCapacity entries, so that repeated calls with the same arguments (including the same occurCheckEnabled flag) are served from the cache instead of being recomputed.
Since Unificator.match and Unificator.unify are, by default, defined in terms of Unificator.mgu, they too benefit from the cache transitively — no separate caching is performed for them.
Cache keys are built from term1/term2 (or the two Substitutions, for merge) compared via Term.equals/ Substitution.equals; two structurally equal but distinct term/substitution instances therefore share a cache entry. This class is safe for concurrent use from multiple threads: the underlying cache synchronizes its access.
Instances are normally created through Unificator.cached rather than directly, since that factory also avoids double-wrapping an already-cached Unificator.
Parameters
the Unificator whose results are being cached
Properties
Functions
Returns the cached result for (substitution1, substitution2, occurCheckEnabled), computing and caching it if absent. Shares the same underlying LRU cache (and thus the same cacheCapacity budget) as mgu.
Merges substitution1 and substitution2, with occurs-check enabled.
Returns the cached result for (term1, term2, occurCheckEnabled), computing and caching it if absent.