Map with integer key

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User avatar
Thorsten1867
Addict
Addict
Posts: 1366
Joined: Wed Aug 24, 2005 4:02 pm
Location: Germany

Map with integer key

Post by Thorsten1867 »

It would be very helpful if there were also a MAP where you could use integers as keys.
Translated with http://www.DeepL.com/Translator

Download of PureBasic - Modules
Download of PureBasic - Programs

[Windows 11 x64] [PB V5.7x]
Little John
Addict
Addict
Posts: 4519
Joined: Thu Jun 07, 2007 3:25 pm
Location: Berlin, Germany

Re: Map with integer key

Post by Little John »

+ 1
User avatar
Josh
Addict
Addict
Posts: 1183
Joined: Sat Feb 13, 2010 3:45 pm

Re: Map with integer key

Post by Josh »

+1
sorry for my bad english
User avatar
Bisonte
Addict
Addict
Posts: 1226
Joined: Tue Oct 09, 2007 2:15 am

Re: Map with integer key

Post by Bisonte »

Thorsten1867 wrote:It would be very helpful if there were also a MAP where you could use integers as keys.
Very, very, very, very, very....... helpful

+1
PureBasic 6.04 LTS (Windows x86/x64) | Windows10 Pro x64 | Asus TUF X570 Gaming Plus | R9 5900X | 64GB RAM | GeForce RTX 3080 TI iChill X4 | HAF XF Evo | build by vannicom​​
English is not my native language... (I often use DeepL to translate my texts.)
User avatar
Andre
PureBasic Team
PureBasic Team
Posts: 2056
Joined: Fri Apr 25, 2003 6:14 pm
Location: Germany (Saxony, Deutscheinsiedel)
Contact:

Re: Map with integer key

Post by Andre »

+1

Currently I'm using maps most of the time with unique ID numbers as map key.
But always need to convert them to ID strings first, which could be avoided if this wish come true :)
Bye,
...André
(PureBasicTeam::Docs & Support - PureArea.net | Order:: PureBasic | PureVisionXP)
davido
Addict
Addict
Posts: 1890
Joined: Fri Nov 09, 2012 11:04 pm
Location: Uttoxeter, UK

Re: Map with integer key

Post by davido »

+1
DE AA EB
BarryG
Addict
Addict
Posts: 3294
Joined: Thu Apr 18, 2019 8:17 am

Re: Map with integer key

Post by BarryG »

+1
User avatar
RSBasic
Moderator
Moderator
Posts: 1218
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: Map with integer key

Post by RSBasic »

+1

I always use Str(IntValue) because this is not possible otherwise.
Image
Image
User avatar
Mijikai
Addict
Addict
Posts: 1360
Joined: Sun Sep 11, 2016 2:17 pm

Re: Map with integer key

Post by Mijikai »

+ 1

How about:

Code: Select all

;Create a map based on #PB Type:
NewMap Country.s(#PB_Integer)
NewMap Country.s(#PB_Float)
NewMap Country.s(#PB_Byte)
NewMap Country.s(#PB_Double)
;...

;-> MapType() -> returns the Type
User avatar
RSBasic
Moderator
Moderator
Posts: 1218
Joined: Thu Dec 31, 2009 11:05 pm
Location: Gernsbach (Germany)
Contact:

Re: Map with integer key

Post by RSBasic »

Or:

Code: Select all

NewMap.i Country.s()
Country(1) = "Germany"
Image
Image
User avatar
Demivec
Addict
Addict
Posts: 4086
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Re: Map with integer key

Post by Demivec »

Or:

Code: Select all

;Create a map of either String or Integer type, #PB_Default used for slots = 512 and for type = #PB_String
NewMap name.<type>([Slots | #PB_Default [, #PB_String | #PB_Integer | #PB_Default]])
 
MapType(Map()) -> returns either #PB_String or #PB_Integer
:)
User avatar
Tenaja
Addict
Addict
Posts: 1948
Joined: Tue Nov 09, 2010 10:15 pm

Re: Map with integer key

Post by Tenaja »

I think you are asking for something like this, to use in the meantime:
viewtopic.php?f=13&t=58708
Rinzwind
Enthusiast
Enthusiast
Posts: 636
Joined: Wed Mar 11, 2009 4:06 pm
Location: NL

Re: Map with integer key

Post by Rinzwind »

+1
Any official statement?
User avatar
idle
Always Here
Always Here
Posts: 5050
Joined: Fri Sep 21, 2007 5:52 am
Location: New Zealand

Re: Map with integer key

Post by idle »

no but you can use the numeric functions of squint for that.
viewtopic.php?f=12&t=75783
User avatar
Tenaja
Addict
Addict
Posts: 1948
Joined: Tue Nov 09, 2010 10:15 pm

Re: Map with integer key

Post by Tenaja »

Rinzwind wrote: Sun May 30, 2021 2:56 am +1
Any official statement?
I, too, would like this feature... However...
Consider their focus at the moment: it's fully on the alpha release. My bet is that if you do get a reply, it will be something like "we may evaluate new features after the C backend is released".

It's not really reasonable to think they are going to put the alpha release on hold to add a feature request that is two years old... Especially when there are at least two libraries on the forum that do what you have asked for.

Has Fred written in any threads not related to the alpha this month?
Post Reply