Changeset 14834 for branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/ExpressionTable.cs
- Timestamp:
- 04/10/17 00:27:31 (8 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/PushGP/HeuristicLab.PushGP/HeuristicLab.Problems.ProgramSynthesis/Push/Expressions/ExpressionTable.cs
r14777 r14834 14 14 public static readonly IDictionary<int, string> IndexToNameTable = new Dictionary<int, string>(); 15 15 public static readonly IDictionary<Type, string> TypeToNameTable = new Dictionary<Type, string>(); 16 public static readonly IDictionary<Type, PushExpressionAttribute> TypeToAttributeTable = new Dictionary<Type, PushExpressionAttribute>(); 16 17 public static readonly IDictionary<StackTypes, IList<string>> StackDependencyToNamesTable = new Dictionary<StackTypes, IList<string>>(); 17 18 public static readonly string[] ExpressionNames; … … 56 57 var attribute = (PushExpressionAttribute)Attribute.GetCustomAttribute(type, typeof(PushExpressionAttribute)); 57 58 59 TypeToAttributeTable.Add(type, attribute); 58 60 dictionary.Add(attribute.ExpressionName, expression); 59 61 IndexToNameTable.Add(IndexToNameTable.Keys.Count, attribute.ExpressionName); 60 62 TypeToNameTable.Add(type, attribute.ExpressionName); 61 63 62 if (!StackTypeToNamesTable.ContainsKey(attribute.StackType s)) {63 StackTypeToNamesTable.Add(attribute.StackType s, new List<string>());64 } 65 66 StackTypeToNamesTable[attribute.StackType s].Add(attribute.ExpressionName);67 68 var dependencies = attribute.StackType s| attribute.AdditionalStackDependencies;64 if (!StackTypeToNamesTable.ContainsKey(attribute.StackType)) { 65 StackTypeToNamesTable.Add(attribute.StackType, new List<string>()); 66 } 67 68 StackTypeToNamesTable[attribute.StackType].Add(attribute.ExpressionName); 69 70 var dependencies = attribute.StackType | attribute.AdditionalStackDependencies; 69 71 if (!StackDependencyToNamesTable.ContainsKey(dependencies)) { 70 72 StackDependencyToNamesTable.Add(dependencies, new List<string>()); … … 88 90 var attribute = (PushExpressionAttribute)Attribute.GetCustomAttribute(type, typeof(PushExpressionAttribute)); 89 91 92 TypeToAttributeTable.Add(type, attribute); 90 93 dictionary.Add(attribute.ExpressionName, creator); 91 94 IndexToNameTable.Add(IndexToNameTable.Keys.Count, attribute.ExpressionName); 92 95 TypeToNameTable.Add(type, attribute.ExpressionName); 93 96 94 if (!StackTypeToNamesTable.ContainsKey(attribute.StackType s)) {95 StackTypeToNamesTable.Add(attribute.StackType s, new List<string>());96 } 97 98 StackTypeToNamesTable[attribute.StackType s].Add(attribute.ExpressionName);99 100 var dependencies = attribute.StackType s| attribute.AdditionalStackDependencies;97 if (!StackTypeToNamesTable.ContainsKey(attribute.StackType)) { 98 StackTypeToNamesTable.Add(attribute.StackType, new List<string>()); 99 } 100 101 StackTypeToNamesTable[attribute.StackType].Add(attribute.ExpressionName); 102 103 var dependencies = attribute.StackType | attribute.AdditionalStackDependencies; 101 104 if (!StackDependencyToNamesTable.ContainsKey(dependencies)) { 102 105 StackDependencyToNamesTable.Add(dependencies, new List<string>()); … … 142 145 } 143 146 144 public static IReadOnlyList<string> GetE nabledExpressionsByStackTypes(StackTypes allowedTypes) {147 public static IReadOnlyList<string> GetExpressionsByStackTypes(StackTypes allowedTypes) { 145 148 return StackDependencyToNamesTable 146 149 .Where(entry => (entry.Key & ~allowedTypes) == StackTypes.None)
Note: See TracChangeset
for help on using the changeset viewer.