IndexTreeNode

abstract class IndexTreeNode<T : IndexTreeNode<T>>

IndexTreeNode is the node of IndexTree. It is used to represent the document of text-based editors.

Constructors

Link copied to clipboard
constructor()

Types

Link copied to clipboard
object Companion
Link copied to clipboard

Properties

Link copied to clipboard

Returns the children of the node including tombstones.

Link copied to clipboard

Returns the children of the node. Tombstone nodes remain awhile in the tree during editing. They will be removed after the editing is done. So, we need to filter out the tombstone nodes to get the real children.

Link copied to clipboard
abstract val dataSize: DataSize
Link copied to clipboard

Returns true if the node's children consist of only text children.

Link copied to clipboard
abstract val isRemoved: Boolean
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
var parent: T?
Link copied to clipboard
Link copied to clipboard
Link copied to clipboard
abstract val type: String
Link copied to clipboard
abstract var value: String
Link copied to clipboard

Functions

Link copied to clipboard
fun append(node: T)

Appends the given node to the children.

Link copied to clipboard
abstract fun cloneElement(issueTimeTicket: () -> TimeTicket): T

Clones the element node with the given issueTimeTicket lambda and value.

Link copied to clipboard
abstract fun cloneText(offset: Int): T

Clones the text node with the given id and value.

Link copied to clipboard
fun findOffset(node: T, includeRemoved: Boolean = false): Int

Returns the offset of the given node in the children. If includeRemoved is true, it includes removed nodes in the calculation.

Link copied to clipboard

getChildrenText returns text value of all text type children.

Link copied to clipboard
fun insertAfter(targetNode: T, newNode: T)

Inserts the newNode after the targetNode.

Link copied to clipboard
fun insertAt(offset: Int, newNode: T)

Inserts the newNode at the given offset.

Link copied to clipboard
fun insertBefore(targetNode: T, newNode: T)

Inserts the newNode before the targetNode.

Link copied to clipboard
fun paddedSize(includeRemoved: Boolean = false): Int

Returns the length of the node including padding. If includeRemoved is true, it includes removed nodes in the calculation.

Link copied to clipboard
fun prepend(node: T)

Prepends the given node to the children.

Link copied to clipboard
fun removeChild(child: T)

Removes the given child (physically purges it from the tree).

Link copied to clipboard
fun splitElement(offset: Int, issueTimeTicket: () -> TimeTicket): Pair<T?, DataSize>
Link copied to clipboard
fun splitText(offset: Int, absOffset: Int): Pair<T?, DataSize>
Link copied to clipboard
fun updateAncestorSize(delta: Int, includeRemoved: Boolean = false)

Updates the size of the ancestors. It is used when the size of the node is changed. If includeRemoved is true, it updates ancestors totalSize including removed nodes.

Link copied to clipboard
fun updateDescendantSize(includeRemoved: Boolean = false): Int

Updates the size of the descendants. It is used when the tree is newly created and the size of the descendants is not calculated. If includeRemoved is true, it includes removed nodes in the calculation.