home *** CD-ROM | disk | FTP | other *** search
- Xref: sparky comp.object:2969 comp.programming:2063
- Newsgroups: comp.object,comp.programming
- Path: sparky!uunet!zaphod.mps.ohio-state.edu!wupost!m.cs.uiuc.edu!m.cs.uiuc.edu!liberte
- From: liberte@cs.uiuc.edu (Daniel LaLiberte)
- Subject: Re: How to design a data structure library.
- In-Reply-To: richieb@bony1.bony.com's message of Tue, 21 Jul 92 12:42:56 GMT
- Message-ID: <LIBERTE.92Jul22123315@birch.cs.uiuc.edu>
- Sender: news@m.cs.uiuc.edu (News Database (admin-Mike Schwager))
- Organization: University of Illinois, Urbana-Champaign, Dept CS
- References: <1820@snap> <1992Jul21.124256.17256@bony1.bony.com>
- Date: Wed, 22 Jul 1992 18:33:15 GMT
- Lines: 38
-
- This is a great question which should probably be stated more
- specifically as "How to design an object-oriented data structure
- library", though there should be large overlap with non-OO techniques.
- (I removed comp.lang.eiffel and added comp.programming.)
-
- In article <1992Jul21.124256.17256@bony1.bony.com> richieb@bony1.bony.com (Richard Bielak) writes:
-
- I think that cursors should be separate from the data structure they
- are used to traverse. The main reason is to allow multiple iterations
- over the same list.
-
- I would agree that cursors for iteration should at least be separable
- from the objects being iterated over. However, in some applications,
- it may be sufficient, and probably more efficient, to mixin the
- cursors with the objects being iterated over. How to define a class
- such that it may be either mixed in or used separately sounds like
- an interesting problem. The functionality is very similar in both cases
- so there should be some way to share common features.
-
- Related to this problem of multiple simultaneous uses of a feature
- (the multiple iterators, not the mixin vs. separable uses of a class),
- I have been working with iterators over DAGs. To avoid traversing a
- subdag more than once, I mark nodes as having been visited. The
- visited status needs to be consistently cleared either before or after
- the traversal, though before seemed better but I forget why.
-
- This traversal scheme does not allow multiple simultaneous traversals
- even if the cursor (which I also dont use) is external to the DAG
- nodes. I havent needed this feature (yet!), but I wonder about the
- alternatives. One alternative would be to pretraverse the structure
- building a linear list of nodes to traverse. This requires extra
- temporary space but could probably be faster than my current scheme if
- you hashed the elements of the constructed linear list to avoid linear
- searches.
-
- Dan LaLiberte
- liberte@cs.uiuc.edu
- (Join the League for Programming Freedom: league@prep.ai.mit.edu)
-