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
IRC channel
GIT
Mailing List
Other languages
Foundation
Website
Useful Wiki Links
Project Roadmap
Getting the Source
Screenshots
How to use the forum
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
Forum slow
by
Curt Carpenter
[
Today
at 03:41:07 am]
Arabic text, problem on L...
by
Zaher
[
Today
at 03:29:16 am]
InstallAware Using Lazaru...
by
TRon
[
Today
at 02:55:41 am]
Generics - correct syntax
by
Blaazen
[
Today
at 01:57:40 am]
Demoscene The Champs Crac...
by
Gigatron
[
Today
at 01:05:16 am]
How to use the Event Log?
by
n7800
[
Today
at 12:47:25 am]
v3.99 code completion que...
by
440bx
[
Today
at 12:45:55 am]
FpDebug breakpoint on "be...
by
440bx
[
Today
at 12:36:23 am]
Access violation when re-...
by
TRon
[April 19, 2024, 11:44:51 pm]
[solved] how to get class...
by
jamie
[April 19, 2024, 11:34:44 pm]
Lazarus for Windows on aa...
by
Wallaby
[April 19, 2024, 10:52:25 pm]
Poll: Watches and Display...
by
440bx
[April 19, 2024, 07:13:51 pm]
Who is Indy mattias?
by
paweld
[April 19, 2024, 04:17:53 pm]
I just released a commerc...
by
BrassGear
[April 19, 2024, 03:17:28 pm]
Does anyone know why thes...
by
Laksen
[April 19, 2024, 03:04:14 pm]
Database standards OR Am ...
by
gidesa
[April 19, 2024, 02:37:56 pm]
How to: create DLL file f...
by
TRon
[April 19, 2024, 02:26:53 pm]
A fairly simple sound sol...
by
paweld
[April 19, 2024, 01:46:11 pm]
Access violation when ope...
by
Чебурашка
[April 19, 2024, 12:27:34 pm]
Step-into the field sette...
by
Martin_fr
[April 19, 2024, 11:31:48 am]
AI, NLP and CAI: Text Gen...
by
Dzandaa
[April 19, 2024, 11:03:26 am]
dwindows for Android
by
PierceNg
[April 19, 2024, 10:54:44 am]
create system unit from s...
by
Laksen
[April 19, 2024, 10:53:57 am]
[Solved] Find child contr...
by
Joanna
[April 19, 2024, 09:53:43 am]
FpDebug unexpected Assemb...
by
Marc
[April 19, 2024, 08:46:38 am]
« previous
next »
Print
Pages: [
1
]
Author
Topic: Ropes - An alternative to strings (Read 2660 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: 11453
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: 14373
Sensorship about opinions does not belong here.
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
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.
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: 14373
Sensorship about opinions does not belong here.
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
Object Pascal programmers should get rid of their "component fetish" especially with the non-visuals.
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