Free cookie consent management tool by TermsFeed Policy Generator

Changeset 1463


Ignore:
Timestamp:
03/30/09 12:51:34 (16 years ago)
Author:
epitzer
Message:

Properly fill arrays with non-zero lower bounds (#561)

Location:
trunk/sources
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Persistence.Test/NewSerializationTest.cs

    r1456 r1463  
    188188
    189189    public static void Test4() {
    190       ArrayList[] arrayListArray = new ArrayList[3];
     190      ArrayList[] arrayListArray = new ArrayList[4];
    191191      arrayListArray[0] = new ArrayList();
    192192      arrayListArray[0].Add(arrayListArray);
     
    197197      arrayListArray[2].Add(arrayListArray);
    198198      arrayListArray[2].Add(arrayListArray);
     199      Array a = Array.CreateInstance(
     200                              typeof(object),
     201                              new[] { 1, 2 }, new[] { 3, 4 });
     202      arrayListArray[2].Add(a);
    199203      XmlGenerator.Serialize(arrayListArray, "test4");
    200204      object o = XmlParser.DeSerialize("test4");
  • trunk/sources/HeuristicLab.Persistence/Default/Decomposers/ArrayDecomposer.cs

    r1454 r1463  
    4343        e.MoveNext();
    4444        lowerBounds[i] = (int)e.Current.Value;
    45       }
    46       Array a = Array.CreateInstance(t.GetElementType(), lengths, lowerBounds);     
    47       int[] positions = new int[rank];
     45      }     
     46      Array a = Array.CreateInstance(t.GetElementType(), lengths, lowerBounds);
     47      int[] positions = (int[])lowerBounds.Clone();
    4848      while (e.MoveNext()) {
    4949        int[] currentPositions = positions;
     
    5151        positions[0] += 1;
    5252        for (int i = 0; i < rank-1; i++) {
    53           if (positions[i] >= lengths[i]) {
    54             positions[i] = 0;
     53          if (positions[i] >= lengths[i]+lowerBounds[i]) {
     54            positions[i] = lowerBounds[i];
    5555            positions[i + 1] += 1;
    5656          } else {
Note: See TracChangeset for help on using the changeset viewer.