Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/json-crdt-patch/PatchLog.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import {Patch} from "@automerge/automerge";
import {AvlMap} from "../util/trees/avl/AvlMap";

export class PatchLog {
/**
* Patch index by [sid, time].
*/
private index = new AvlMap<number, AvlMap<number, Patch>>();

public push(patch: Patch) {}

}
8 changes: 8 additions & 0 deletions src/util/trees/avl/AvlMap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ export class AvlMap<K, V> implements Printable {
return item;
}

/**
* Inserts a new node with the given key and value. If a node with the given
* key already exists, its value is updated.
*
* @param k Key
* @param v Value
* @returns Reference to the node with the given key.
*/
public set(k: K, v: V): AvlNodeReference<AvlNode<K, V>> {
const root = this.root;
if (!root) return this.insert(k, v);
Expand Down