Re: Collections of structured-data objects: what approach?
- From: "Graham Wideman" <checkforrealaddress@xxxxxxxxxxxxxxxxx>
- Date: Fri, 25 Aug 2006 12:23:05 -0700
Robert:
Question and then a comment:
Question: What does the keyword "self" do when sitting on a line by itself,
as in several of your methods?
Comment:
For the sake of discussion I present a different approach. As long as
you don't need 4 (lookup by key) an Array is perfect. However, with the
lookup IMHO a new data structure is preferred because then consistency
can be handled internally. I'll attach a half grown quick hack to
demonstrate what I mean.
If I'm reading you correctly, you are saying a bit more than this:
1. For lookup (or for that matter if one want to implement a
SortedCollection), then it's desirable to have an index for the array on the
key field(s), which can be a ruby hash. (Ie: one *could* use Enumerable#find
or find_all, but on larger collections that's slow?)
2. But if you are going to implement an index using a helper hash, then you
want a way to keep the hash up-to-date as items are inserted or deleted from
the array.
3. So you advocate a class to wrap these together so that "consistency can
be handled internally".
Thanks for your reply,
Graham
--
---------------------------------------------------
Graham Wideman
Microsoft Visio MVP
---------------------------------------------------
Book/Tools:
Visio 2003 Developer's Survival Pack
Resources for programmable diagramming at:
http://www.diagramantics.com
.
- Follow-Ups:
- Re: Collections of structured-data objects: what approach?
- From: Robert Klemme
- Re: Collections of structured-data objects: what approach?
- From: Simen Edvardsen
- Re: Collections of structured-data objects: what approach?
- References:
- Collections of structured-data objects: what approach?
- From: Graham Wideman
- Re: Collections of structured-data objects: what approach?
- From: Robert Klemme
- Collections of structured-data objects: what approach?
- Prev by Date: Re: What does *var mean?
- Next by Date: Can you temporarily turn off STDERR ??
- Previous by thread: Re: Collections of structured-data objects: what approach?
- Next by thread: Re: Collections of structured-data objects: what approach?
- Index(es):
Relevant Pages
|
Loading