A global hashtable? o.O

the Immortal

I know, I know...
Reaction score
51
Ynow, after we (in fact 'you') had that discussion about a global GROUP, isn't it time for a global hashtable, lols? =P

No, apart from the jokes, there are many spells where only one row (column) of the hashtable is needed. Should I post some links? Though am sure everyone can find. So instead of making the user paste some indexing/attaching system (be it unit, trigger, timer or w/e.. plus you can -always- make it optional) or needlessly create tens of hashtables only to use a single key or two of them, why isn't something as simple as that implemented?:
JASS:

library_once HASH
    globals
        hashtable HASH    //damn silly name, but we have 'GROUP' so diaf!
    endglobals
endlibrary


And when you want to use it, just create a public key and.. voilà?

So this
JASS:

scope SomeSpell
    globals
        hashtable ht
    endglobals

    function onCast takes nothing returns nothing
        local data d = LoadInteger(ht, 0, GetHandleId(GetTriggerUnit()))
        ...
    endfunction
    
    ...

endscope

becomes this:
JASS:
library_once HASH
    globals
        hashtable HASH    //damn silly name, but we have 'GROUP' ?
    endglobals
endlibrary
scope SomeSpell requires HASH
    globals
        public key UNITID_ROW     //another silly name, out of ideas today
    endglobals

    function onCast takes nothing returns nothing
        local data d = LoadInteger(HASH, UNITID_ROW, GetHandleId(GetTriggerUnit()))
        ...
    endfunction

    ...

endscope



Actually for me it doesn't matter if I have 1000 hashtables or only one, as the speed difference should be.. negligible. But since it seems to be a problem, I am putting it here for discussing.. without much hopes to accomplish anything btw =D

Nothing's wrong with unit indexing / attaching, of course.. but I hate having to paste a whole system only for a single spell to work. As, I think, most of the time happens.
Make these optional, use hashtables. Or better - use a single hashtable.
 

Zwiebelchen

You can change this now in User CP.
Reaction score
60
Unit indexing systems are a must have, if you ask me. Hashtables are fast, but arrayed globals and getting UnitUserData is still like 80% faster.
And if that doesn't matter to you, then indexed global arrays are still better, because they save lines of code.

Besides, it's absolutely no problem to import indexing systems, as they do not require manual setup. They work completely automaticly (at least the popular ones).

If you "have to import" an indexing system "just for one spell", where is the problem with that? Modularity is a pro, not a con. And maybe some day you will want this other spell that uses indexing too.

Of all systems you can import into your map, indexing systems are possibly the most vital.
 

weaaddar

New Member
Reaction score
6
A lot of people use the Table library to do exactly what you are talking about.

Also eventually, Vex will translate large dynamic arrays to hashtable so you probably can just do something like "integer array Table[9000,81000]" and have native built in table.


And you really don't need an indexing system they aren't a mega speed increase, its about twice as fast to use GetUserData then Hashtable natives that is true.
 

the Immortal

I know, I know...
Reaction score
51
> Unit indexing systems are a must have, if you ask me.
Sure, but when for a simple bash snippet, I have to attach to units, triggers, and timers, (or instead of trigger-attaching use a damage detection system) why should I import 3 systems instead of use 1 hashtable row and 'suffer' + 0.0001ms execution time?

> Of all systems you can import into your map, indexing systems are possibly the most vital.
They would be 'vital' if it wasn't possible to do exactly the same things without them. (excluding unit-structs as this is completely another question..)

> A lot of people use the Table library to do exactly what you are talking about.
Wasn't aware of its existence. Will look into it later.


And, okay, let me rephrase my question:
If I simply want to attach data to handles, why should I import 2, 3, or more systems, instead of use a hashtable in the form of that little snippet? For efficiency?
ArrayGet[UnitId()] execution time is neglectfully small. HashtableGet is less than twice slower than it. No good code should call these more than once / run. And even at 32 times / second the performance loss is still equal to zero, given it's 2k9 and we are running a game from 2k3 or so.

Yes, there might be exceptions in the form of gigantic maps-o-systems. But for at least 95% of the time.. it wouldn't matter at all.

Please correct me if I see these things wrong.

Best regards,
Ix
 

weaaddar

New Member
Reaction score
6
Yeah table is pretty much one of the best utility libraries I can suggest. It's a clean wrapper around the native's and so it all inline. It also gives you array notation.

So you use it like::
JASS:

HandleTable myTable = HandleTable.create();
myTable[someUnitVar] = someStruct;
if(myTable.exists(someOtherUnit))
{
    someValue = myTable[someOtherUnit];
}
myTable.flush();
 
General chit-chat
Help Users
  • No one is chatting at the moment.
  • Monovertex Monovertex:
    How are you all? :D
    +1
  • Ghan Ghan:
    Howdy
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top