David Bovill wrote:

2008/9/14 Richard Gaskin <ambassador at fourthworld.com>
For accessing specific elements from large collections, arrays outperform
any lineoffset in lists or any other method I can think of by several orders
of magnitude.*

Read, "It's a good hash mechanism". :)

When I need ordinal sequential access, I use ordinal keys.  Am I some sort
of freak?

Most of the time I need both with the same data - classic example would be
paragraphs of text with indented titles (an outline index) - or a tree of
objects and their properties. I want the data in a way in which I can
interact with the keys (titles in a hierarchical structure) - and display or
process the data (say a paragraph of text) asociated with that key.

Order sometimes does not matter = click display paragraph  - but often does
= reconstruct document. In short I want a simple data model which does both.
With sequentially ordered array keys we would have that.

I do a similar thing with processing sections of HTML in WebMerge, where I need to grab a page section with in a tag, do a lot of stuff with it, and tuck it back into that space to generate the final output. For those I use simple ordinal keys, and it's worked a treat for years.

Your case differs in that each element has two distinct things to keep track of: title and body.

In the olden days (pre v3) you might consider just using two arrays to retrieve the title and body for a given ordinal element:

  put tMyTitleA[5]
  put tMyBodyA[5]

In v3 it seems simple enough to use a single array by just having it use ordinal keys at its outermost level, and the elements within it are each their own two-element array, with their keys being "title" and "body", allowing you to instantly retrieve either for a given item easily:

  put tMyData[5]["title"]
  put tMyData[5]["body"]

- or -

  put tMyData[5] into tMySnippetA
  put tMySnippetA["title"]
  put tMySnippetA["body"]


Are there cases where putting your arrays inside of ordinal wrapper arrays would be problematic?

--
 Richard Gaskin
 Managing Editor, revJournal
 _______________________________________________________
 Rev tips, tutorials and more: http://www.revJournal.com
_______________________________________________
use-revolution mailing list
[email protected]
Please visit this url to subscribe, unsubscribe and manage your subscription 
preferences:
http://lists.runrev.com/mailman/listinfo/use-revolution

Reply via email to