develooper Front page | perl.perl5.porters | Postings from October 2002

Re: Collections

Thread Previous | Thread Next
From:
Christian Jaeger
Date:
October 1, 2002 18:35
Subject:
Re: Collections
Message ID:
p04320410b9bff98a6390@[192.168.3.11]
At 15:43 Uhr +0100 30.09.2002, hv@crypt.org wrote:
>Well, I'd suggest that depends a lot on just what the end user wants
>to do.
>
>I've often wanted the Tie::RefHash-type semantics, and it seems to me
>that it would be very easy to add an efficient core implementation of
>that - in fact, such hashes could even be faster than normal hashes
>if the benefits of the fixed key size outweigh the cost of the extra
>refcount mangling. I believe this is what Christian was originally
>asking for.

Yes. The only value I would store in such a hash would be "undef", in 
the hope that undef doesn't take up any space (I don't know if this 
is true).

For "collection"-only usage, the tie'd (or however implemented) hash 
could maybe just ignore any value stored in it. Or maybe something 
different like this would be an alternative?:
   $bucket += $obj; # add object to collection
   $bucket -= $obj; # remove it again
   undef $bucket; # emtpy it. (Is this doable with Tie?)
   for (@$bucket) { ... } # give ref to autobuilt array which is tied 
or magic itself and supports iterating through it? (so it doesn't 
have to waste memory for copying)

just an idea
Christian.

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About