Free cookie consent management tool by TermsFeed Policy Generator

source: branches/HeuristicLab.MetaOptimization/HeuristicLab.Problems.MetaOptimization/3.3/ConstrainedItemList.cs @ 7952

Last change on this file since 7952 was 5110, checked in by cneumuel, 14 years ago

#1215

  • optional parameter values now can be null
  • problem type can now be set specifically
  • values are constrained to the encoding of the Problem
  • moved repetitions parameter to MetaOptimizationProblem
File size: 1.0 KB
RevLine 
[5110]1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using HeuristicLab.Core;
6using HeuristicLab.Persistence.Default.CompositeSerializers.Storable;
7using HeuristicLab.Common;
8
9namespace HeuristicLab.Problems.MetaOptimization {
10  [StorableClass]
11  public class ConstrainedItemList<T> : ItemList<T> where T : class, IItem {
12    [Storable]
13    private Type type;
14    public Type Type {
15      get { return type; }
16      set {
17        if (type != value) {
18          type = value;
19          this.RemoveAll(x => x.GetType() != type);
20        }
21      }
22    }
23
24    public ConstrainedItemList() {
25      Type = typeof(T);
26    }
27    [StorableConstructor]
28    protected ConstrainedItemList(bool deserializing) : base(deserializing) { }
29    protected ConstrainedItemList(ConstrainedItemList<T> original, Cloner cloner)
30      : base(original, cloner) {
31      this.Type = original.Type;
32    }
33    public override IDeepCloneable Clone(Cloner cloner) {
34      return new ConstrainedItemList<T>(this, cloner);
35    }
36  }
37}
Note: See TracBrowser for help on using the repository browser.