Would this be useful to anyone?

Vestras

Retired
Reaction score
249
JASS:
library DataHandler initializer Initialization
globals
    private constant integer A=65
    private constant integer B=66
    private constant integer C=67
    private constant integer D=68
    private constant integer E=69
    private constant integer F=70
    private constant integer G=71
    private constant integer H=72
    private constant integer I=73
    private constant integer J=74
    private constant integer K=75
    private constant integer L=76
    private constant integer M=77
    private constant integer N=78
    private constant integer O=79
    private constant integer P=80
    private constant integer Q=81
    private constant integer R=82
    private constant integer S=83
    private constant integer T=84
    private constant integer U=85
    private constant integer V=86
    private constant integer W=87
    private constant integer X=88
    private constant integer Y=89
    private constant integer Z=90
    private string array Letter
endglobals
private function Initialization takes nothing returns nothing
    set Letter[A]="A"
    set Letter<b>=&quot;B&quot;
    set Letter[C]=&quot;C&quot;
    set Letter[D]=&quot;D&quot;
    set Letter[E]=&quot;E&quot;
    set Letter[F]=&quot;F&quot;
    set Letter[G]=&quot;G&quot;
    set Letter[H]=&quot;H&quot;
    set Letter<i>=&quot;I&quot;
    set Letter[J]=&quot;J&quot;
    set Letter[K]=&quot;K&quot;
    set Letter[L]=&quot;L&quot;
    set Letter[M]=&quot;M&quot;
    set Letter[N]=&quot;N&quot;
    set Letter[O]=&quot;O&quot;
    set Letter[P]=&quot;P&quot;
    set Letter[Q]=&quot;Q&quot;
    set Letter[R]=&quot;R&quot;
    set Letter<s>=&quot;S&quot;
    set Letter[T]=&quot;T&quot;
    set Letter<u>=&quot;U&quot;
    set Letter[V]=&quot;V&quot;
    set Letter[W]=&quot;W&quot;
    set Letter[X]=&quot;X&quot;
    set Letter[Y]=&quot;Y&quot;
    set Letter[Z]=&quot;Z&quot;
endfunction

function DH_H2I takes handle h returns integer
    return h
    return 0
endfunction
function DH_H2S takes handle h returns string
    return I2S(DH_H2I(h))
endfunction
function DH_GetHandleName takes handle h returns string
    local integer hj=DH_H2I(h)-0x100000
    local string basic=&quot;&quot;
    local string s=&quot;&quot;
    local integer n=A-1
    local integer j=-1
    if hj&gt;Z then
        loop
            set j=j+1
            exitwhen hj&lt;=Z
                set hj=hj-1
        endloop
    endif
    set basic=I2S(hj)
    loop
        set n=n+1
        exitwhen n&gt;Z
            if n==hj then
                set s=s+Letter[n]
                set n=Z+1
            endif
    endloop
    debug call BJDebugMsg(&quot;basic == &quot;+basic)
    debug call BJDebugMsg(&quot;s == &quot;+s)
    return s
endfunction

//! textmacro DH_Create takes NAME,TYPE
private struct stringex$TYPE$
    string sxname
    string sx$TYPE$
    string sxfull
endstruct
globals
    private stringex$TYPE$ array str$TYPE$[400000]
    private $TYPE$ array $TYPE$store[400000]
endglobals

function Insert$NAME$Data takes $TYPE$ xx returns string // stores $TYPE$ data in a string
    local integer i=DH_H2I(xx)
    set str$TYPE$<i>=stringex$TYPE$.create()
    set str$TYPE$<i>.sxname=DH_GetHandleName(xx)
    set str$TYPE$<i>.sx$TYPE$=DH_H2S(xx)
    set str$TYPE$<i>.sxfull=str$TYPE$<i>.sxname+str$TYPE$<i>.sx$TYPE$
    debug call BJDebugMsg(str$TYPE$<i>.sxfull)
    set $TYPE$store[S2I(str$TYPE$<i>.sxfull)]=xx
    return str$TYPE$<i>.sxfull
endfunction
function Get$NAME$Data takes string sxfull returns $TYPE$ // gets $TYPE$ data in a string and converts it into a $TYPE$
    return $TYPE$store[S2I(sxfull)]
endfunction
//! endtextmacro
//! runtextmacro DH_Create(&quot;Unit&quot;,&quot;unit&quot;)
//! runtextmacro DH_Create(&quot;Timer&quot;,&quot;timer&quot;)
//! runtextmacro DH_Create(&quot;Trigger&quot;,&quot;trigger&quot;)
//! runtextmacro DH_Create(&quot;Group&quot;,&quot;group&quot;)
endlibrary</i></i></i></i></i></i></i></i></i></u></s></i></b>


What it does? Stores things via strings.
Got the idea from Toadcop a long time ago. Didn't know if this was useful to anyone, but if it is, I'll optimize it and release it.
 

Viikuna

No Marlo no game.
Reaction score
265
Some of those array index letters in initializer function are not supposed to be lower case letters right?

EDIT. Well anyways, it doesnt matter if you are going to optimize it. I wont probably use this, but Id like to know how fast it is.
 

Vestras

Retired
Reaction score
249
Some of those array index letters in initializer function are not supposed to be lower case letters right?

No, they aren't. And they aren't in the library.

EDIT. Well anyways, it doesnt matter if you are going to optimize it. I wont probably use this, but Id like to know how fast it is.

So would I. :)

You might want to rethink both the idea and the implementation a few times...

Why? What's wrong with it?
 

phyrex1an

Staff Member and irregular helper
Reaction score
447
Why? What's wrong with it?
That was what I suggested you to think about.

Here is a few hints:
Doesn't work as intended. Leaks both structs and strings. Slow. Lots of implementation oddities that makes it even stranger, eg
JASS:
    if hj&gt;Z then
        loop
            set j=j+1
            exitwhen hj&lt;=Z
                set hj=hj-1
        endloop
    endif

which happens to be the same thing as
JASS:
set hj = IMaxBJ(hj, Z)

and note that you don't even use j after that loop.

And all this for a system that does, what exactly? Nothing relevant as far as I can tell. I guess I just don't get it...
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top