Front page | perl.perl5.porters |
Postings from October 2002
Re: Collections
Thread Previous
|
Thread Next
From:
Graham Barr
Date:
October 1, 2002 06:33
Subject:
Re: Collections
Message ID:
20021001142949.D53782@pobox.com
On Tue, Oct 01, 2002 at 03:26:13PM +0200, H.Merijn Brand wrote:
> On Tue 01 Oct 2002 15:05, Rafael Garcia-Suarez <rgarciasuarez@free.fr> wrote:
> > Damien Neil <neild@misago.org> wrote:
> > > > $roll = [$dice1, $dice2];
> > > > $rolls->{$roll}++; <--
> > ....
> > > I'm happy writing the above replacing the "<--" marked line with
> > >
> > > $rolls->{"$dice1 $dice2"}++;
> >
> > Nobody mentioned the $; variable yet ?
>
> Or pack?
>
> $rolls->{pack "ll", $dice1, $dice2}++
>
> Verrrry efficient, and ultimate simple to sort :)
Not id the data structure being used as the key has a huge number
of elements in it.
What is being attempted is currently trivial with a tied hash, even getting
refs etc back from keys. But I suspect people want the core hash todo this.
The issue is how to do it "without" slowing normal hashes as they are today.
Remeber it is those hashes that perl uses for its packages, so any slowdown
can have huge consequences.
But if we do figure out how to do this, then I would suggest that
the hash call a method to determine the key. For unblessed references,
just use the address.
Graham.
Thread Previous
|
Thread Next