On Tuesday, 3 November 2015 at 08:23:20 UTC, Ali Çehreli wrote:
> "Programming in D" book (the revision of 2015-10-24)

Oooh! That smells very fresh. :)

:)

> In my case, the container class can't become empty. Even if
it contains
> one single element, in this case the example should return
true for
> begin == end, it is not empty.

That problem is solved by the convention that 'end' is one beyond the last valid element. So, when there is only the element 42, then begin==42 and end==43. Only when the last element (42 in this case) is consumed, begin==end.

This part is dangerous, and I'm not sure how dangerous it is. Now, I have to dive into my structure a little bit deeper:
Say, I have three classes:


class B //current structure
{
    M[] _ms;
    P[] _ps;
    P[M] assoc;
}

struct M
{
    int id;
    alias id this;
}

struct P
{
    int id;
    alias id this;
    int begin;
    int end;
}

The idea is, that P structs are disjunct (and contigous, if this does matter) arrays of M's. And the question is, what happens, if I set the end property of a P to a number, which belongs to another P. At the current time class B contains arrays of different M's (constant, big one, say order of 10^6 elements, elements itself are not very large, say about 5 members and a bunch of properties calculated at runtime) as well as an array of P's (at the beginning not so big one, but growing fast) and the array of associations between the M's and P's. In my program I implement this array as int[int], and reassign the associated values at the same time as the array of P's is growing.

Here I have to deliver the "buzz words", so I'm trying to implement a set partition algorithm with disjoint sets. With the standard question how to achieve the fastest cutting of the whole array into its single components. The application in my case are just some constraints which say, how the cutting is allowed.

Such ranges are called generators.
ok, cool! Thx.

Reply via email to