773
774
// newOpNode creates a new operation tree node with the given key.
775
>
func newOpNode(key Key) *opNode {
tree.go
776
>
return &opNode{
777
>
key: key,
778
>
children: make(map[Key]*opNode),
779
>
}
780
>
}
781
782
// collect returns an ordered subset of the input operation log based on the deletion status tracked in this operation
783
// tree. The original chronological order of operations is preserved. The status of each node in the path (not just the
784
// operation's target) determines whether the operation is included in the result.
785
>
func (n *opNode) collect(oplog OperationLog) OperationLog {
tree.go
786
>
var result OperationLog
787
>
788
>
for _, op := range oplog {
789
>
path := op.Path()
790
>
current := n
791
>
792
>
var isAncestorDeleted bool
793
>
794
>
// Traverse the path to the target node, checking deletion status
795
>
for i, key := range path {
796
child, exists := current.children[key]
797
if !exists {