Jump to content

3300+ oranges


irihapeti
You are about to reply to a thread that has been inactive for 2342 days.

Please take a moment to consider if this thread is worth bumping.

Recommended Posts

++++++++++++++++

edit again: if you thinking of doing something like this in your LSL app then LepreKhaun made a mod (is post further down). Use that one bc is really good his mod

++++++++++++++++

edit: in response to feedback from revochen I recode this to the more formal coding style for the reasons raised. is post below

++++++++++++++++ 

this a script that came out of a chat about stuffing apples into a box in another post in the Library. This script about how many oranges can you stuff in the same box. Can stuff over 3300 oranges seems like

if i had a question it would be have I missed anything else bugwise?

 

// stores 3329 encoded keys losslessly in a string table 
// call this script with table id -3329 in num 
// llMessageLinked(LINK_THIS, -3329, "", yourkey);
// return codes in num
//   0 = table full
//   1 = key found in table 
//   2 = key added to table  
//   link_message(integer sender_num, integer num, string message, key id)
//   { llOwnerSay((string)num + " " + (string)id); }   
// 
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
// search code is Public Domain May 2014 by elizabeth (irihapeti)
//
// encoder is CCby3 license. as is based on some CCby3 works. refs:
// Adam Wozniak and Doran Zemlja (public domain)
// http://wiki.secondlife.com/wiki/Key_Compression
// Becky Pippen (unspecified. assume CCby3)
// http://wiki.secondlife.com/wiki/User:Becky_Pippen/Numeric_Storage
// Combined Library (CCby3)
// http://wiki.secondlife.com/wiki/Combined_Library
//
// CCby3 exception: you dont have to maintain credits for my contribution to the
// encoder that you publish or distribute bc they Public Domain
//
// my encoder design contribution was to encode right-to-left so that decoding is 
// a little bit more straightforward to code for 
//
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

integer u = -3329; // table uniqueid. can change to whichever
integer m =  3329; // max number of records. set lower if get stack/heap collisons
string  d;         // data table
integer c;         // count of records in table

default
{
    link_message(integer n, integer b, string s, key k)
    {
        if (b != u) return;
        
        b = 0;
        if (c < m) 
        {
            // encode
            s = llDumpList2String(llParseString2List((string)k, ["-"], []), ""); 
            string  e;
            integer i;
            for (i = 28; i >= 0; i -= 4)
            {
                n = (integer)("0x" + llGetSubString(s, i, i + 3));
                b = (b << 1) | (n & 0x1);
                n = (n >> 1) & 0x7FFF;
                e += llBase64ToString(llIntegerToBase64(
                    0xE0808000 | (((n + 0x800) << 12) & 0xF000000) | 
                    (((n + 0x0800) << 10) & 0x3F0000) | ((n << 8) & 0x3F00)));
            }
            b = (b & 0xFF);
            e += llBase64ToString(llIntegerToBase64(
                0xE0808000 | (((b + 0x800) << 12) & 0xF000000) | 
                (((b + 0x0800) << 10) & 0x3F0000) | ((b << 8) & 0x3F00)));
            
            // search
            b = 0;
            i = llSubStringIndex(d, e);
            if (~i) 
            { 
                n = (i % 9);
                if (!n) jump y;
                i += (9 - n);
                n = llStringLength(d);
                @x;
                if (llGetSubString(d, i, i + 8) == e) jump y;
                if ((i += 9) < n) jump x;   
            }        
            d += e; c++; b++;
            @y; b++; 
        }
        llMessageLinked(LINK_THIS, b, "", k);
    } 
}

 

 

 

Link to post
Share on other sites

++++++++++++++++

edit again: if you thinking of doing something like this in your LSL app then LepreKhaun made a mod (is post further down). Use that one bc is really good his mod

++++++++++++++++

edit: in response to feedback from revochen I recode this to the more formal coding style for the reasons raised. is post below

++++++++++++++++ 

this a script that came out of a chat about stuffing apples into a box in another post in the Library. This script about how many oranges can you stuff in the same box. Can stuff over 3300 oranges seems like

if i had a question it would be have I missed anything else bugwise?

 

// stores 3329 encoded keys losslessly in a string table 
// call this script with table id -3329 in num 
// llMessageLinked(LINK_THIS, -3329, "", yourkey);
// return codes in num
//   0 = table full
//   1 = key found in table 
//   2 = key added to table  
//   link_message(integer sender_num, integer num, string message, key id)
//   { llOwnerSay((string)num + " " + (string)id); }   
// 
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
//
// search code is Public Domain May 2014 by elizabeth (irihapeti)
//
// encoder is CCby3 license. as is based on some CCby3 works. refs:
// Adam Wozniak and Doran Zemlja (public domain)
// http://wiki.secondlife.com/wiki/Key_Compression
// Becky Pippen (unspecified. assume CCby3)
// http://wiki.secondlife.com/wiki/User:Becky_Pippen/Numeric_Storage
// Combined Library (CCby3)
// http://wiki.secondlife.com/wiki/Combined_Library
//
// CCby3 exception: you dont have to maintain credits for my contribution to the
// encoder that you publish or distribute bc they Public Domain
//
// my encoder design contribution was to encode right-to-left so that decoding is 
// a little bit more straightforward to code for 
//
//++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++

integer u = -3329; // table uniqueid. can change to whichever
integer m =  3329; // max number of records. set lower if get stack/heap collisons
string  d;         // data table
integer c;         // count of records in table

default
{
    link_message(integer n, integer b, string s, key k)
    {
        if (b != u) return;
        
        b = 0;
        if (c < m) 
        {
            // encode
            s = llDumpList2String(llParseString2List((string)k, ["-"], []), ""); 
            string  e;
            integer i;
            for (i = 28; i >= 0; i -= 4)
            {
                n = (integer)("0x" + llGetSubString(s, i, i + 3));
                b = (b << 1) | (n & 0x1);
                n = (n >> 1) & 0x7FFF;
                e += llBase64ToString(llIntegerToBase64(
                    0xE0808000 | (((n + 0x800) << 12) & 0xF000000) | 
                    (((n + 0x0800) << 10) & 0x3F0000) | ((n << 8) & 0x3F00)));
            }
            b = (b & 0xFF);
            e += llBase64ToString(llIntegerToBase64(
                0xE0808000 | (((b + 0x800) << 12) & 0xF000000) | 
                (((b + 0x0800) << 10) & 0x3F0000) | ((b << 8) & 0x3F00)));
            
            // search
            b = 0;
            i = llSubStringIndex(d, e);
            if (~i) 
            { 
                n = (i % 9);
                if (!n) jump y;
                i += (9 - n);
                n = llStringLength(d);
                @x;
                if (llGetSubString(d, i, i + 8) == e) jump y;
                if ((i += 9) < n) jump x;   
            }        
            d += e; c++; b++;
            @y; b++; 
        }
        llMessageLinked(LINK_THIS, b, "", k);
    } 
}

 

 

 

Link to post
Share on other sites

The wiki is expressing the opinion of the person who made that entry. There's no such thing as a one-size-fits-all rule.  There are times when jump is not only convenient but also the most efficient way to handle flow, such as needing to exit a repetitive process prematurely without leaving the event.  I don't use jump a lot myself, but there are times when it's just the right tool.

Link to post
Share on other sites

Yes but i believe its much more convenient to read as a while loop or flow control structure if possible and even might be less code.

Chapeau! if the code runs proper. I rarely see such code. Reminds me on BASIC :matte-motes-nerdy:

Link to post
Share on other sites

Nice idea to use an event parameter (integer b) for other purposes instead of creating a custom local variable.

But naming variables or the jump scope only like a, b, c or d is also quite inconvenient and not clever on a public domain script.

Link to post
Share on other sites


revochen Mayne wrote:

To be honest, i was reading the code now a duzend times. Really trying to understand it but i still failing yet.

 

It is definitely my candidate for the geek script of the year! :matte-motes-nerdy:

You will love to learn the history behind it. Look here

The thread contains entertainment, wisdom and drama, all in one thread

:smileysurprised::):smileyvery-happy:

Link to post
Share on other sites

mod of 1st script (above)

more formal coding style bc feedback

also I changed the encoder in this version to use the same decoder that I posted on other forum. Just so is compatible with that

so some key storage loss. down to 3310

+

!!! Warninks !!! the codes produced by this script are not the same as those produced by the 1st script ok !!!

is no decoder been written for the 1st script. Is only a decoder for this one (see below)

+

i have no intention to mod this anymore unless is a bug in it

also: this is not a library submission. Is just example code for people to do whatever they want with

 

// example of storing 3310 encoded keys losslessly in a string table // call this script with table id -3310 in num // llMessageLinked(LINK_THIS, -3310, "", yourkey);// return codes in num//   0 = table full//   1 = key found in table //   2 = key added to table  //   link_message(integer sender_num, integer num, string message, key id)//   { llOwnerSay((string)num + " " + (string)id); }   // //++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++//// search code is Public Domain May 2014 by elizabeth (irihapeti)//// encoder is CCby3 license. as is based on some CCby3 works. refs:// Adam Wozniak and Doran Zemlja (public domain)// http://wiki.secondlife.com/wiki/Key_Compression// Becky Pippen (unspecified. assume CCby3)// http://wiki.secondlife.com/wiki/User:Becky_Pippen/Numeric_Storage// Combined Library (CCby3)// http://wiki.secondlife.com/wiki/Combined_Library//// CCby3 exception: you dont have to maintain credits for my contribution to the// encoder that you publish or distribute bc they Public Domain//// my encoder design contribution was to encode right-to-left so that decoding is // a little bit more straightforward to code for ////++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++integer u = -3310; // table uniqueid. can change to whicheverinteger m =  3310; // max number of records. set lower if get stack/heap collisionstring  d;         // data tableinteger c;         // count of records in tabledefault{    link_message(integer n, integer b, string s, key id)    {        if (b != u) return;                b = 0;        if (c < m)         {            // encode            s = llDumpList2String(llParseString2List((string)id, ["-"], []), "");             string  e;            integer i;            integer z;            for (i = 24; i >= 0; i -= 8)            {                n = (integer)("0x" + llGetSubString(s, i, i + 7));                b = (b <<  2) | (n & 0x3);                z = (n >>  2) & 0x7FFF;                n = (n >> 17) & 0x7FFF;                e += llBase64ToString(llIntegerToBase64(                        0xE0808000 | (((z + 0x800) << 12) & 0xF000000) |                         (((z + 0x0800) << 10) & 0x3F0000) | ((z << 8) & 0x3F00)))                  +  llBase64ToString(llIntegerToBase64(                        0xE0808000 | (((n + 0x800) << 12) & 0xF000000) |                         (((n + 0x0800) << 10) & 0x3F0000) | ((n << 8) & 0x3F00)));             }            b = (b & 0xFF);            e += llBase64ToString(llIntegerToBase64(                0xE0808000 | (((b + 0x800) << 12) & 0xF000000) |                 (((b + 0x0800) << 10) & 0x3F0000) | ((b << 8) & 0x3F00)));                        // search            i = llSubStringIndex(d, e);            if (i >= 0)             {                 n = (i % 9);                if (n > 0)                 {                         i += (9 - n);                    n = llStringLength(d);                    do                    {                        b = (llGetSubString(d, i, i + 8) == e);                        i += 9;                    } while ((b == 0) && (i < n));                    if (b == 0) b = 2;                     // else b = 1                } else b = 1;            }            else b = 2;                           if (b == 2) { d += e; c++; };        }        llMessageLinked(LINK_THIS, b, "", id);    } }

 

 

Link to post
Share on other sites

example encoder / decoder

// example key encoder decoder// public domain April 2014 by elizabeth (irihapeti)// a mod of works by:// Adam Wozniak, Doran Zemlja, Becky Pippen, Strife Onizuka// with mentions for exacts in the codes//// encodes a key (uuid) into a string of 9 UTF16 chars. 18 bytes// str = Key2UTF(key) // key = UTF2Key(str) //// UTF16 codes produced are copypasta into scripts and notecards in // SL viewer 3.7.3 (287491) Mar 4 2014 05:01:31// on Windows 8.1. Default USA english// dunno about earlier/later versions, LSL Editor or TPVs or other OS// just need be careful when copypasta as// - some UTF glyphs are not visible but are in the string// - many of them show as the same glyph. but they are decodeable// so best to Say wrapped in "" for copypasta purposes //// warninkkks !!! is no error trapping !!! if you need that then mod  // -- encoder ---integer enB; string enU(integer n){   // credit: Strife    return llBase64ToString(llIntegerToBase64(        0xE0808000 | (((n + 0x800) << 12) & 0xF000000) |         (((n + 0x800) << 10) & 0x3F0000) | ((n << 8) & 0x3F00)));}   string enP(integer n){       enB = (enB << 2) | (n & 0x3);    return enU((n >> 2) & 0x7FFF) + enU((n >> 17) & 0x7FFF); }   string Key2UTF(key k){       string s = (string)k;    string r =        enP((integer)("0x" + llGetSubString(s, 28, 35))) +       enP((integer)("0x" + llGetSubString(s, 19, 22) + llGetSubString(s, 24, 27))) +       enP((integer)("0x" + llGetSubString(s,  9, 12) + llGetSubString(s, 14, 17))) +       enP((integer)("0x" + llGetSubString(s,  0,  7)));    return r + enU(enB & 0xFF);}// --- end encoder ---   // --- decoder ---integer deB;list deH = ["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f"];   integer deU(string s){   // credit: Becky     s = llEscapeURL(s);    return        ((((integer)("0x" + llGetSubString(s, 1, 2)) & 0x1F) << 12) |         (((integer)("0x" + llGetSubString(s, 4, 5)) & 0x3F) << 6) |          ((integer)("0x" + llGetSubString(s, 7, 8)) & 0x3F)) - 0x800;}    string deP(string s){    integer n = (deU(llGetSubString(s, 1, 1)) << 17) |                (deU(llGetSubString(s, 0, 0)) << 2) | (deB & 0x3);    deB = deB >> 2;    return          llList2String(deH, (n >> 28) & 0xF) + llList2String(deH, (n >> 24) & 0xF) +        llList2String(deH, (n >> 20) & 0xF) + llList2String(deH, (n >> 16) & 0xF) +        llList2String(deH, (n >> 12) & 0xF) + llList2String(deH, (n >>  8) & 0xF) +        llList2String(deH, (n >>  4) & 0xF) + llList2String(deH, n & 0xF);}     key UTF2Key(string s){      deB = deU(llGetSubString(s, 8, 8));    return (key)(        deP(llGetSubString(s, 6, 7)) + "-" +        llInsertString(deP(llGetSubString(s, 4, 5)), 4, "-") + "-" +        llInsertString(deP(llGetSubString(s, 2, 3)), 4, "-") +        deP(llGetSubString(s, 0, 1)));}// --- end decoder --- // --- some test code --- list keys = [    "ffffffff-ffff-ffff-ffff-ffffffffffff",    "88888888-8888-8888-8888-888888888888",    "77777777-7777-7777-7777-777777777777",    "01234567-8901-2345-6789-012345678901",    "01234567-89ab-cdef-fedc-ba9876543210",    "abcdeffe-dcba-abcd-effe-dcbaabcdeffe",    "c9012a38-3f29-6ef3-fc21-4380aecd5927",    "00000000-0000-0000-0000-000000000000"      ]; string utfs = "蟿蟿蟿蟿蟿蟿蟿蟿ࣿ|⨢䱄⨢䱄⨢䱄⨢䱄ࠀ|旝䎻旝䎻旝䎻旝䎻ࣿ|橀⪳䡈㯄僑䲀奙࢑ࣝ|ᒄ䌪㚦蝮筻䳕奙࢑ࣰ|菿左㼮翿㋳癝菿左࢚|幉彦壠蘐掼➔劎沀࠳|ࠀࠀࠀࠀࠀࠀࠀࠀࠀ"; default{    touch_end(integer total_number)    {        key k;        key d;        string s;        integer i;                // encode/decode list keys        integer t = llGetListLength(keys);        llOwnerSay("begin... encode/decode check");        for (i = 0; i < t; i++)        {            k = llList2Key(keys, i);            s = Key2UTF(k);            d = UTF2Key(s);            llOwnerSay(                (string)k + " " +  // rem this if just want the utf                "\"" + s + "\""                 + " " + (string)d  // and this             );        }         llOwnerSay("...end");               // decode utf pipe set (utfs) that been copypasta into this script        llOwnerSay("begin... decode copypasta utfs set separated by |");        list ukeys = llParseStringKeepNulls(utfs, ["|"], []);        t = llGetListLength(ukeys);        for (i = 0; i < t; i++)        {            s = llList2String(ukeys, i);            k = UTF2Key(s);            llOwnerSay("\"" + s + "\" " + (string)k);        }             llOwnerSay("...end");                 // make a utf pipe set from list keys        t = llGetListLength(keys);        llOwnerSay("begin... make a utf set separated by |");        s = "\"";        for (i = 0; i < (t - 1); i++)        {            k = llList2Key(keys, i);            s += Key2UTF(k) + "|";        }        k = llList2Key(keys, i);        s += Key2UTF(k) + "\"";         llOwnerSay(s);        llOwnerSay("...end");    }}

 

 

Link to post
Share on other sites


revochen Mayne wrote:

Yes but i believe its much more convenient to read as a while loop or flow control structure if possible and even might be less code.

Chapeau! if the code runs proper. I rarely see such code. Reminds me on BASIC :matte-motes-nerdy:

is old old school that coding style. comes from assembler

i also found out tho in rewriting is that LSL MONO is best written with zero tricks. Everything that everybody ever learn about tricks on old LSL they should forget

the MONO compiler needs really plain simple code if is to produce fast runtime code

things I found out: the don't do this list:

if (!b) : write: if (b == 0)

if (~b) : write: if (b >= 0)

while ((--i)): write: while (i > 0) --i;

LSL MONO compiler optimises plain ordinary equality assignments. Everything else is dog food

the worst thing can write is stuff like this

while (!(b = (something)) && ((n++) < somethingelse)

which is why I end up writing the 1st in old school. bc I was coding before like in the last example

so thanks (: bc I would never have learned about this if you hadnt said what you did

Link to post
Share on other sites


Dora Gustafson wrote:


You will love to learn the history behind it. Look

The thread contains entertainment, wisdom and drama, all in one thread

:smileysurprised:
:)
:smileyvery-happy:

drama !!! wut ??!?!!? where !???!!!

oh! that thread. jejejejeje (:

Link to post
Share on other sites


irihapeti wrote:


revochen Mayne wrote:

It is definitely my candidate for the geek script of the year! :matte-motes-nerdy:

i am not a geek ok. imma a nerd. I done a test on the internets (:

is official: 52 % Nerd, 22% Geek, 22% Dork


all i can say is how can anyone not love you!

Link to post
Share on other sites


revochen Mayne wrote:

Sorry, wasn't intended as offence. I even love those type of code allthough i rarely understand it yet.

...

Perhaps  irihapeti would be so kind as to comment her code for the rest of us.

 

Not all of us are familiar with these "<<", "&" and "|" operators or what "0xE08080000" might signify (the wiki doesn't help much!) and an explanation of how you're using them to accomplish what purpose and why would be appropriate here.

 

You could start with "0xE0808000"- what is the significance of it and how is it being used? And then go on to tell us what is happening In the code surrounding it, please.

Link to post
Share on other sites

maybe you could write the wiki entry yourself. Me not being a wiki editor. It would be more useful i think. As more people going to go to the wiki than will ever read this post. It soon be buried and forgotten in a few days. Unlike the wiki

+

just as a FYI. the very first writing of the encoder was:

 

string eih(integer n, integer i){       string r;    while (~--i)     {        r = llGetSubString("0123456789abcdef", n & 15, n & 15) + r;        n = n >> 4;    }        return r;}// -- encoder ---string eiu(integer n){       n += 0x800;    return llUnescapeURL(        "%" + eih(0xe0 + (n >> 12), 2) +        "%" + eih(0x80 + ((n >> 6) & 0x3f), 2) +        "%" + eih(0x80 + (n & 0x3f), 2));}

 

can see for this that is clear what is the significance of 0xE0808000 and how is being used

+

A very helpful person commented on this codes at the time and said can get a performance gain if rewrite the same as is now. The int2hex is a killer. And I say to them thanks and say thats really good of you to help me like that and I change the codes to that way

they didnt think they had anything to prove when they made the suggestion. I accept in the spirit it was given and I was happy to be helped and accepting off it

+

I was always accept help and suggestions in the spirit is given

Link to post
Share on other sites


irihapeti wrote:

maybe you could write the wiki entry yourself. Me not being a wiki editor. It would be more useful i think. As more people going to go to the wiki than will ever read this post. It soon be buried and forgotten in a few days. Unlike the wiki

+

just as a FYI. the very first writing of the encoder was:

 
string eih(integer n, integer i){       string r;    while (~--i)     {        r = llGetSubString("0123456789abcdef", n & 15, n & 15) + r;        n = n >> 4;    }        return r;}// -- encoder ---string eiu(integer n){       n += 0x800;    return llUnescapeURL(        "%" + eih(0xe0 + (n >> 12), 2) +        "%" + eih(0x80 + ((n >> 6) & 0x3f), 2) +        "%" + eih(0x80 + (n & 0x3f), 2));}

 

can see for this that is clear what is the significance of 0xE0808000 and how is being used

+

A very helpful person commented on this codes at the time and said can get a performance gain if rewrite the same as is now. The int2hex is a killer. And I say to them thanks and say thats really good of you to help me like that and I change the codes to that way

they didnt think they had anything to prove when they made the suggestion. I accept in the spirit it was given and I was happy to be helped and accepting off it

+

I was always accept help and suggestions in the spirit is given

When modding other peoples' code, it pays to familiarize oneself with what is going on. The significance of 0xE0808000 is in the encoding of an integer to UTF16 which uses an intermediate step using one or more UTF8 encoded bytes. It turns on the required bits so llBase64ToString(llIntegerToBase64()) knows to encode exactly three bytes of the integer (no more, no less) to the resulting U+0800 - U+87FF code point. See http://en.wikipedia.org/wiki/UTF-8#Description for details.

 

I contribute to the wiki at times because I use from it and am able to give back in a meaningful way. However, I fail to see how that addresses the lack of comments in your code that might help someone like revochen Mayne to easier comprehend what you're doing.

Link to post
Share on other sites


irihapeti wrote:

...

I was always accept help and suggestions in the spirit is given

OK, here's a suggestion:

[Third and final edit]

After the protracted conversation that follows, I remove the crossed out suggestion below, since it's obviously flawed. It did, however, lead to some enlightening discussion about probabilities. Maybe some good will come out of that.

 

Since the odds of nine character representations matching anything BUT a specific key is minuscule (it works out to be app. 0.000,000,000,000,000,000,000,008,748 - figuring eight 15 bit possibilities and a ninth of 8 bits, ALL having to match but NOT on a boundary for a "false positive") one just needs llSubStringIndex()

 

By eliminating the spaghetti code in the search, we open up enough room for almost 10 more oranges into the crate. Like so:

integer u = -3329; // table uniqueid. can change to whicheverinteger m =  3329; // max number of records. set lower if get stack/heap collisonsstring  d;         // data tableinteger c;         // count of records in tabledefault{    link_message(integer n, integer b, string s, key k)    {        if (b != u) return;                b = 0;        if (c < m)         {            // encode            s = llDumpList2String(llParseString2List((string)k, ["-"], []), "");             string  e;            integer i;            for (i = 28; i >= 0; i -= 4)            {                n = (integer)("0x" + llGetSubString(s, i, i + 3));                b = (b << 1) | (n & 0x1);                n = (n >> 1) & 0x7FFF;                e += llBase64ToString(llIntegerToBase64(                    0xE0808000 | (((n + 0x800) << 12) & 0xF000000) |                     (((n + 0x0800) << 10) & 0x3F0000) | ((n << 8) & 0x3F00)));            }            b = (b & 0xFF);            e += llBase64ToString(llIntegerToBase64(                0xE0808000 | (((b + 0x800) << 12) & 0xF000000) |                 (((b + 0x0800) << 10) & 0x3F0000) | ((b << 8) & 0x3F00)));                        // search            if(~llSubStringIndex(d, e))             { //we found it                b = 1;            }            else            {                // add to data string                d += e;                b = 2;            }         }        llMessageLinked(LINK_THIS, b, "", k);    } }

 [Edited to replace faulty algorithm for the reason given.]

Link to post
Share on other sites

see what happens when concentrate on the codes and not fuss so much about what people write in their texts

is pretty good this mod you made. clean, fast and no fuss. I like it (:

 

 

Link to post
Share on other sites
  • 2 weeks later...


irihapeti wrote:

see what happens when concentrate on the codes and not fuss so much about what people write in their texts

is pretty good this mod you made. clean, fast and no fuss. I like it (:

 

 

And, on reflection, I see it was completely unneeded since the odds of ever matching anything NOT on a key boundary is vanishly small (it works out to be (number_of_keys_added - 2)*(number_of_keys_added - 1)/2*81.329228e-36 * 1/256 = approximately 0.000,000,000,000,000,000,000,008,748 - figuring 3,300 eight 15 bit possibilities with a ninth of 8 bits, all having to match) and one just needs llSubStringIndex().

 

I've changed my original code to reflect this much better solution since the chance of a false positive is so incredibly small the complication I had originally added is unnecessary.

[Edited to more correctly show that the first two additions to the data string will, of course, never result in a false match and to cite my source as to how that extremely small figure is to be obtained.

Link to post
Share on other sites

if anyone do use the above algo then replace this code:

 

 b = (b & 0xFF); e += llBase64ToString(llIntegerToBase64(     0xE0808000 | (((b + 0x800) << 12) & 0xF000000) |      (((b + 0x0800) << 10) & 0x3F0000) | ((b << 8) & 0x3F00)));

 with this

 

 b = (b & 0xFF) | 0x8800; e += llBase64ToString(llIntegerToBase64(     0xE0808000 | ((b << 12) & 0xF000000) |      ((b << 10) & 0x3F0000) | ((b << 8) & 0x3F00)));

 

+

means that the chance of cross-boundary collision is 0. 0 like in never

dunno why LepreKhaun is now regressing his own design. It dont make any sense at all to do this. The coding cost of zero collision guaranteed is zero

+

the cost of non-zero isnt mathematical when it happens. The cost is a really unhappy customer

a once in a zillion year storm ? once in a zillion zillion ? a zillion zillion zillion even. Only needs to happen once and unhappy. The coder who sold you the non-zero app in these situations will just go:

gosh !!! wow !! really ??? like relly really !!??!!? woooo !!! how unlucky can you be ??? oh! well

 

Link to post
Share on other sites


irihapeti wrote:

if anyone do use the above algo then replace this code:

 
 b = (b & 0xFF); e += llBase64ToString(llIntegerToBase64(     0xE0808000 | (((b + 0x800) << 12) & 0xF000000) |      (((b + 0x0800) << 10) & 0x3F0000) | ((b << 8) & 0x3F00)));

 with this

 
 b = (b & 0xFF) | 0x8800; e += llBase64ToString(llIntegerToBase64(     0xE0808000 | ((b << 12) & 0xF000000) |      ((b << 10) & 0x3F0000) | ((b << 8) & 0x3F00)));

 

+

means that the chance of cross-boundary collision is 0. 0 like in never

dunno why LepreKhaun is now regressing his own design. It dont make any sense at all to do this. The coding cost of zero collision guaranteed is zero

+

the cost of non-zero isnt mathematical when it happens. The cost is a really unhappy customer

a once in a zillion year storm ? once in a zillion zillion ? a zillion zillion zillion even. Only needs to happen once and unhappy. The coder who sold you the non-zero app in these situations will just go:

gosh !!! wow !! really ??? like relly really !!??!!? woooo !!! how unlucky can you be ??? oh! well

 

Well, if you want to go that way, fine. Your choice.

 

But I think my design change suggestion is much better... 

Link to post
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...