Ignore:
Timestamp:
02/05/15 13:55:04 (7 years ago)
Author:
bburlacu
Message:

#2223: Moved Data member to the generic versions of Vertex and Arc (restricted to be an IDeepCloneable). Fixed AddVertices method and added complementary AddArcs and RemoveArcs methods.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Core/3.3/Collections/DirectedGraph/Vertex.cs

    r11263 r11912  
    5252    }
    5353
    54     [Storable]
    55     private IDeepCloneable data;
    56     public IDeepCloneable Data {
    57       get { return data; }
    58       set {
    59         if (data == value) return;
    60         data = value;
    61         OnChanged(this, EventArgs.Empty);
    62       }
    63     }
    64 
    6554    private readonly List<IArc> inArcs = new List<IArc>();
    6655    public IEnumerable<IArc> InArcs {
     
    8372    private void AfterDeserialization() { }
    8473
    85     public Vertex(IDeepCloneable data) {
    86       this.data = data;
    87     }
     74    public Vertex() { }
    8875
    8976    protected Vertex(Vertex original, Cloner cloner)
    9077      : base(original, cloner) {
    91       data = cloner.Clone(original.Data);
    9278      label = original.Label;
    9379      weight = original.Weight;
    94 
    9580      // we do not clone the arcs here (would cause too much recursion and ultimately a stack overflow)
    9681    }
     
    157142
    158143  [StorableClass]
    159   public class Vertex<T> : Vertex, IVertex<T> where T : class,IItem {
    160     public new T Data {
    161       get { return (T)base.Data; }
    162       set { base.Data = value; }
     144  public class Vertex<T> : Vertex, IVertex<T> where T : class,IDeepCloneable {
     145    [Storable]
     146    private T data;
     147    public T Data {
     148      get { return data; }
     149      set {
     150        if (data == value) return;
     151        data = value;
     152        OnChanged(this, EventArgs.Empty);
     153      }
    163154    }
    164155
     
    168159    protected Vertex(Vertex<T> original, Cloner cloner)
    169160      : base(original, cloner) {
     161      if (original.Data != null)
     162        Data = cloner.Clone(original.Data);
    170163    }
    171164
    172     public Vertex(IDeepCloneable data)
    173       : base(data) {
    174     }
     165    public Vertex() : base() { }
    175166
    176167    public override IDeepCloneable Clone(Cloner cloner) {
Note: See TracChangeset for help on using the changeset viewer.