aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKoni Marti <koni.marti@gmail.com>2022-02-21 00:18:41 +0100
committerRobin Jarry <robin@jarry.cc>2022-02-23 21:09:01 +0100
commit5eac8d603e8807f7d4be58a4a7b03862a8c90df2 (patch)
treeec8cbcbe94eabd47ba81f57f0b7790092e3f88fc
parent8935c452939cd707d7bd060292da502157625fa4 (diff)
downloadaerc-5eac8d603e8807f7d4be58a4a7b03862a8c90df2.tar.gz
thread: add method to append new node
implement a method function for a *types.Thread receiver to append a new node to its linked list. Signed-off-by: Koni Marti <koni.marti@gmail.com>
-rw-r--r--worker/types/thread.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/worker/types/thread.go b/worker/types/thread.go
index 09f9dbb6..18b31e94 100644
--- a/worker/types/thread.go
+++ b/worker/types/thread.go
@@ -16,6 +16,19 @@ type Thread struct {
Deleted bool // if this flag is set the message was deleted
}
+func (t *Thread) AddChild(child *Thread) {
+ if t.FirstChild == nil {
+ t.FirstChild = child
+ } else {
+ var iter *Thread
+ for iter = t.FirstChild; iter.NextSibling != nil; iter = iter.NextSibling {
+ }
+ child.PrevSibling = iter
+ iter.NextSibling = child
+ }
+ child.Parent = t
+}
+
func (t *Thread) Walk(walkFn NewThreadWalkFn) error {
err := newWalk(t, walkFn, 0, nil)
if err == ErrSkipThread {