Saturday, February 15, 2014

Rope Datastructure

This post will handle specially bout the Rope Data structure.
Rope is a data structure to hold a single string of characters. Yes, it is correct, that Rope holds only the characters which are represented in a string. Why any one on the earth wants a special data structure to hold the characters in a string where a contiguous chunk of bytes in memory is sufficient. Well,  Rope is designed to optimise mainly three operations on the string.

  1. Adding a new character to the String, 
  2. Deleting a character from the string, 
  3. Concatenating two strings.                            
   The above mentioned operations are performed well compared on Rope to traditional String implementations. Who in the earth wants to optimise the above mentioned operations. Well think about the text editors. How will you store the constantly changing the text data in the text editor. If you are using String,  then you will be spending a lot of time copying the data in the memory for every new single character.
Here is an excellent article on Rope Datastructure. Thanks to IBM Developer works.

No comments:

Post a Comment