Map: FloatMap?

110 views
Skip to first unread message

Ma rk

unread,
Aug 28, 2014, 10:20:11 AM8/28/14
to haxe...@googlegroups.com
hi,

I was wondering why no FloatMap is available in Haxe. Here's this guy: http://api.haxe.org/Map.html telling us "K" cannot be a Float. I checked it and the doc is right, there's no FloatMap :)
Why is that, lang devs?

Thanks for the answer in advance.

Bernd Ritter

unread,
Aug 28, 2014, 10:33:56 AM8/28/14
to haxe...@googlegroups.com
You need a fixed value for a key in a map. A Float cannot provide that because of precision. That would be my guess.


--
To post to this group haxe...@googlegroups.com
http://groups.google.com/group/haxelang?hl=en
---
You received this message because you are subscribed to the Google Groups "Haxe" group.
For more options, visit https://groups.google.com/d/optout.

Juraj Kirchheim

unread,
Aug 28, 2014, 12:11:57 PM8/28/14
to haxe...@googlegroups.com
Use a BalancedTree<Float> (http://api.haxe.org/haxe/ds/BalancedTree.html).

You can probably get a speedup by overriding the compare method to use
float comparison directly.

Best,
Juraj

Sam MacPherson

unread,
Aug 28, 2014, 2:14:28 PM8/28/14
to haxe...@googlegroups.com
There are use cases I can see for this. For example if you want to use 53 bit integers instead of the regular 32 bits. Provided you arn't doing anything prone to rounding errors, I don't see why you shouldn't be able to use Floats as the key.
Reply all
Reply to author
Forward
0 new messages