Path: utzoo!utgpu!attcan!uunet!ateng!chip From: chip@ateng.ateng.com (Chip Salzenberg) Newsgroups: comp.lang.c++ Subject: Container classes (was Re: friend) Message-ID: <1988Sep27.103559.4881@ateng.ateng.com> Date: 27 Sep 88 14:35:58 GMT References: <61@cybaswan.UUCP> <1988Sep2.174327.6439@ateng.uucp> <78@cybaswan.UUCP> <1988Sep15.151514.20657@ateng.uucp> <763@esl.UUCP> Organization: A T Engineering, Tampa, FL Lines: 34 According to dml@esl.UUCP (Denis Lynch): >But you missed the point. Of course linked lists are useful. They are >a separate concept of their own, and shouldn't be imbedded in you hash >table constructs. [...] The HashNode isn't the thing that >really has the "next" property, that is the responsibility of the set >or sequence. I appreciate the clarification. But I must make comment on the following: >In short, look at something like OOPS. Use a set of basic "computer >science" classes to handle lists, arrays, sets, etc., independent of >the *contents* of the collections. The whole issue of container classes is one that gets religious pretty quickly. Smalltalk devotees -- and their acolytes, the Objective C folks -- rant on about container classes that work the same no matter what they contain. Personally, I consider the whole issue a red herring. For example, the Objective C book gives the example of iterating across all objects in a collection, adding up their weights. The hidden gotcha: What guarantee is there that all objects in the collection respond correctly, or at all, to the "getWeight" message? The likely answer: "Well, I know because I put them there." In that case, you don't *really* have a heterogenous collection. To get back to the original example: Yes, perhaps I should have implemented a HashNodeCollection type to hold all the HashNodes. But I certainly would not create a huge class hierarchy with virtual functions everywhere just so I could create pseudo-heterogenous collection classes. That method may be appropriate for Smalltalk and Objective C, but it's not "the C++ way". -- Chip Salzenbergor A T Engineering My employer may or may not agree with me. The urgent leaves no time for the important.