-
Notifications
You must be signed in to change notification settings - Fork 0
NodeStorageProtocol
public protocol NodeStorageProtocol: CustomStringConvertible
CustomStringConvertible
Current working root (unless just reset or committed, not committed yet)
var root: Node
Current working version (not committed yet)
var version: Int64
Orphans organized by version All available versions from the Storage
var versions: [Int64]
Get the root node at provided version.
func root(at version: Int64) throws -> Node?
- version: requested version number
the corresponding root node or nil if doesn't exist
func get(key: Key, at version: Int64) throws -> (index: Int64, value: Value?)
func get(index: Int64, at version: Int64) throws -> (key: Key, value: Value)?
func has(key: Key, at version: Int64) throws -> Bool
func next(key: Key, at version: Int64) throws -> Key?
func get(key: Key) throws -> (index: Int64, value: Value?)
func get(index: Int64) throws -> (key: Key, value: Value)?
func has(key: Key) throws -> Bool
func next(key: Key) throws -> Key?
Deletes the last saved version, adjusts the current version number accordingly It will delete the root and the orphans The current version is set to the deleted version, and the current orphans are set to the orphans of the deleted version
func deleteLast() throws
Deletes all versions from version from
onwards.
The roots and orphans are adjusted as if deleteLast() was called as many times as needed to reach version from
The current version is set to from, as well as corresponding orphans list.
func deleteAll(from: Int64) throws
Rolls back all changes to the tree since last save.
That means that the root is now the same as the root as of version - 1
and the orphans list for version version
is empty
version
remains as is
func rollback()
Commits changes to the tree by saving them in the backing Storage.
version
is incremented, current root is set to just saved version and orphans for this version is set to empty.
func commit() throws
var description: String
Adds or Updates a leaf in the tree and recalculates (hashes, size, height, balancing) the tree when required. When the item is updated, will return true. Returns false otherwise This will lead to updating the tree and orphans for the current version
func set(key: Key, value: Value) throws -> Bool
Removes the leaf with key key
if it exists.
If the leaf exists, removes the leaf node, returns its value and true
and rebalances the tree as needed
it also adjusts as hashes, size and height where needed.
If the leaf doesn't exist, returns nil fort he value and false for the removed boolean.
func remove(key: Key) -> (Value?, Bool)
func makeEmpty() -> Node
func makeLeaf(key: Key, value: Value) -> Node
func makeInner(key: Key, left: Node, right: Node) -> Node
Generated at 2021-04-20T11:34:45+0000 using swift-doc 1.0.0-beta.5.