public override void Add(ILinkDemandAndProvider item) { if (item == null) { return; } if (item.Quantity == null || item.Quantity <= 0) { throw new MrpRunException($"Quantity is not correct: {item.Quantity}"); } // a set contains the element only once, else skip adding if (StackSet.Contains(item) == false) { if (_indexDemandId.ContainsKey(item.GetDemandId()) == false) { _indexDemandId.Add(item.GetDemandId(), new Ids()); } _indexDemandId[item.GetDemandId()].Add(item.GetId()); if (_indexProviderId.ContainsKey(item.GetProviderId()) == false) { _indexProviderId.Add(item.GetProviderId(), new Ids()); } _indexProviderId[item.GetProviderId()].Add(item.GetId()); base.Add(item); } }
private void PrintArea(StackSet <Node> stack, HashSet <string> clay, Dictionary <string, Node> seen, Node current, bool flowing) { return; if (current == null) { return; } var sb = new StringBuilder(); var yRange = 30; var xRange = 60; for (var y = current.Location.Y - yRange; y < current.Location.Y + yRange; y++) { for (var x = current.Location.X - xRange; x < current.Location.X + xRange; x++) { if (stack.Contains($"{x},{y}")) { sb.Append('q'); } else if (current.Location.X == x && current.Location.Y == y) { sb.Append('@'); } else if (clay.Contains($"{x},{y}")) { sb.Append('#'); } else if (seen.ContainsKey($"{x},{y}")) { if (seen[$"{x},{y}"].Flowing) { sb.Append('~'); } else { sb.Append('|'); } } else { sb.Append('.'); } } sb.Append($"{y}".PadLeft(5)); sb.AppendLine(); } sb.AppendLine($"Flowing: {flowing}"); Console.SetCursorPosition(0, 0); Console.WriteLine(sb.ToString()); }
public void TestContains() { IStackSet <IScheduleNode> stackSet = new StackSet <IScheduleNode>(); int countNodes = 10; for (int i = 0; i < countNodes; i++) { IScheduleNode testNumber = new DummyNode(i); stackSet.Push(testNumber); } for (int i = countNodes - 1; i > 0; i--) { IScheduleNode scheduleNode = new DummyNode(i); Assert.True( stackSet.Contains(scheduleNode) && stackSet.Count() == i + 1, "Contains() didn't work."); stackSet.Remove(scheduleNode); } }