Data Structure for Implementing Text Editor

Gap Buffer is one of the data structure that is used in the implementation of popular text editor "Notepad++". It is one of the frequently used data structure for text editors.
Gap Buffer is a dynamic array that allows insertion and deletion efficiently. Mostly changes took place in editors at the place where cursor is pointing at that time. Data is divided into two strings usually considering point at which cursor is located and one side of the gap is stored in one buffer and other side of the gap is stored in other buffer and as the cursor is moved so follows the text.

There is another data structure Rope which is binary tree having leaf nodes as small strings. In this, weight of the string i.e. length of the string is also stored. Each node has weight equal to the length of the string plus sum of all the weights of its left subtree. Thus a node with two children divides the whole string into two parts: the left subtree stores the first part of the string. The right sub tree stores the second part and its weight is the sum of the left child's weight and the length of its contained string.
 A rope, is a data structure composed of smaller strings that is used for efficiently storing and manipulating a very long string

Comments

Popular posts from this blog

Three mislabeled Jar

Difference between Macro And function