home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.c++
- Path: sparky!uunet!psinntp!bony1!richieb
- From: richieb@bony1.bony.com (Richard Bielak)
- Subject: Re: problems designing lists with templates
- Message-ID: <1992Nov19.165602.13420@bony1.bony.com>
- Organization: multi-cellular
- References: <1992Oct26.225959.566@beaver.cs.washington.edu> <1992Oct28.163105.9062@ucc.su.OZ.AU>
- Date: Thu, 19 Nov 92 16:56:02 GMT
- Lines: 59
-
- In article <1992Oct28.163105.9062@ucc.su.OZ.AU> maxtal@extro.ucc.su.OZ.AU (John MAX Skaller) writes:
-
- [...]
-
- >
- > There are 3 ways I can think of off hand to do this.
- >
- > 1) Supply operator[] for the list class. This what I do.
-
- [...]
-
- >
- > 2) Do as you suggested.
-
- [...]
-
- >
- > 3) Use an iterator.
-
- [...]
-
- >
- >No doubt there are even more solutions. The iterator technique is probably
- >the best and hardest. The first technique is easy to work with and code.
- >It is not necessarily slow either, by providing a cache it is as fast
- >for sequential access as the methods (2) and (3) which are constrained
- >to sequential access, whereas (1) gives the appearance of random access.
- >
- >--
-
- The fourth way is to use a list with "cursor". The cursor can be a
- separate class, or be part of list. You can set the cursor to point to
- the first or last element and then move it around. Code my look
- something like this:
-
- curs.set_list (list);
- curs.start;
- curs.forth;
-
- x = curs.item; // gets the item at the cursor
-
-
- The user still doesn't need to see ListElement.
-
- This approach is described in more detail in "Object Oriented
- Software Construction" by B. Meyer.
-
-
-
- ...richie
-
-
-
-
- --
- * Richie Bielak (212)-815-3072 | *
- * Internet: richieb@bony.com | Rule #1: Don't sweat the small stuff. *
- * Bang {uupsi,uunet}!bony1!richieb | Rule #2: It's all small stuff. *
- * - Strictly my opinions - | *
-