예제 #1
0
        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}");
            }
        }
예제 #2
0
        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}");
            }
        }
예제 #3
0
        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}");
            }
        }
예제 #4
0
        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}");
            }
        }
예제 #5
0
        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}");
            }
        }
예제 #6
0
        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}");
            }
        }
예제 #7
0
        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}");
            }
        }
예제 #8
0
        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}");
            }
        }
예제 #9
0
        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);
        }
예제 #10
0
 public IVecValue Modulo(IVecValue other)
 => throw new InvalidOperationException("Array does not support numeric operations!");
예제 #11
0
 public VecBool IsLesserThan(IVecValue other)
 => throw new InvalidOperationException("Array does not support relational operations!");
예제 #12
0
 public static VecBool IsLesserOrEqualTo(this IVecValue lhs, IVecValue rhs)
 => lhs.IsEqualTo(rhs).Or(lhs.IsLesserThan(rhs));
예제 #13
0
 public static VecBool IsGreaterThan(this IVecValue lhs, IVecValue rhs)
 => lhs.IsLesserThan(rhs).Not();
예제 #14
0
 public IVecValue Divide(IVecValue other)
 => throw new InvalidOperationException("String does not support numeric operations!");
예제 #15
0
 public IVecValue Multiply(IVecValue other)
 => throw new InvalidOperationException("Bool does not support numeric operations!");
예제 #16
0
 public IVecValue Subtract(IVecValue other)
 => throw new InvalidOperationException("Null does not support numeric operations!");