Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
02/19/10 02:15:10 (14 years ago)
Author:
swagner
Message:

Operator architecture refactoring (#95)

  • worked on operators and SGA
  • improved performance
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Core/3.3/ItemArray.cs

    r2790 r2830  
    2121
    2222using System;
     23using System.Linq;
    2324using System.Collections;
    2425using System.Collections.Generic;
     
    5556    public ItemArray() : base() { }
    5657    public ItemArray(int length) : base(length) { }
    57     public ItemArray(T[] array) : base(array) { }
    58     public ItemArray(IEnumerable<T> collection) : base(collection) { }
     58    public ItemArray(T[] array) : base(array) {
     59      foreach (T item in this)
     60        item.Changed += new ChangedEventHandler(Item_Changed);
     61    }
     62    public ItemArray(IEnumerable<T> collection) : base(collection) {
     63      foreach (T item in this)
     64        item.Changed += new ChangedEventHandler(Item_Changed);
     65    }
    5966
    6067    public object Clone() {
     
    6269    }
    6370
    64     public IDeepCloneable Clone(Cloner cloner) {
    65       T[] items = new T[Length];
    66       for (int i = 0; i < items.Length; i++)
    67         items[i] = (T)cloner.Clone(this[i]);
    68       ItemArray<T> clone = (ItemArray<T>)Activator.CreateInstance(this.GetType(), new object[] { items });
     71    public virtual IDeepCloneable Clone(Cloner cloner) {
     72      ItemArray<T> clone = (ItemArray<T>)Activator.CreateInstance(this.GetType(), this.Select(x => (T)cloner.Clone(x)));
    6973      cloner.RegisterClonedObject(this, clone);
    7074      return clone;
Note: See TracChangeset for help on using the changeset viewer.