Bins

The struct Bins is a container holding binned data

Members

Functions

opApply
int opApply(int delegate(ref T) dg)
Undocumented in source. Be warned that the author may not have intended to support it.
opApply
int opApply(int delegate(double, ref T) dg)
Undocumented in source. Be warned that the author may not have intended to support it.
opIndex
T opIndex(size_t index)

Access bin by index

Properties

length
size_t length [@property getter]

How many bins does the container have

length
size_t length [@property setter]

Set length/number of bins

max
double max [@property getter]
Undocumented in source. Be warned that the author may not have intended to support it.
save
Bins!T save [@property getter]

save the container position

Variables

min
double min;
Undocumented in source.
width
double width;
Undocumented in source.

Examples

For loop over Bins

Bins!size_t bins;
bins.min = -1;
bins.width = 0.5;
bins.mybins = [1,2,3,4];

size_t correct_el = 1;
foreach ( el; bins ) {
    assert( correct_el == el );
    correct_el++;
}

double correct_x = bins.min;
correct_el = 1;
foreach ( x, el; bins ) {
    assert( correct_x == x );
    assert( correct_el == el );
    correct_x += bins.width;
    correct_el++;
}

Number of Bins

    Bins!size_t bins;
    bins.min = -1;
    bins.width = 0.5;
		bins.length = 3;
		assert( bins.length == 3 );
		assert( equal( bins.mybins, [0,0,0] ) );

Meta