in reply to What do you like in a Collection class?

What is different between what you call a collection (im assuming it isnt _exactly_ the same as VB calls a collection) and a hash or tiedhash?

Personally I dont understand the difference.

Consider the methods you listed.... Now lets have a look at the Tie::Hash documentation...

TIEHASH classname, LIST STORE this, key, value FETCH this, key FIRSTKEY this NEXTKEY this, lastkey EXISTS this, key DELETE this, key CLEAR this
Seems like this cover pretty much what is needed from a collection. More advanced methods could be made available through the tied() keyword, in fact you could use some intelligent parameter conventions and aliases to provide both the standard tiedhash interface and a more powerful OO oriented one as well. (For instance in one TIEHASH i wrote I did just this with the "FIRSTKEY" method)

Yves / DeMerphq
---
Writing a good benchmark isnt as easy as it might look.

Replies are listed 'Best First'.
Re: What do you like in a Collection class?
by Abigail-II (Bishop) on Jul 10, 2002 at 11:26 UTC
    It looks like "collections" are basically linked lists. Tie::Hash is a far cry away from linked lists. Somewhere, somewhen, I posted an implementation of linked lists in Perl. Probably on comp.lang.perl.misc. Google might be able to find it.

    Abigail

      "Collections" are linked lists? Weird. That contradicts the concepts that ive seen the term applied to, but whatever.

      Incidentally there are a number of modules using linked list implementations underneath on CPAN.

      Yves / DeMerphq
      ---
      Writing a good benchmark isnt as easy as it might look.