Here's a link to this code: Red Black TreesRed Black Trees, Eternally Confuzzled

Here's a link to this code: Red Black Trees, Eternally Confuzzled

Here's a link to this code: Red Black Trees, Eternally Confuzzled

Made compliant with the Jon Skeet Decree - <https://twitter.com/PeterMortensen/status/976400000942034944>.
Source Link
Peter Mortensen
  • 29.8k
  • 21
  • 98
  • 124
// declareDeclare and then fill in the lookup table
int lut[256];
for (unsigned c = 0; c < 256; ++c)
    lut[c] = (c >= 128) ? c : 0;

// useUse the lookup table after it is built
for (unsigned i = 0; i < 100000; ++i)
{
    // Primary loop
    for (unsigned c = 0; c < arraySize; ++c)
    {
        sum += lut[data[c]];
    }
}
// declare and then fill in the lookup table
int lut[256];
for (unsigned c = 0; c < 256; ++c)
    lut[c] = (c >= 128) ? c : 0;

// use the lookup table after it is built
for (unsigned i = 0; i < 100000; ++i)
{
    // Primary loop
    for (unsigned c = 0; c < arraySize; ++c)
    {
        sum += lut[data[c]];
    }
}
// Declare and then fill in the lookup table
int lut[256];
for (unsigned c = 0; c < 256; ++c)
    lut[c] = (c >= 128) ? c : 0;

// Use the lookup table after it is built
for (unsigned i = 0; i < 100000; ++i)
{
    // Primary loop
    for (unsigned c = 0; c < arraySize; ++c)
    {
        sum += lut[data[c]];
    }
}
readers generally don't care about what has been added or removed, they just want to read a good post. For those who are more curious, there is the edit history. https://meta.stackexchange.com/a/127655/316262
Source Link
Neuron
  • 4.2k
  • 4
  • 28
  • 50

EDIT: One thing I forgot to put in.

The technique of indexing into an array, instead of using an if statement, can be used for deciding which pointer to use. I saw a library that implemented binary trees, and instead of having two named pointers (pLeft and pRight or whatever) had a length-2 array of pointers and used the "decision bit" technique to decide which one to follow. For example, instead of:

EDIT: One thing I forgot to put in.

The technique of indexing into an array, instead of using an if statement, can be used for deciding which pointer to use. I saw a library that implemented binary trees, and instead of having two named pointers (pLeft and pRight or whatever) had a length-2 array of pointers and used the "decision bit" technique to decide which one to follow. For example, instead of:

The technique of indexing into an array, instead of using an if statement, can be used for deciding which pointer to use. I saw a library that implemented binary trees, and instead of having two named pointers (pLeft and pRight or whatever) had a length-2 array of pointers and used the "decision bit" technique to decide which one to follow. For example, instead of:

Mod Removes Wiki by Shog9
Post Made Community Wiki by George Stocker
textified link - feel free to rollback
Source Link
Mark Rogers
  • 93.1k
  • 18
  • 84
  • 134
Loading
add more
Source Link
steveha
  • 70.6k
  • 19
  • 89
  • 116
Loading
Source Link
steveha
  • 70.6k
  • 19
  • 89
  • 116
Loading