public E Copy <E>(EdgeNodeStateContext nodeStateContext, EdgeNodeStateContextFactory <E> factory) where E : EdgeNodeStateContext, new() { var nodeFactory = EdgeNodeFactory.GetFactory(); var context = factory.ConstructNodeContext(nodePosition: nodeStateContext.Node.Position, nodeState: nodeStateContext.State, nodeFactory: nodeFactory); return(context); }
public EdgeNodeStateContextContainer <E> Copy( EdgeNodeStateContextFactory <E> factory) { var container = new EdgeNodeStateContextContainer <E>(); foreach (var nodeStateContext in this.Values) { container.Values.Add(nodeStateContext.Key, nodeStateContext.Value.Copy <E>(nodeStateContext.Value, factory)); } return(container); }
public NodeStateContextContainerFacadeFactory(EdgeNodeStateContextFactory <E> edgeNodeStateContextFactory, VertexNodeStateContextFactory <V> vertexNodeStateContextFactory) { if (edgeNodeStateContextFactory == null) { throw new NullReferenceException("edgeNodeStateContextFactory cannot be null"); } EdgeNodeStateContextFactory = edgeNodeStateContextFactory; if (vertexNodeStateContextFactory == null) { throw new NullReferenceException("vertexNodeStateContextFactory cannot be null"); } VertexNodeStateContextFactory = vertexNodeStateContextFactory; }
protected internal virtual void AddEdge(int edgePosition, EdgeNodeStateContextFactory <E> factory) { this.EdgeNodeStateContextContainer.Add(edgePosition, factory.ConstructDefaultNodeContext(edgePosition)); }
protected internal virtual void AddEdge(int edgePosition, EdgeNodeStateContextFactory <E> factory) { this.NodeStateContextContainerFacade.AddEdge(edgePosition, factory); this.IncidenceProvider.AddEdge(edgePosition); }
protected internal virtual void AddVertices(int sourceVertexPosition, int[] targetVertexPositions, EdgeNodeStateContextFactory <E> edgeFactory, VertexNodeStateContextFactory <V> vertexFactory) { lock (this.IncidenceProvider.Values) { var edgePositionList = this.IncidenceProvider.SetVertices(sourceVertexPosition, targetVertexPositions); lock (this.NodeStateContextContainerFacade) { edgePositionList.ForEach(t => this.NodeStateContextContainerFacade.AddEdge(t, edgeFactory)); } } lock (this.AdjacencyProvider.Values) { this.AdjacencyProvider.SetVertices(sourceVertexPosition, targetVertexPositions); lock (this.NodeStateContextContainerFacade) { NodeStateContextContainerFacade.AddVertex(sourceVertexPosition, vertexFactory); targetVertexPositions.ToList().ForEach(t => NodeStateContextContainerFacade.AddVertex(t, vertexFactory)); } } }
protected internal virtual void AddVertices(int sourceVertexPosition, int targetVertex, EdgeNodeStateContextFactory <E> edgeFactory, VertexNodeStateContextFactory <V> vertexFactory) { lock (this.IncidenceProvider.Values) { var edgePosition = this.IncidenceProvider.SetVertices(sourceVertexPosition, targetVertex); lock (this.NodeStateContextContainerFacade) { this.NodeStateContextContainerFacade.AddEdge(edgePosition, edgeFactory); } } lock (this.AdjacencyProvider.Values) { this.AdjacencyProvider.SetVertices(sourceVertexPosition, targetVertex); lock (this.NodeStateContextContainerFacade) { NodeStateContextContainerFacade.AddVertex(sourceVertexPosition, vertexFactory); NodeStateContextContainerFacade.AddVertex(targetVertex, vertexFactory); } } }