Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
04/18/17 01:15:25 (8 years ago)
Author:
pkimmesw
Message:

#2665 BenchmarkSuite, all examples, partially tested, VectorExpressions added

Location:
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Stack
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Stack/IPushStack.cs

    r14834 r14875  
    99    T BottomOrDefault { get; }
    1010    T this[int key] { get; set; }
    11 
    1211    void Push(T item);
    1312    void Push(T item1, T item2);
    1413    void Push(T item1, T item2, T item3);
    1514    void Push(T item1, T item2, T item3, T item4);
    16 
    1715    void Push(IReadOnlyList<T> items, int startIndex = 0);
     16    void Push(IReadOnlyList<T> items);
    1817    T Peek();
    1918    T[] Peek(int count);
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Stack/PushStack.cs

    r14834 r14875  
    118118
    119119    public T ReverseElementAt(int offset) {
    120       return data[data.Count - 1 - offset];
     120      return data[offset];
    121121    }
    122122
     
    125125    }
    126126
    127     public T this[int key]
    128     {
    129       get
    130       {
    131         return data[key];
    132       }
    133       set
    134       {
    135         data[key] = value;
    136       }
     127    public T this[int index]
     128    {
     129      get { return data[Count - 1 - index]; }
     130      set { data[Count - 1 - index] = value; }
    137131    }
    138132
     
    141135      var bottomIndex = Count - count;
    142136
    143       for (var i = Count - 1; i > bottomIndex; i--) data[i] = data[i - 1];
     137      for (var i = Count - 1; i > bottomIndex; i--)
     138        data[i] = data[i - 1];
    144139
    145140      data[bottomIndex] = top;
     
    149144      if (index == Count - 1) return;
    150145
    151       var item = ElementAt(index);
     146      var item = ReverseElementAt(index);
    152147      data.RemoveAt(index);
    153148      data.Add(item);
     
    155150
    156151    public T Pop() {
    157       var value = data[Count - 1];
     152      var top = Top;
    158153      data.RemoveAt(Count - 1);
    159154
    160       return value;
     155      return top;
    161156    }
    162157
     
    223218    }
    224219
    225     public void Push(IReadOnlyList<T> items, int startIndex = 0) {
     220    public void Push(IReadOnlyList<T> items, int startIndex) {
    226221      if (!IsEnabled) return;
    227222
     
    229224    }
    230225
     226    public void Push(IReadOnlyList<T> items) {
     227      if (!IsEnabled) return;
     228
     229      data.AddRange(items);
     230    }
     231
    231232    public void Insert(int index, T item) {
    232233      if (!IsEnabled) return;
    233234
    234       data.Insert(index, item);
     235      data.Insert(Count - index, item);
    235236    }
    236237
  • branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Stack/StackTypes.cs

    r14834 r14875  
    22  using System;
    33
     4  // Be aware that it is assumed that this values are equal to HeuristicLab.BenchmarkSuite.DataTypes
    45  [Flags]
    56  public enum StackTypes : ushort {
     
    1314    Code = 0x80,
    1415    Exec = 0x100,
    15     IntegerVector = 0x200,
    16     FloatVector = 0x400,
    17     BooleanVector = 0x800,
    18     StringVector = 0x1000
     16    Return = 0x200,
     17    IntegerVector = 0x400,
     18    FloatVector = 0x800,
     19    StringVector = 0x1000,
     20    BooleanVector = 0x2000
    1921  }
    2022}
Note: See TracChangeset for help on using the changeset viewer.