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
About donations (wiki)
Bookstore
Computer Math and Games in Pascal
(preview)
Lazarus Handbook
Search
Advanced search
Recent
Memory Safety and Object ...
by
BlueIcaro
[
Today
at 04:07:49 pm]
Random ?
by
Zoran
[
Today
at 04:07:37 pm]
Spaces are allowed here ?
by
Thaddy
[
Today
at 04:06:29 pm]
[Solved] A Tip for beginn...
by
Ten_Mile_Hike
[
Today
at 03:55:00 pm]
Error 403 downloading wit...
by
Thaddy
[
Today
at 03:09:31 pm]
API on intranet - auth im...
by
MarkMLl
[
Today
at 02:17:27 pm]
Making sense of pparser, ...
by
Thaddy
[
Today
at 01:09:44 pm]
مشكلة في التقارير
by
nouzi
[
Today
at 12:47:27 pm]
Artificial intelligence
by
MarkMLl
[
Today
at 12:31:46 pm]
[SOLVED] Treeview flicker...
by
d7_2_laz
[
Today
at 12:13:44 pm]
No access to the wiki
by
dseligo
[
Today
at 12:01:01 pm]
UK's Online Safety Act
by
Joanna from IRC
[
Today
at 11:37:49 am]
SQL update statement and ...
by
Zvoni
[
Today
at 11:03:07 am]
D2Bridge Framework for La...
by
nummer8
[
Today
at 09:53:00 am]
Preparing FPC 3.2.4, poin...
by
AlexTP
[
Today
at 09:25:09 am]
IContainers
by
cdbc
[
Today
at 08:36:34 am]
Using Tesseract without i...
by
Thaddy
[
Today
at 07:41:06 am]
GR32 GR_Bindings problem
by
staratel20
[
Today
at 12:50:04 am]
built IDE for qt5
by
HotShoe
[
Today
at 12:37:22 am]
Nested declarations insid...
by
Joanna from IRC
[
Today
at 12:29:42 am]
Install OOPsie
by
johnsg
[January 19, 2025, 10:48:06 pm]
Lazarus Release Candidate...
by
baldzhang
[January 19, 2025, 05:53:07 pm]
const declaration
by
marcov
[January 19, 2025, 04:51:08 pm]
Migrate vb.net to Lazarus...
by
gidesa
[January 19, 2025, 02:50:02 pm]
Amigo programming languag...
by
maurog
[January 19, 2025, 02:47:35 pm]
« previous
next »
Print
Pages: [
1
]
Author
Topic: Ropes - An alternative to strings (Read 2927 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: 11990
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: 16381
Censorship 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
There is nothing wrong with being blunt. At a minimum it is also honest.
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: 16381
Censorship 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
There is nothing wrong with being blunt. At a minimum it is also honest.
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