On Monday 14 October 2002 02:26 pm, bob mcwhirter wrote: > > > I was hoping there might be a good Lisp fanatic or something with some > > > reasons for why a Pair object would be very useful. I seem to recall > > > reading someone's blog opining for a Pair class. > > > > Well, you could certainly do lists the LISP way with a Pair class. One > > element is the CAR and the other is the CDR. Then you could build the > > other list operations on top of it quite simply. That's not to say this > > is a good idea, but you *could*. ;-) > > Also, for some hysterical perspective, I believe the STL returned an > Iterator<Pair<KEY,VALUE> > from Map::iterator(). >
On the other hand, Java Collections explicitly rejected the notion that a Map is a collection of pairs. It's one of the reasons that List and Map are irreconcilable. > > Of course, this begs the question of what *do* you call the elements of a > > generic Pair class, to avoid implying any semantic. I guess you can't > > really go far beyond 'obj1' and 'obj2'. > > Yes, I believe the STL's Pair had getFirst() and getSecond(). > I think that's about all you can say about them. It's not like this a deep class. But if you've got them in a few places, they might as well be the same. If there's anyplace a Pair would come in handy in commons, I'd be for it, otherwise, I don't see the general use. > We're not breaking new ground here... > > -bob -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
