levsha
levsha copied to clipboard
Lists & keys support
Levsha sucks when inserting (or prepending) nodes in container with big number of children.
https://reactjs.org/docs/lists-and-keys.html
Pseudo code
if key < old_key then
node_insert_before(node, old_node)
move_old_pointer_back()
else key > old_key then
node_remove(old_node)
move_current_pointer_back()
else
compare_nodes()
val a = lhs.nextNode
val b = rhs.nextNode
val bb = rhs.nextNode
// 123 -> 0123
if a.key != b.key && a.key == bb.key then
node_insert_before(a, b)
rhs.back()
rhs.back()
// 1234 -> 134
else if a.key != b.key && a.key != bb.key then
node_remove(a)
rhs.back()
rhs.back()
else
compare_nodes()