Lazarus
Home
Help
TinyPortal
Search
Login
Register
Lazarus
»
Forum
»
Programming
»
General
»
Ropes - An alternative to strings
Free Pascal
Website
Downloads
Wiki
Documentation
Bugtracker
Mailing List
Lazarus
Website
Downloads (Laz+FPC)
Packages (OPM)
FAQ
Wiki
Documentation (RTL/FCL/LCL)
Bugtracker
CCR Bugs
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
Forum Rules
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
Postgres, ZEOS and Visual...
by
calebs
[
Today
at 04:48:18 am]
Feature announcement: Fun...
by
wfbhappy
[
Today
at 02:44:42 am]
[SOLVED] Strange behavior...
by
jamie
[
Today
at 12:08:12 am]
ThemeServices.OnThemeChan...
by
sgj
[January 18, 2026, 10:37:32 pm]
AVRPascal – free code edi...
by
ackarwow
[January 18, 2026, 10:18:12 pm]
Developing FreePascal on ...
by
ccrause
[January 18, 2026, 09:34:54 pm]
help implementing frexp
by
srvaldez
[January 18, 2026, 09:25:07 pm]
my implementation of frex...
by
srvaldez
[January 18, 2026, 06:27:39 pm]
Rolling releases Lazarus[...
by
Martin_fr
[January 18, 2026, 04:37:42 pm]
Strings in Free Pascal: I...
by
PascalDragon
[January 18, 2026, 04:13:36 pm]
Question about optimizer ...
by
PascalDragon
[January 18, 2026, 04:01:54 pm]
Adjacent rectangles not a...
by
jamie
[January 18, 2026, 02:36:34 pm]
Very simple Style Manager...
by
sgj
[January 18, 2026, 02:21:54 pm]
How to set the Excel cell...
by
dodgex
[January 18, 2026, 02:06:25 pm]
PeaZip project turns 20 t...
by
JanRoza
[January 18, 2026, 01:57:46 pm]
How to implement multiple...
by
bills
[January 18, 2026, 01:26:29 pm]
AdvancedHTTPServer: A Go-...
by
CynicRus
[January 18, 2026, 12:48:43 pm]
RPNCalc in Lazarus
by
jwdietrich
[January 18, 2026, 12:13:43 pm]
Is this Pascal Compiler t...
by
HKPhysicist
[January 18, 2026, 11:11:59 am]
Maze Makers: Modified Cyl...
by
Boleeman
[January 18, 2026, 08:51:29 am]
Olympic Rings (Interleave...
by
Boleeman
[January 18, 2026, 04:28:24 am]
Unit decfloat
by
MathMan
[January 17, 2026, 08:29:41 pm]
Funny
by
Ten_Mile_Hike
[January 17, 2026, 08:18:39 pm]
New book on Object Pascal
by
Ten_Mile_Hike
[January 17, 2026, 07:34:06 pm]
New open source component...
by
salvadordf
[January 17, 2026, 06:26:56 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: Ropes - An alternative to strings (Read 3280 times)
A3aan
Newbie
Posts: 3
Ropes - An alternative to strings
«
on:
October 23, 2018, 10:22:49 am »
Hi Everyone
,
When searching for an efficient way to handle long texts I stumbled on this Wikipedia article:
https://en.wikipedia.org/wiki/Rope_(data_structure)
After reading I decided to implement the Rope data type as a unit so Ropes could be used as an alternative to Strings. Ropes have an advantage over Strings when texts grow large since they reduce the amount of data movement when inserting or deleting parts of the text. Also the implementation uses a reference counting scheme to avoid unnecessary duplication of text fragments. This behavior is often desired in word processing when multiple versions of the text must be held in memory to allow for recovering from erroneous changes.
The Ropes unit, documentation, and a demo in the form of a small text editor program can be found here:
http://home.hccnet.nl/fam.rappard/adriaan/fpc/ropes.zip
Hope you like it
Adriaan Rappard
«
Last Edit: October 23, 2018, 10:35:54 am by A3aan
»
Logged
marcov
Administrator
Hero Member
Posts: 12593
FPC developer.
Re: Ropes - An alternative to strings
«
Reply #1 on:
October 23, 2018, 10:34:34 am »
Can't load the link. The correct link should be
http://home.hccnet.nl/fam.rappard/adriaan/fpc/Ropes.zip
Afaik many better programming oriented texteditors use a similar structure, but in general will be more line oriented. (since they don't display endless continuous text, but texts broken up in lines).
At least that is what Martin tried to explain to me about the lazarus editor implementation once :_)
«
Last Edit: October 23, 2018, 11:57:15 am by marcov
»
Logged
A3aan
Newbie
Posts: 3
Re: Ropes - An alternative to strings
«
Reply #2 on:
October 23, 2018, 10:42:04 am »
Hi marcov,
Thanx! I corrected the link
.
Logged
Thaddy
Hero Member
Posts: 18676
Jungle wars. And failing health it seems.
Re: Ropes - An alternative to strings
«
Reply #3 on:
October 23, 2018, 11:50:21 am »
I learned it as "cord". It is based on a Trie, not tree, and not very memory efficient on long texts, so it needs a windowing scheme too.
Logged
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.
sash
Sr. Member
Posts: 366
Re: Ropes - An alternative to strings
«
Reply #4 on:
October 23, 2018, 01:44:31 pm »
> when multiple versions of the text must be held in memory to allow for recovering from erroneous changes
IMO you should not hold multiple versions (as a full snapshot copies). It is enough to keep some base version, current version and set of replayable/undoable changes between them.
Logged
Lazarus 2.0.10 FPC 3.2.0 x86_64-linux-gtk2 @
Ubuntu
20.04
XFCE
Thaddy
Hero Member
Posts: 18676
Jungle wars. And failing health it seems.
Re: Ropes - An alternative to strings
«
Reply #5 on:
October 23, 2018, 03:06:47 pm »
Yes, sash. That's exactly what this does. Speed efficient at the cost of space.
Logged
Due to censorship, I changed this to "Nelly the Elephant". Keeps the message clear.
A3aan
Newbie
Posts: 3
Re: Ropes - An alternative to strings
«
Reply #6 on:
October 23, 2018, 04:29:20 pm »
Yes, you're right. If you want to see how much faster at what memory cost download the zip file and read page 16 and 17 of the reference guide (Ropes.pdf)
.
Logged
Print
Pages: [
1
]
« previous
next »
Lazarus
»
Forum
»
Programming
»
General
»
Ropes - An alternative to strings
TinyPortal
© 2005-2018