Re: [Scheme-reports] mutable unicode strings
John Cowan 02 Jul 2014 23:34 UTC
Per Bothner scripsit:
> When it comes to BuffersCowan, it seems reasonable enough. One comment:
> What is the point of point? I.e. the concept seems redundant if you have
> markers. In Emacs point is a special marker corresponding to the "current
> position", but I don't think that makes sense for a Scheme library API.
The idea of point is that it's where you can insert text into the buffer.
This reflects a classical buffer-gap implementation, in which the buffer
is a big array of characters, with everything before point left-justified
in the buffer, and everything after point right-justified. Therefore,
as long as the buffer doesn't overflow, inserting at point is O(k)
where k is the number of characters inserted, rather than O(n*k).
The trade-off is that shifting point by k characters is also O(k).
It is therefore optimized for inserting single characters and shifting
by a single character, both of which are O(1).
--
John Cowan http://www.ccil.org/~cowan cowan@ccil.org
There is no real going back. Though I may come to the Shire, it will
not seem the same; for I shall not be the same. I am wounded with
knife, sting, and tooth, and a long burden. Where shall I find rest?
--Frodo
_______________________________________________
Scheme-reports mailing list
Scheme-reports@scheme-reports.org
http://lists.scheme-reports.org/cgi-bin/mailman/listinfo/scheme-reports