From 48f86d75896833592308913b1ea133bb2a65119f Mon Sep 17 00:00:00 2001
From: streamich <streamich@gmail.com>
Date: Sat, 11 Nov 2023 23:28:02 +0100
Subject: [PATCH] =?UTF-8?q?chore:=20=F0=9F=A4=96=20start=20PatchLog=20impl?=
 =?UTF-8?q?ementation?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

---
 src/json-crdt-patch/PatchLog.ts | 12 ++++++++++++
 src/util/trees/avl/AvlMap.ts    |  8 ++++++++
 2 files changed, 20 insertions(+)
 create mode 100644 src/json-crdt-patch/PatchLog.ts

diff --git a/src/json-crdt-patch/PatchLog.ts b/src/json-crdt-patch/PatchLog.ts
new file mode 100644
index 0000000000..d2bc3543cb
--- /dev/null
+++ b/src/json-crdt-patch/PatchLog.ts
@@ -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) {}
+
+}
diff --git a/src/util/trees/avl/AvlMap.ts b/src/util/trees/avl/AvlMap.ts
index d0b3751f12..a47856dfd1 100644
--- a/src/util/trees/avl/AvlMap.ts
+++ b/src/util/trees/avl/AvlMap.ts
@@ -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);