formatting

This commit is contained in:
klemek
2020-12-19 17:21:06 +01:00
parent 63e8f2c5f6
commit 205a663e07
56 changed files with 1690 additions and 1297 deletions
+57 -57
View File
@@ -3,77 +3,77 @@ using System.Linq;
namespace UntitledLogicGame.Workspace.Gates
{
public class InputState : State
{
public InputState(IEnumerable<bool> args) : base(args) { }
public class InputState : State
{
public InputState(IEnumerable<bool> args) : base(args) { }
public InputState(params bool[] args) : base(args) { }
public InputState(params bool[] args) : base(args) { }
public InputState(int len) : base(len) { }
}
public InputState(int len) : base(len) { }
}
public class OutputState : State
{
public OutputState(IEnumerable<bool> args) : base(args) { }
{
public OutputState(IEnumerable<bool> args) : base(args) { }
public OutputState(params bool[] args) : base(args) { }
public OutputState(params bool[] args) : base(args) { }
public OutputState(int len) : base(len) { }
}
public OutputState(int len) : base(len) { }
}
public abstract class State
{
internal int Length => values.Length;
{
internal int Length => values.Length;
internal bool[] values;
internal bool[] values;
public State(IEnumerable<bool> args)
{
values = args.ToArray();
}
public State(IEnumerable<bool> args)
{
values = args.ToArray();
}
public State(params bool[] args)
{
values = args;
}
public State(params bool[] args)
{
values = args;
}
public State(int len)
{
values = new bool[len];
}
public State(int len)
{
values = new bool[len];
}
public bool this[int index]
{
get
{
if (index < 0 || index >= values.Length)
return false;
return values[index];
}
set
{
if (index >= 0 && index < values.Length)
values[index] = value;
}
}
public bool this[int index]
{
get
{
if (index < 0 || index >= values.Length)
return false;
return values[index];
}
set
{
if (index >= 0 && index < values.Length)
values[index] = value;
}
}
public override bool Equals(object obj)
{
return obj is State state && Enumerable.SequenceEqual(values, state.values);
}
public override bool Equals(object obj)
{
return obj is State state && Enumerable.SequenceEqual(values, state.values);
}
public override int GetHashCode()
{
//https://stackoverflow.com/questions/6832139/gethashcode-from-booleans-only
int hash = 17;
for (int index = 0; index < values.Length; index++)
hash = hash * 23 + values[index].GetHashCode();
return hash;
}
public override int GetHashCode()
{
//https://stackoverflow.com/questions/6832139/gethashcode-from-booleans-only
int hash = 17;
for (int index = 0; index < values.Length; index++)
hash = hash * 23 + values[index].GetHashCode();
return hash;
}
public override string ToString()
{
return string.Join(",", values);
}
}
public override string ToString()
{
return string.Join(",", values);
}
}
}