[gedit-list] Data structure for holding large text files



-
 Hi,

 I have developed a data structure that might be of your interest. I
think it's perfect for holding large text files data in a very simple
way.

 I've taken a fast look to your code and I still don't have a clear
idea of what data structure are you using (list, tree, array...), so
if ti is the same, or yours is better, sorry. Though, I sincerely
believe that this can be interesting.

 The data structure I propose is a generic C++STL-like sequence
container with fast random access and fast insertion/removal (all
O(log n)). That is: like a std::vector, with indexes ranging from 0 to
size-1, but with fast insertion/removal (and a not so lightning fast
random access, but still pretty good).

 Additionally, this data structure provides what I call
"Non-Proportional Sequence View" (NPSV), which is some kind of index
where elements can occupy positions of any size. Each element has an
associated width that can be changed on the fly in O(log n) time. The
position of every element is the sum of the widths of all previous
elements in the sequence. For any given element, this position can be
retrieved in O(log n) time. The reverse (reaching the element of a
given position) takes also O(log n) time.

 Why am I telling you all of this? Well, let's say that you use this
container for holding one long-line (a paragraph) per element. You can
use the width for the number of lines actually required for displaying
the paragraph. The normal index can be used to show the number of the
current line (counting every paragraph as one) and for the "go to
line..." command. The NPSV index can be used associated with the
scroll bar. When the user inserts text (writing), inserting elements
takes only logarithmic time. The same when the user deletes lines.
When the user moves the scroll bar, jumping to, say position 80%, the
corresponding data can be found in logarithmic time (with the NPSV
index). When the user resizes the window, you can readjust lines (and
change widths) of the visible text on the fly, and when the user
releases the mouse, you can readjust the rest and update all widths in
the background, updating the scroll bar position at the end.

 What do you think?

 Oh, by the way, here is the 'thing':

   http://sourceforge.net/projects/avl-array

 I hope I didn't make you loose your time. Thanks for your attention,

 Martín Knoblauch Revuelta



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]