- Timestamp:
- 07/30/14 15:02:27 (10 years ago)
- Location:
- trunk/sources/HeuristicLab.Core/3.3/Collections/DirectedGraph
- Files:
-
- 1 added
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Core/3.3/Collections/DirectedGraph/Vertex.cs
r11239 r11241 24 24 using System.Linq; 25 25 using HeuristicLab.Common; 26 using HeuristicLab.Core;27 26 using HeuristicLab.Persistence.Default.CompositeSerializers.Storable; 28 27 29 namespace HeuristicLab. Problems.DataAnalysis.Symbolic{28 namespace HeuristicLab.Core { 30 29 [StorableClass] 31 30 public class Vertex : Item, IVertex { 32 31 [Storable] 33 pr otectedstring label;32 private string label; 34 33 public string Label { 35 34 get { return label; } … … 42 41 43 42 [Storable] 44 pr otecteddouble weight;43 private double weight; 45 44 public double Weight { 46 45 get { return weight; } … … 53 52 54 53 [Storable] 55 pr otected object content;56 public object Content{57 get { return content; }54 private IDeepCloneable data; 55 public IDeepCloneable Data { 56 get { return data; } 58 57 set { 59 if ( content== value) return;60 content= value;58 if (data == value) return; 59 data = value; 61 60 OnChanged(this, EventArgs.Empty); 62 61 } 63 62 } 64 63 65 private List<IArc> inArcs;64 private readonly List<IArc> inArcs = new List<IArc>(); 66 65 public IEnumerable<IArc> InArcs { 67 get { return inArcs ?? Enumerable.Empty<IArc>(); }66 get { return inArcs; } 68 67 } 69 68 70 private List<IArc> outArcs;69 private readonly List<IArc> outArcs = new List<IArc>(); 71 70 public IEnumerable<IArc> OutArcs { 72 get { return outArcs ?? Enumerable.Empty<IArc>(); }71 get { return outArcs; } 73 72 } 74 73 … … 83 82 private void AfterDeserialization() { } 84 83 85 public Vertex( object content) {86 this. content = content;84 public Vertex(IDeepCloneable data) { 85 this.data = data; 87 86 } 88 87 89 88 protected Vertex(Vertex original, Cloner cloner) 90 89 : base(original, cloner) { 91 content = original.content;90 data = cloner.Clone(original.Data); 92 91 label = original.Label; 93 92 weight = original.Weight; … … 106 105 107 106 if (this == arc.Source) { 108 if (outArcs == null) 109 outArcs = new List<IArc>(); 110 else if (outArcs.Contains(arc)) 111 throw new InvalidOperationException("Arc already added."); 107 if (outArcs.Contains(arc)) throw new InvalidOperationException("Arc already added."); 112 108 outArcs.Add(arc); 113 } else if (this == arc.Target) { 114 if (inArcs == null) 115 inArcs = new List<IArc>(); 116 else if (inArcs.Contains(arc)) 117 throw new InvalidOperationException("Arc already added."); 109 } 110 if (this == arc.Target) { 111 if (inArcs.Contains(arc)) throw new InvalidOperationException("Arc already added."); 118 112 inArcs.Add(arc); 119 113 } … … 125 119 throw new InvalidOperationException("The current vertex must be either the arc source or the arc target."); 126 120 127 if (this == arc.Source && outArcs != null) { 128 if (!outArcs.Remove(arc)) 129 throw new InvalidOperationException("Arc is not present in this vertex' outgoing arcs."); 130 } else if (this == arc.Target && inArcs != null) { 131 if (!inArcs.Remove(arc)) 132 throw new InvalidOperationException("Arc is not present in this vertex' incoming arcs."); 121 if (this == arc.Source) { 122 if (!outArcs.Remove(arc)) throw new InvalidOperationException("Arc is not present in this vertex' outgoing arcs."); 123 } 124 if (this == arc.Target) { 125 if (!inArcs.Remove(arc)) throw new InvalidOperationException("Arc is not present in this vertex' incoming arcs."); 133 126 } 134 127 OnArcRemoved(this, new EventArgs<IArc>(arc)); … … 162 155 [StorableClass] 163 156 public class Vertex<T> : Vertex, IVertex<T> where T : class,IItem { 164 public new T Content{165 get { return (T)base. Content; }166 set { base. Content= value; }157 public new T Data { 158 get { return (T)base.Data; } 159 set { base.Data = value; } 167 160 } 168 161
Note: See TracChangeset
for help on using the changeset viewer.