# all subtrees are kept as full trees. def add(new_write): # assume there is a sorted list of writes # merge this in. retain what the lengths of non-write data are to the left and right # if the writes trim non-write entries, then: # on the left, walk left-to-right, and on the right, walk right-to-left, covering the trimmed lengths # when between two writes, consider only the length that goes through the largest full tree between them: so as to leave smaller trees near the more distant write, to merge with a future flush, and not have unnecessary depth # there might be a little more to think about and adjust here, regarding producing these subtrees well. not sure. # when between a write and the edge of the data, consider the entire length # expand out full trees from the trimmed lengths, and merge them into the more distant full trees when they are equal or larger to those more distant full subtrees