New dictionary class named HashTable

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
11 messages Options
Reply | Threaded
Open this post in threaded view
|

New dictionary class named HashTable

Nicolas Petton
Hi guys,

I pushed an implementation of Dictionary temporary named HashTable that
allows you to put any kind of object as a key.

This class name is temporary, and may very well replace Dictionary in
the future (or better, the current Dictionary class will be renamed and
stay as the subclass of the new Dictionary).

It's a faster implementation for #at:.
#at:put: is as fast for small dictionaries (size < 500) and becomes
slower as the dictionary grows.

Cheers,
Nico

Reply | Threaded
Open this post in threaded view
|

Re: New dictionary class named HashTable

Amber Milan Eskridge
Great news :)

On Sun, Nov 6, 2011 at 4:21 PM, Nicolas Petton <[hidden email]> wrote:
Hi guys,

I pushed an implementation of Dictionary temporary named HashTable that
allows you to put any kind of object as a key.

This class name is temporary, and may very well replace Dictionary in
the future (or better, the current Dictionary class will be renamed and
stay as the subclass of the new Dictionary).

It's a faster implementation for #at:.
#at:put: is as fast for small dictionaries (size < 500) and becomes
slower as the dictionary grows.

Cheers,
Nico


Reply | Threaded
Open this post in threaded view
|

Re: New dictionary class named HashTable

Nicolas Petton
In reply to this post by Nicolas Petton
I renamed the old dictionary hashedCollection and it is now the
superclass of the new Dictionary.

I adapted #asJSON to reflect these changes.

So, HashedCollection and Dictionary have exactly the same API, the only
difference is that HashedCollection can only hve strings as keys.

Also, now the #{'foo' -> 'bar'} syntax builds an instance of
HashedCollection.

it can be converted to a Dictionary with #asDictionary.

Cheers,
Nico

On Sun, 2011-11-06 at 16:21 +0100, Nicolas Petton wrote:

> Hi guys,
>
> I pushed an implementation of Dictionary temporary named HashTable that
> allows you to put any kind of object as a key.
>
> This class name is temporary, and may very well replace Dictionary in
> the future (or better, the current Dictionary class will be renamed and
> stay as the subclass of the new Dictionary).
>
> It's a faster implementation for #at:.
> #at:put: is as fast for small dictionaries (size < 500) and becomes
> slower as the dictionary grows.
>
> Cheers,
> Nico
>


Reply | Threaded
Open this post in threaded view
|

Re: New dictionary class named HashTable

Amber Milan Eskridge
Really cool



On Sun, Nov 6, 2011 at 5:53 PM, Nicolas Petton <[hidden email]> wrote:
I renamed the old dictionary hashedCollection and it is now the
superclass of the new Dictionary.

I adapted #asJSON to reflect these changes.

So, HashedCollection and Dictionary have exactly the same API, the only
difference is that HashedCollection can only hve strings as keys.

Also, now the #{'foo' -> 'bar'} syntax builds an instance of
HashedCollection.

it can be converted to a Dictionary with #asDictionary.

Cheers,
Nico

On Sun, 2011-11-06 at 16:21 +0100, Nicolas Petton wrote:
> Hi guys,
>
> I pushed an implementation of Dictionary temporary named HashTable that
> allows you to put any kind of object as a key.
>
> This class name is temporary, and may very well replace Dictionary in
> the future (or better, the current Dictionary class will be renamed and
> stay as the subclass of the new Dictionary).
>
> It's a faster implementation for #at:.
> #at:put: is as fast for small dictionaries (size < 500) and becomes
> slower as the dictionary grows.
>
> Cheers,
> Nico
>



Reply | Threaded
Open this post in threaded view
|

Re: New dictionary class named HashTable

Sebastian Nozzi-2
In reply to this post by Nicolas Petton
This is cool! However, using "Point" as a key is failing for me...
For example:

d := Dictionary new.
d at: (1@1) put: 'hello'.
d keys first = (1@1). "true, which is ok"
d at: (1@1). "=> Object is not in collection"

Am I doing something wrong?
Reply | Threaded
Open this post in threaded view
|

Re: New dictionary class named HashTable

Nicolas Petton
On Sun, 2011-11-13 at 06:59 -0800, Sebastian Nozzi wrote:
> d := Dictionary new.
> d at: (1@1) put: 'hello'.
> d keys first = (1@1). "true, which is ok"
> d at: (1@1). "=> Object is not in collection"

Are you sure you're version of Amber is up-to-date?
It works for. Try on amber-lang.net.

Cheers,
Nico

Reply | Threaded
Open this post in threaded view
|

Re: New dictionary class named HashTable

Hannes Hirzel
Hello
I do not see any superclass of Dictionary on http://amber-lang.net/.
Is that really the last version?

In addition it would be nice to have two or three tests for Hash*? Is
it HashCollection or HashTable?

--Hannes

On 11/13/11, Nicolas Petton <[hidden email]> wrote:

> On Sun, 2011-11-13 at 06:59 -0800, Sebastian Nozzi wrote:
>> d := Dictionary new.
>> d at: (1@1) put: 'hello'.
>> d keys first = (1@1). "true, which is ok"
>> d at: (1@1). "=> Object is not in collection"
>
> Are you sure you're version of Amber is up-to-date?
> It works for. Try on amber-lang.net.
>
> Cheers,
> Nico
>
>
Reply | Threaded
Open this post in threaded view
|

Re: New dictionary class named HashTable

Sebastian Nozzi-2
In reply to this post by Nicolas Petton
I don't know what's going on. I am no git expert and might be doing
something wrong, but I'm convinced I have the latest version (I've
been pulling updates from the master). In my browser I even see
Dictionary inheriting from HashTable.

And, on amber-lang.net, as you say, it works as expected.

Strange. I'll try to find out what's going on.

On Nov 13, 4:06 pm, Nicolas Petton <[hidden email]> wrote:
> Are you sure you're version of Amber is up-to-date?
> It works for. Try on amber-lang.net.
Reply | Threaded
Open this post in threaded view
|

Re: New dictionary class named HashTable

Nicolas Petton
I think I know what's going on: I didn't update the website, and there
is to be a bug with the new Dictionary :)

Nico

On Tue, 2011-11-15 at 03:02 -0800, Sebastian Nozzi wrote:

> I don't know what's going on. I am no git expert and might be doing
> something wrong, but I'm convinced I have the latest version (I've
> been pulling updates from the master). In my browser I even see
> Dictionary inheriting from HashTable.
>
> And, on amber-lang.net, as you say, it works as expected.
>
> Strange. I'll try to find out what's going on.
>
> On Nov 13, 4:06 pm, Nicolas Petton <[hidden email]> wrote:
> > Are you sure you're version of Amber is up-to-date?
> > It works for. Try on amber-lang.net.


Reply | Threaded
Open this post in threaded view
|

Re: New dictionary class named HashTable

Nicolas Petton
I fixed the bug, added some tests, and pushed to Master!
https://github.com/NicolasPetton/amber/commit/b27b1bffa7eb22ab56206305de8c82dee4240fb5

Cheers,
Nico

On Tue, 2011-11-15 at 12:11 +0100, Nicolas Petton wrote:

> I think I know what's going on: I didn't update the website, and there
> is to be a bug with the new Dictionary :)
>
> Nico
>
> On Tue, 2011-11-15 at 03:02 -0800, Sebastian Nozzi wrote:
> > I don't know what's going on. I am no git expert and might be doing
> > something wrong, but I'm convinced I have the latest version (I've
> > been pulling updates from the master). In my browser I even see
> > Dictionary inheriting from HashTable.
> >
> > And, on amber-lang.net, as you say, it works as expected.
> >
> > Strange. I'll try to find out what's going on.
> >
> > On Nov 13, 4:06 pm, Nicolas Petton <[hidden email]> wrote:
> > > Are you sure you're version of Amber is up-to-date?
> > > It works for. Try on amber-lang.net.
>
>


Reply | Threaded
Open this post in threaded view
|

Re: New dictionary class named HashTable

Amber Milan Eskridge
Cool :)

On Fri, Dec 2, 2011 at 3:51 PM, Nicolas Petton <[hidden email]> wrote:

> I fixed the bug, added some tests, and pushed to Master!
> https://github.com/NicolasPetton/amber/commit/b27b1bffa7eb22ab56206305de8c82dee4240fb5
>
> Cheers,
> Nico
>
> On Tue, 2011-11-15 at 12:11 +0100, Nicolas Petton wrote:
>> I think I know what's going on: I didn't update the website, and there
>> is to be a bug with the new Dictionary :)
>>
>> Nico
>>
>> On Tue, 2011-11-15 at 03:02 -0800, Sebastian Nozzi wrote:
>> > I don't know what's going on. I am no git expert and might be doing
>> > something wrong, but I'm convinced I have the latest version (I've
>> > been pulling updates from the master). In my browser I even see
>> > Dictionary inheriting from HashTable.
>> >
>> > And, on amber-lang.net, as you say, it works as expected.
>> >
>> > Strange. I'll try to find out what's going on.
>> >
>> > On Nov 13, 4:06 pm, Nicolas Petton <[hidden email]> wrote:
>> > > Are you sure you're version of Amber is up-to-date?
>> > > It works for. Try on amber-lang.net.
>>
>>
>
>