Hasty Briefsbeta

Bilingual

Show HN: Slice-tree – A piece table data structure implemented using RB tree

a year ago
  • #javascript
  • #data-structures
  • #text-editing
  • A piece table is a data structure used in text editors to represent a document during editing.
  • It starts with a reference to the entire original file and updates with inserts and deletes.
  • The SliceTree class is implemented using a piece table structure with methods for text manipulation.
  • Methods include creating a SliceTree instance, counting characters and lines, reading text, and modifying content.
  • Examples demonstrate how to use SliceTree for text operations like writing, reading, and erasing text.