public MathContainer SetSubtraction(SubtractionConfig config) { if (config == null) { config = new SubtractionConfig(); config.SetDefault(); } config.Repaire(); for (var i = 0; i < config.Times; i++) { Subtractions.Add(GenerateSubtraction(config)); } return(this); }
public PN_Counter Subtract(int value, Guid nodeId) { var element = Subtractions.FirstOrDefault(e => e.Node.Id == nodeId); if (element is null) { element = new CounterElement(value, nodeId); } else { element.Add(Math.Abs(value)); } var subtractions = Subtractions.Where(e => e.Node.Id != nodeId).ToImmutableHashSet(); subtractions = subtractions.Add(element); return(new PN_Counter(Additions, subtractions)); }