VEBtree.this

to construct a VEB tree the wished size has to be provided. However, the size should be greater then one and should not excess the maximum allowed size for the current architecture.

  1. this()
  2. this(size_t value)
    class VEBtree
    nothrow
    this
    (
    size_t value
    )
  3. this(R range)

Examples

auto currentSeed = unpredictableSeed();
static if(vdebug){write("UT: vT, __ctor.       "); writeln("seed: ", currentSeed);} 
rndGenInUse.seed(currentSeed); //initialize the random generator

auto uS = uniform(1U << size_t(1),testedSize, rndGenInUse);
const VEBtree vT = new VEBtree(uS); 
assert(vT.empty);
if((uS & (uS - 1)) == 0)
    assert(vT.capacity == uS); 
else
    assert(vT.capacity == (size_t(1) << (bsr(uS) + 1))); 

assert(vT.expectedSize == uS); 

const auto uS1 = uniform(1U << size_t(1),testedSize, rndGenInUse);
const auto uSsmall = uniform(1U << size_t(1),baseSize, rndGenInUse);
VEBtree vT1 = new VEBtree(uS1); 
const VEBtree vTsmall = new VEBtree(uSsmall); 

assert(vTsmall.root._val == 0);
assert(vTsmall.root.ptrArr == null); 

if(uS1 > 8 * size_t.sizeof)
{
    assert(vT1.root._val == 1);
    assert(vT1.root.ptrArr != null); 

    //check every child for consistency. 
    // the size of a node is higher square root & the summary node. 

    // capacity is tested elsewhere. 
    // hSR is also tested elsewhere
    const auto childsAmount_l1 = hSR(vT1.capacity) + 1; 
    const auto childsAmount_l2 = hSR(lSR(vT1.capacity)) > baseSize ? hSR(lSR(vT1.capacity)) + 1 : 0; 

    // the tree is just created, assert all children are nullified
    for(size_t i; i < childsAmount_l1; ++i)
    {
        assert(vT1.root.ptrArr[i].isNull);
        if(childsAmount_l1 > baseSize + 1)
        {
            for(size_t j; j < childsAmount_l2; ++j)
            {
                assert(vT1.root.ptrArr[i].ptrArr[j].isNull);
            }
        }
    }
}

Meta