- Timestamp:
- 04/07/09 11:34:49 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Persistence/Default/Decomposers/ArrayDecomposer.cs
r1463 r1518 15 15 Array a = (Array)array; 16 16 yield return new Tag("rank", a.Rank); 17 int[] lengths = new int[a.Rank]; 18 int[] lowerBounds = new int[a.Rank]; 17 19 for (int i = 0; i < a.Rank; i++) { 20 lengths[i] = a.GetLength(i); 18 21 yield return new Tag("length_" + i, a.GetLength(i)); 19 22 } 20 23 for (int i = 0; i < a.Rank; i++) { 24 lowerBounds[i] = a.GetLowerBound(i); 21 25 yield return new Tag("lowerBound_" + i, a.GetLowerBound(i)); 22 26 } 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 } 25 39 } 26 40 }
Note: See TracChangeset
for help on using the changeset viewer.