Ejemplo n.º 1
0
		public void AddDependent(GraphNode node)
		{
			if (outgoing == null)
			{
				outgoing = new List<GraphNode>();
			}
			outgoing.Add(node);
		}
Ejemplo n.º 2
0
		public void SimpleUsage()
		{
			GraphNode parent = new GraphNode();
			GraphNode child = new GraphNode();
			
			parent.AddDependent(child);

			Assert.AreSame( child, parent.Dependents[0] );
		}
Ejemplo n.º 3
0
		public void AddDependent(GraphNode node)
		{
			var collection = outgoing;
			if (collection == null)
			{
				var @new = new SimpleThreadSafeCollection<GraphNode>();
				collection = Interlocked.CompareExchange(ref outgoing, @new, null) ?? @new;
			}
			collection.Add(node);
		}
		public void Removal()
		{
			GraphNode parent = new GraphNode();
			GraphNode child = new GraphNode();
			
			parent.AddDependent(child);
			
			child.RemoveDepender(parent);

			Assert.IsTrue( parent.Dependents.Length == 0 );
			Assert.IsTrue( parent.Dependers.Length == 0 );
			Assert.IsTrue( child.Dependers.Length == 0 );
			Assert.IsTrue( child.Dependents.Length == 0 );
		}
Ejemplo n.º 5
0
		public void RemoveDepender(GraphNode depender)
		{
			Incoming.Remove(depender);
			depender.RemoveDependent(this);
		}
Ejemplo n.º 6
0
		public void AddDependent(GraphNode node)
		{
			Outgoing.Add(node);
			node.Incoming.Add(this);
		}
Ejemplo n.º 7
0
		private void RemoveDependent(GraphNode graphNode)
		{
			Outgoing.Remove(graphNode);
		}