Skip to content

Non-deterministic enumeration of weights in OverlappingModel #19

@nanodeath

Description

@nanodeath

While porting this over to Kotlin (whee), I discovered what I think is the root cause of my troubles: when populating the patterns and stationary arrays in OverlappingModel, the keys of weight are iterated over. The order of this enumeration is non-deterministic, and the patterns and stationary can vary significantly based on the ordering.

For purposes of enumeration, each item in the dictionary is treated as a KeyValuePair<TKey, TValue> structure representing a value and its key. The order in which the items are returned is undefined.
https://msdn.microsoft.com/en-us/library/xfhwa508(v=vs.110).aspx

The affected code is here:

        foreach (int w in weights.Keys)
        {
            patterns[counter] = patternFromIndex(w);
            stationary[counter] = weights[w];
            counter++;
        }

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions