LPCounter

Simple Linear Probabilistic Counter.

Constructors

this
this()
Undocumented in source.
this
this(size_t kilobytes)

Constructs counter with appropriate size.

this
this(void[] dump)

Constructs counter with predefined dump.

Members

Functions

count
ulong count()
dump
const(ubyte)[] dump()
opOpAssign
void opOpAssign(LPCounter counter)

Merges a counter into this one.

opOpAssign
void opOpAssign(Range counters)

Merges a set of LPCounters into this one.

put
void put(uint data)
void put(ulong data)

Puts integer to a counter.

put
void put(UUID data)

Puts UUID to a counter.

put
void put(void[] data)

Puts raw data to a counter.

size
size_t size()

Examples

auto counter = LPCounter(32);
counter.put(100U);
counter.put(100UL);
counter.put("100");
assert(counter.count == 3);
counter.put("101");
assert(counter.count == 4);
auto a = LPCounter(32);
a.put(100U);
a.put(100UL);
a.put("100");
assert(a.count == 3);

auto b = LPCounter(32);
b.put(100U); // intersection
b.put(200U);
b.put("LP");
assert(b.count == 3);

auto c = LPCounter(32);

c += [a, b];
assert(c.count == 5);

a += b;
assert(a.count == 5);

Meta