first time in my life i found a use case for HashSet

This commit is contained in:
2026-01-11 02:40:53 +05:00
parent e09e81073b
commit 6d7b57c9f9

View File

@@ -2,6 +2,7 @@
{ {
class EquationManager class EquationManager
{ {
private static readonly HashSet<string> _operators = new() { "+", "-", "*", "/", "^", "√" };
private ReverseNotationSolver reverseNotationSolver = new(); private ReverseNotationSolver reverseNotationSolver = new();
List<Token> equation = new(); List<Token> equation = new();
@@ -173,11 +174,11 @@
outerOperandLabel.Text = currentOperand == "" ? "0" : currentOperand; outerOperandLabel.Text = currentOperand == "" ? "0" : currentOperand;
} }
} }
private bool IsOperator() private bool IsOperator()
{ {
if (equation.Count == 0) return false; if (equation.Count == 0) return false;
return new[] { "+", "-", "*", "/", "^", "√" }.Contains(equation.Last().value); return _operators.Contains(equation.Last().value);
} }
private bool IsOpen() private bool IsOpen()