owltech
Version:
This a backend for OwlTech Company
72 lines (71 loc) • 2.37 kB
TypeScript
/**
* @license
* Copyright 2017 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
import { Path } from './util/Path';
import { Node } from './snap/Node';
/**
* Helper class to store a sparse set of snapshots.
*
* @constructor
*/
export declare class SparseSnapshotTree {
/**
* @private
* @type {Node}
*/
private value_;
/**
* @private
* @type {CountedSet}
*/
private children_;
/**
* Gets the node stored at the given path if one exists.
*
* @param {!Path} path Path to look up snapshot for.
* @return {?Node} The retrieved node, or null.
*/
find(path: Path): Node | null;
/**
* Stores the given node at the specified path. If there is already a node
* at a shallower path, it merges the new data into that snapshot node.
*
* @param {!Path} path Path to look up snapshot for.
* @param {!Node} data The new data, or null.
*/
remember(path: Path, data: Node): void;
/**
* Purge the data at path from the cache.
*
* @param {!Path} path Path to look up snapshot for.
* @return {boolean} True if this node should now be removed.
*/
forget(path: Path): boolean;
/**
* Recursively iterates through all of the stored tree and calls the
* callback on each one.
*
* @param {!Path} prefixPath Path to look up node for.
* @param {!Function} func The function to invoke for each tree.
*/
forEachTree(prefixPath: Path, func: (a: Path, b: Node) => any): void;
/**
* Iterates through each immediate child and triggers the callback.
*
* @param {!Function} func The function to invoke for each child.
*/
forEachChild(func: (a: string, b: SparseSnapshotTree) => void): void;
}