-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOperator.cs
More file actions
78 lines (68 loc) · 1.79 KB
/
Operator.cs
File metadata and controls
78 lines (68 loc) · 1.79 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/**
* SAT solver using Bruteforce
*
* @author : Princy Rasolonjatovo
* @email : princy.m.rasolonjatovo@gmail.com
* @github : princy-rasolonjatovo
**/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace SATBruteforce
{
public class Operator : IEquatable<Operator>, IExpressionType, ICloneable<Operator>
{
public string Name { get; init; }
public string Symbol { get; init; }
private Func<bool, bool, bool> Fn;
public int Priority { get; init; }
public bool IsUnary { get; init; }
public Operator(
string name,
string symbol,
Func<bool, bool, bool> fn,
int priority,
bool isUnary=false)
{
this.Name = name;
this.Symbol = symbol;
this.Priority = priority;
this.IsUnary = isUnary;
this.Fn = fn;
}
public bool Apply(bool left, bool right)
{
return this.Fn(left, right);
}
public override string ToString()
{
return $"[Operator] symbol: '{this.Symbol}'";
}
public bool Equals(Operator? other)
{
if (other == null) return false;
return this.Name == other.Name;
}
public ExpressionType RevealType()
{
return ExpressionType.OPERATOR;
}
public string GetSymbol()
{
return this.Symbol;
}
public Operator Clone()
{
return new Operator
(
this.Name,
this.Symbol,
this.Fn,
this.Priority,
this.IsUnary
);
}
}
}