pike.git / lib / modules / ADT.pmod / CritBit.pmod

version» Context lines:

pike.git/lib/modules/ADT.pmod/CritBit.pmod:1:   #pike __REAL_VERSION__ + #require constant(ADT._CritBit)      //! @ignore - #if !constant (ADT._CritBit) - constant this_program_does_not_exist = 1; - #else -  +    inherit ADT._CritBit : C;   //! @endignore      //! Creates a CritBit tree for keys of type @expr{type@}. If no argument is given,   //! an instance of @[ADT.CritBit.StringTree] is returned. Supported types are @expr{"string"@},   //! @expr{"int"@}, @expr{"float"@}, @expr{"ipv4"@} and @expr{Calendar.TimeRange@}.   object Tree(void|string|program|mapping type) {    if (type==Calendar.TimeRange)    return DateTree();    switch (type) {
pike.git/lib/modules/ADT.pmod/CritBit.pmod:157:    }   }      //! Data structure representing a set of disjunct @[ADT.Interval] objects. Can be thought   //! of as an interval with gaps.   class RangeSet {    object tree;       //! Create a RangeSet from a given tree program.    void create(function|object|program tree) { -  this_program::tree = objectp(tree) ? tree : tree(); +  this::tree = objectp(tree) ? tree : tree();    }       mixed `[](mixed key) {    if (objectp(key) && Program.inherits(object_program(key), ADT.Interval))    return contains(key);    mixed next = tree[key];    if (!undefinedp(next)) return next->contains(key);    next = tree->next(key);       if (next) {
pike.git/lib/modules/ADT.pmod/CritBit.pmod:267:    return 0;    }   }      class MultiRangeSet {    // mapping from left/right boundary to interval    object tree;    int|float max_len;       void create(function|program|object tree) { -  this_program::tree = objectp(tree) ? tree : tree(); +  this::tree = objectp(tree) ? tree : tree();    }       mixed `[](mixed key) {       if (!objectp(key) || !Program.inherits(object_program(key),    ADT.Interval)) {    key = ADT.Interval(key, key);    }       return contains(key);
pike.git/lib/modules/ADT.pmod/CritBit.pmod:384:    }       mixed _m_delete(mixed idx) {    return m_delete(tree, idx);    }       mixed nth(int n) {    return tree->nth(sizeof(tree)-n);    }    -  mixed _random() { -  return random(tree); +  mixed _random(function rnd_str, function rnd) { +  return rnd(tree);    }       int(0..) depth() {    return tree->depth();    }       mixed common_prefix() {    return tree->common_prefix();    }   
pike.git/lib/modules/ADT.pmod/CritBit.pmod:500:    n -= sizeof(trees[i]);    }       error("Index out of bounds.\n");    }       mixed _m_delete(mixed idx) {    return m_delete(tree(idx), idx);    }    -  mixed _random() { -  int n = random(sizeof(this)); -  return nth(n); +  mixed _random(function rnd_str, function rnd) { +  int n = sizeof(this); +  if (!n) return UNDEFINED; +  return nth(rnd(n));    }       int first() {    foreach (trees;; object t) {    if (sizeof(t)) return t->first();    }    }       int last() {    for (int i = sizeof(trees)-1; i; i --) {
pike.git/lib/modules/ADT.pmod/CritBit.pmod:597:    foreach (trees; int i; object t) {    ret->trees[i] = t - o->trees[i];    }    return ret;    }       class MultiIterator {    array oit, it;       void create(int step, mixed|void start, mixed|void stop) { -  int i = zero_type(start) ? 0 : itree(start); -  int j = zero_type(stop) ? sizeof(trees)-1 : itree(stop); +  int i = undefinedp(start) ? 0 : itree(start); +  int j = undefinedp(stop) ? sizeof(trees)-1 : itree(stop);       array t = trees[i..j];    j = sizeof(t);       if (j == 1) {    t[0] = t[0]->_get_iterator(step, start, stop);    } else {    t[0] = t[0]->_get_iterator(step, start);    for (i = 1; i < j-1; i++)    t[i] = t[i]->_get_iterator(step);    t[-1] = t[-1]->_get_iterator(step, start);    }    -  this_program::oit = t; -  this_program::it = t + ({ }); +  this::oit = t; +  this::it = t + ({ });    }       int(0..1) `!() {    while (sizeof(it) && !it[0]) it = it[1..];    return !sizeof(it);    }       int(0..1) next() {    while (sizeof(it) && !it[0]->next()) it = it[1..];    return !!sizeof(it);
pike.git/lib/modules/ADT.pmod/CritBit.pmod:657: Inside #if constant(ADT._CritBit.BigNumTree)
   array(object) trees = ({ Reverse(BigNumTree()), C::IntTree(), BigNumTree() });       int itree(mixed i) {    if (!intp(i)) error("Bad Index %O to %O\n", i, this);    if (is_bignum(i)) {    return i < 0 ? 0 : 2;    } else return 1;    }   }   #endif // constant(ADT._CritBit.BigNumTree) -  - #endif // constant(ADT._CritBit) +