public VecBool IsEqualTo(IVecValue other) { switch (other) { case VecArray <T> otherArray: return(new VecBool(Values.SequenceEqual(otherArray.Values))); default: throw new InvalidOperationException($"Can only equal with string type! Type: {other.Type}"); } }
public VecBool IsEqualTo(IVecValue other) { switch (other) { case VecString otherString: return(new VecBool(Value == otherString.Value)); default: throw new InvalidOperationException($"Can only equal with string type! Type: {other.Type}"); } }
public VecBool IsEqualTo(IVecValue other) { switch (other) { case VecBool otherBool: return(new VecBool(Value == otherBool.Value)); default: throw new InvalidOperationException($"Can only equal with bools! Type: {other.Type}"); } }
public VecBool IsEqualTo(IVecValue other) { switch (other) { case VecNull _: return(new VecBool(true)); default: throw new InvalidOperationException($"Can only equal with null type! Type: {other.Type}"); } }
public IVecValue Multiply(IVecValue other) { switch (other) { case VecInt otherInt: return(new VecFloat(Value * otherInt.Value)); case VecFloat otherFloat: return(new VecFloat(Value * otherFloat.Value)); default: throw new InvalidOperationException($"Can only multiply numeric type! Type: {other.Type}"); } }
public VecBool IsLesserThan(IVecValue other) { switch (other) { case VecInt otherInt: return(new VecBool(Value < otherInt.Value)); case VecFloat otherFloat: return(new VecBool(Value < otherFloat.Value)); default: throw new InvalidOperationException($"Can only compare with numeric type! Type: {other.Type}"); } }
public VecBool IsEqualTo(IVecValue other) { switch (other) { case VecInt otherInt: return(new VecBool(Value == otherInt.Value)); case VecFloat otherFloat: return(new VecBool(Value == otherFloat.Value)); default: throw new InvalidOperationException($"Can only equal with numeric type! Type: {other.Type}"); } }
public void Set(int idx, IVecValue value) { if (idx < 0 || idx >= Size) { throw new InvalidOperationException($"Index must be between 0 and {Values.Length - 1}!"); } if (value is T valueT) { Values[idx] = valueT; } else { throw new InvalidOperationException($"Wrong element type for this {ElementType} array! Was: {value.Type}"); } }
public static bool TryConvertToFloat(this IVecValue value, out VecFloat valueAsFloat) { if (value is VecFloat valF) { valueAsFloat = valF; return(true); } if (value is VecInt valI) { valueAsFloat = new VecFloat(valI.Value); return(true); } valueAsFloat = default(VecFloat); return(false); }
public IVecValue Modulo(IVecValue other) => throw new InvalidOperationException("Array does not support numeric operations!");
public VecBool IsLesserThan(IVecValue other) => throw new InvalidOperationException("Array does not support relational operations!");
public static VecBool IsLesserOrEqualTo(this IVecValue lhs, IVecValue rhs) => lhs.IsEqualTo(rhs).Or(lhs.IsLesserThan(rhs));
public static VecBool IsGreaterThan(this IVecValue lhs, IVecValue rhs) => lhs.IsLesserThan(rhs).Not();
public IVecValue Divide(IVecValue other) => throw new InvalidOperationException("String does not support numeric operations!");
public IVecValue Multiply(IVecValue other) => throw new InvalidOperationException("Bool does not support numeric operations!");
public IVecValue Subtract(IVecValue other) => throw new InvalidOperationException("Null does not support numeric operations!");