Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/07/09 11:34:49 (15 years ago)
Author:
epitzer
Message:

Make serialization order of array components explicit (in all array decomposers) (#574)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Persistence/Default/Decomposers/ArrayDecomposer.cs

    r1463 r1518  
    1515      Array a = (Array)array;     
    1616      yield return new Tag("rank", a.Rank);
     17      int[] lengths = new int[a.Rank];
     18      int[] lowerBounds = new int[a.Rank];
    1719      for (int i = 0; i < a.Rank; i++) {
     20        lengths[i] = a.GetLength(i);
    1821        yield return new Tag("length_" + i, a.GetLength(i));
    1922      }
    2023      for (int i = 0; i < a.Rank; i++) {
     24        lowerBounds[i] = a.GetLowerBound(i);
    2125        yield return new Tag("lowerBound_" + i, a.GetLowerBound(i));
    2226      }
    23       foreach (object o in (Array)array) {
    24         yield return new Tag(null, o);
     27      int[] positions = (int[])lowerBounds.Clone();
     28      while (positions[a.Rank - 1] < lengths[a.Rank - 1] + lowerBounds[a.Rank - 1]) {
     29        yield return new Tag(a.GetValue(positions));
     30        positions[0] += 1;
     31        for (int i = 0; i < a.Rank - 1; i++) {
     32          if (positions[i] >= lowerBounds[i] + lengths[i]) {
     33            positions[i] = lowerBounds[i];
     34            positions[i + 1] += 1;
     35          } else {
     36            break;
     37          }
     38        }
    2539      }
    2640    }
Note: See TracChangeset for help on using the changeset viewer.