dkh.datastructure.fastset

  • Declaration

    struct FastSet;

    almost same bool[int], except key range is stricted

    Examples

    1. import std.algorithm : equal, map; import std.range : iota; auto fs = FastSet(10); fs.insert(1); fs.insert(5); fs.insert(6); fs.remove(5); fs.insert(4); // [1, 4, 6] assert(1 in fs); assert(2 !in fs); assert(5 !in fs); assert(6 in fs); assert(equal([1, 4, 6], fs[])); assert(equal( iota(8).map!(i => fs.next(i)), [1, 1, 4, 4, 4, 6, 6, 10] )); assert(equal( iota(8).map!(i => fs.prev(i)), [-1, 1, 1, 1, 4, 4, 6, 6] )); assert(equal([1], fs.lowerBound(4))); assert(equal([1, 4], fs.lowerBound(5))); assert(equal([1, 4, 6], fs.upperBound(0))); assert(equal([4, 6], fs.upperBound(1)));

    • Declaration

      this(size_t n);

      make set for [0, 1, ..., n-1]

    • Declaration

      const bool empty();

    • Declaration

      const size_t length();

      count true

    • Declaration

      bool opBinaryRight(string op : "in")(size_t i);

    • Declaration

      void insert(size_t x);

    • Declaration

      void remove(size_t x);

    • Declaration

      const ptrdiff_t next(ptrdiff_t x);

      return minimum element that isn't less than x

    • Declaration

      const ptrdiff_t prev(ptrdiff_t x);

      return maximum element that isn't greater than x

    • Declaration

      Range lowerBound(ptrdiff_t x);

      return range that contain less than x

    • Declaration

      Range upperBound(ptrdiff_t x);

      return range that contain greater than x

    • Declaration

      Range opIndex();

    • Declaration

      struct Range;

      bidirectional range