ol
Version:
OpenLayers mapping library
131 lines • 3.12 kB
TypeScript
export default LRUCache;
export type Entry = {
key_: string;
newer: any;
older: any;
value_: any;
};
/**
* @typedef {Object} Entry
* @property {string} key_
* @property {Object} newer
* @property {Object} older
* @property {*} value_
*/
/**
* @classdesc
* Implements a Least-Recently-Used cache where the keys do not conflict with
* Object's properties (e.g. 'hasOwnProperty' is not allowed as a key). Expiring
* items from the cache is the responsibility of the user.
*
* @fires import("../events/Event.js").default
* @template T
*/
declare class LRUCache<T> {
/**
* @param {number=} opt_highWaterMark High water mark.
*/
constructor(opt_highWaterMark?: number);
/**
* @type {number}
*/
highWaterMark: number;
/**
* @private
* @type {number}
*/
private count_;
/**
* @private
* @type {!Object<string, Entry>}
*/
private entries_;
/**
* @private
* @type {?Entry}
*/
private oldest_;
/**
* @private
* @type {?Entry}
*/
private newest_;
/**
* @return {boolean} Can expire cache.
*/
canExpireCache(): boolean;
/**
* FIXME empty description for jsdoc
*/
clear(): void;
/**
* @param {string} key Key.
* @return {boolean} Contains key.
*/
containsKey(key: string): boolean;
/**
* @param {function(T, string, LRUCache<T>): ?} f The function
* to call for every entry from the oldest to the newer. This function takes
* 3 arguments (the entry value, the entry key and the LRUCache object).
* The return value is ignored.
*/
forEach(f: (arg0: T, arg1: string, arg2: LRUCache<T>) => any): void;
/**
* @param {string} key Key.
* @param {*=} opt_options Options (reserverd for subclasses).
* @return {T} Value.
*/
get(key: string, opt_options?: any): T;
/**
* Remove an entry from the cache.
* @param {string} key The entry key.
* @return {T} The removed entry.
*/
remove(key: string): T;
/**
* @return {number} Count.
*/
getCount(): number;
/**
* @return {Array<string>} Keys.
*/
getKeys(): string[];
/**
* @return {Array<T>} Values.
*/
getValues(): T[];
/**
* @return {T} Last value.
*/
peekLast(): T;
/**
* @return {string} Last key.
*/
peekLastKey(): string;
/**
* Get the key of the newest item in the cache. Throws if the cache is empty.
* @return {string} The newest key.
*/
peekFirstKey(): string;
/**
* @return {T} value Value.
*/
pop(): T;
/**
* @param {string} key Key.
* @param {T} value Value.
*/
replace(key: string, value: T): void;
/**
* @param {string} key Key.
* @param {T} value Value.
*/
set(key: string, value: T): void;
/**
* Set a maximum number of entries for the cache.
* @param {number} size Cache size.
* @api
*/
setSize(size: number): void;
}
//# sourceMappingURL=LRUCache.d.ts.map