- Timestamp:
- 02/17/10 00:30:46 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Selection/3.3/MergingReducer.cs
r1530 r2817 1 1 #region License Information 2 2 /* HeuristicLab 3 * Copyright (C) 2002-20 08Heuristic and Evolutionary Algorithms Laboratory (HEAL)3 * Copyright (C) 2002-2010 Heuristic and Evolutionary Algorithms Laboratory (HEAL) 4 4 * 5 5 * This file is part of HeuristicLab. … … 20 20 #endregion 21 21 22 using System;23 22 using System.Collections.Generic; 24 using System.Text;25 23 using HeuristicLab.Core; 26 using HeuristicLab.Operators; 24 using HeuristicLab.Data; 25 using HeuristicLab.Parameters; 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 27 27 28 28 namespace HeuristicLab.Selection { 29 29 /// <summary> 30 /// Merges all sub scopes of the children to one list.30 /// An operator which reduces to the sub-scopes of all sub-scopes of the current scope. 31 31 /// </summary> 32 public class MergingReducer : ReducerBase {33 /// <inheritdoc select="summary"/>34 public override string Description {35 get { return @"TODO\r\nOperator description still missing ..."; }36 }32 [Item("MergingReducer", "An operator which reduces to the sub-scopes of all sub-scopes of the current scope.")] 33 [EmptyStorableClass] 34 [Creatable("Test")] 35 public sealed class MergingReducer : Reducer { 36 public MergingReducer() : base() { } 37 37 38 /// <summary> 39 /// Merges all sub scopes of the sub scopes of the current <paramref name="scope"/>. 40 /// </summary> 41 /// <param name="scope">The current scope whose sub scopes to merge.</param> 42 /// <returns>A list of all merged subscopes of the given <paramref name="scope"/>.</returns> 43 protected override ICollection<IScope> Reduce(IScope scope) { 44 List<IScope> subScopes = new List<IScope>(); 45 46 for (int i = 0; i < scope.SubScopes.Count; i++) { 47 for (int j = 0; j < scope.SubScopes[i].SubScopes.Count; j++) 48 subScopes.Add(scope.SubScopes[i].SubScopes[j]); 49 } 50 return subScopes; 38 protected override ScopeList Reduce(ScopeList scopes) { 39 ScopeList reduced = new ScopeList(); 40 for (int i = 0; i < scopes.Count; i++) 41 reduced.AddRange(scopes[i].SubScopes); 42 return reduced; 51 43 } 52 44 }
Note: See TracChangeset
for help on using the changeset viewer.