Set class

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Set class

Ian Martins
Is there a Set class in haxe?  I don't see one, but I noticed Set.nml in
the neko sources.  should I write a haxe class that externs it?  or
would it be better to write another class?  Set.nml doesn't appear
include toString or the "length" property.

-Ian

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Set class

Tony Polinelli
There is a set in the polygonal datastructures  lib

http://code.google.com/p/polygonal/source/browse/trunk/src/lib/de/polygonal/ds/Set.hx

On Wed, Aug 4, 2010 at 1:20 AM, Ian Martins <[hidden email]> wrote:
Is there a Set class in haxe?  I don't see one, but I noticed Set.nml in
the neko sources.  should I write a haxe class that externs it?  or
would it be better to write another class?  Set.nml doesn't appear
include toString or the "length" property.

-Ian

--
haXe - an open source web programming language
http://haxe.org



--
Tony Polinelli
http://touchmypixel.com

--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Set class

Lyndon Howie
In reply to this post by Ian Martins
What functionality of Set do you need? If you just want to store unique keys you could use Hash (just set empty strings or something), if you want it to be sorted, (especially if you want the toString() to be sorted), you're probably better just grabbing one forom somewhere else.
Cheers,
Lyndon

--- On Wed, 4/8/10, Ian Martins <[hidden email]> wrote:

> From: Ian Martins <[hidden email]>
> Subject: [haXe] Set class
> To: [hidden email]
> Received: Wednesday, 4 August, 2010, 1:20 AM
> Is there a Set class in haxe?  I
> don't see one, but I noticed Set.nml in
> the neko sources.  should I write a haxe class that
> externs it?  or
> would it be better to write another class?  Set.nml
> doesn't appear
> include toString or the "length" property.
>
> -Ian
>
> --
> haXe - an open source web programming language
> http://haxe.org
>




--
haXe - an open source web programming language
http://haxe.org
Reply | Threaded
Open this post in threaded view
|

Re: Set class

Justin Donaldson-2
Check out the "swapAndPop" method in ArrayTools:
http://code.google.com/p/sugar-hx/source/browse/trunk/src/ArrayTools.hx

This lets you remove an element from an array without copying the array.  However, it will change the ordering of the elements (not a problem for sets).  It might be a bit faster for remove operations on some targets (vs. a value hash).

A "nice" set collection would use an object hash to prevent duplicate inclusions of arbitrary objects, but that's not possible just yet on all of the haXe targets.  The only way to do such a thing currently is to check against every object in the set when you want to add a new object.  This is going to be too inefficient for most people, so most just use arrays, or figure a way of referencing their objects with strings, numbers, etc. in a value hash.

-Justin

On Tue, Aug 3, 2010 at 5:52 PM, Lyndon Howie <[hidden email]> wrote:
What functionality of Set do you need? If you just want to store unique keys you could use Hash (just set empty strings or something), if you want it to be sorted, (especially if you want the toString() to be sorted), you're probably better just grabbing one forom somewhere else.
Cheers,
Lyndon

--- On Wed, 4/8/10, Ian Martins <[hidden email]> wrote:

> From: Ian Martins <[hidden email]>
> Subject: [haXe] Set class
> To: [hidden email]
> Received: Wednesday, 4 August, 2010, 1:20 AM
> Is there a Set class in haxe?  I
> don't see one, but I noticed Set.nml in
> the neko sources.  should I write a haxe class that
> externs it?  or
> would it be better to write another class?  Set.nml
> doesn't appear
> include toString or the "length" property.
>
> -Ian
>
> --
> haXe - an open source web programming language
> http://haxe.org
>




--
haXe - an open source web programming language
http://haxe.org



--
blog: http://www.scwn.net
aim: iujjd
twitter: jjdonald


--
haXe - an open source web programming language
http://haxe.org