VEBtree.insert

this method is used to add an element to the tree. duplicate values will be ignored. the class provides an intermediate layer between the caller and the contained root and enrichs the input by the stored size.

  1. bool insert(size_t value)
    class VEBtree
    @nogc nothrow
    bool
    insert
    (
    size_t value
    )
  2. void insert(R arr)

Examples

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

auto uS = uniform(allowedArraySize,testedSize, rndGenInUse);
VEBtree vT = new VEBtree(uS); 

size_t n; 
uint[allowedArraySize] insertedVals;  
while(n < allowedArraySize)
{
    auto valToInsert = uniform(0U, uS, rndGenInUse); 
    const bool inserted = vT.insert(valToInsert); 
    if(inserted)
    {
        insertedVals[n] = valToInsert; 
        n++;
    }
}
assert(vT._elementCount == insertedVals.length); 

sort(insertedVals[]); 
assert(uniq(insertedVals[]).array.length == insertedVals.length); 

Meta