Changeset 15189 for branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Stack
- Timestamp:
- 07/10/17 21:36:03 (7 years ago)
- Location:
- branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Stack
- Files:
-
- 2 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Stack/IPushStack.cs
r15017 r15189 1 1 namespace HeuristicLab.Problems.ProgramSynthesis.Push.Stack { 2 using System;3 2 using System.Collections.Generic; 4 3 … … 18 17 void Push(IEnumerable<T> items); 19 18 new void Clear(); 20 T Peek(); 21 T[] Peek(int count); 22 void PushResult(int count, Func<T[], T> templateFunc); 19 IReadOnlyList<T> Peek(int count); 23 20 void Insert(int index, T item); 24 T ReverseElementAt(int offset);25 21 T Pop(); 26 T[]Pop(int count);22 IReadOnlyList<T> Pop(int count); 27 23 bool TryPop(out T item); 28 24 T ElementAt(int index); -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Stack/InterpreterStackStringifier.cs
r15017 r15189 45 45 46 46 private static IEnumerable<string> StringifyLiteralStack<T>(IPushStack<T> stack, string prefix = "", string postfix = "", bool reverse = true) { 47 var result = stack.As Enumerable();47 var result = stack.AsStrings(); 48 48 49 49 if (reverse) -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Stack/PushStack.cs
r15017 r15189 122 122 } 123 123 124 public T ReverseElementAt(int offset) {125 return data[offset];126 }127 128 124 public T this[int index] 129 125 { … … 145 141 if (index == Count - 1) return; 146 142 147 var item = ReverseElementAt(index);143 var item = data[index]; 148 144 data.RemoveAt(index); 149 145 data.Add(item); … … 157 153 } 158 154 159 public T[]Pop(int count) {155 public IReadOnlyList<T> Pop(int count) { 160 156 var items = Peek(count); 161 157 Remove(count); … … 164 160 } 165 161 166 public T Peek() { 167 return Top; 168 } 169 170 public T[] Peek(int count) { 162 public IReadOnlyList<T> Peek(int count) { 171 163 var startIndex = Count - count; 172 164 … … 207 199 } 208 200 209 public void PushResult(int count, Func<T[], T> templateFunc) {210 if (!IsEnabled) return;211 212 var startIndex = Count - count;213 var items = new T[count];214 215 data.CopyTo(startIndex, items, 0, count);216 Remove(count - 1);217 218 data[Count - 1] = templateFunc(items);219 }220 221 201 public void Push(IReadOnlyList<T> items, int startIndex) { 222 202 if (!IsEnabled) return; -
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Stack/StackTypes.cs
r15032 r15189 20 20 BooleanVector = 0x2000, 21 21 } 22 23 //public static class StackTypeExtensions { 24 // private static readonly IReadOnlyDictionary<StackTypes, string> StackTypesNameDict = new Dictionary<StackTypes, string> { 25 // { StackTypes.Integer, "Integer" }, 26 // { StackTypes.Float, "Float" }, 27 // { StackTypes.Char, "Char" }, 28 // { StackTypes.String, "String" }, 29 // { StackTypes.Boolean, "Boolean" }, 30 // { StackTypes.Name, "Name" }, 31 // { StackTypes.Code, "Code" }, 32 // { StackTypes.Exec, "Exec" }, 33 // { StackTypes.Print, "Print" }, 34 // { StackTypes.IntegerVector, "IntegerVector" }, 35 // { StackTypes.FloatVector, "FloatVector" }, 36 // { StackTypes.StringVector, "StringVector" }, 37 // { StackTypes.BooleanVector, "BooleanVector" }, 38 // }; 39 40 // public static string GetName(this StackTypes types) { 41 // return StackTypesNameDict[types]; 42 // } 43 //} 22 44 }
Note: See TracChangeset
for help on using the changeset viewer.