internal static NativeArray <T> SubtractArrays <T>(NativeArray <T> minuend, NativeArray <T> subtrahend) where T : struct, IEquatable <T>
        {
            if (minuend.Length == 0 || minuend.ArraysEqual(subtrahend))
            {
                return(new NativeArray <T>(0, Allocator.Persistent));
            }

            if (subtrahend.Length == 0)
            {
                return(new NativeArray <T>(minuend, Allocator.Persistent));
            }

            var result = new NativeList <T>(Allocator.Temp);

            result.AddRange(minuend);

            foreach (var sub in subtrahend)
            {
                var i = result.IndexOf(sub);
                if (i != -1)
                {
                    result.RemoveAtSwapBack(i);
                }
            }
            var asArray = new NativeArray <T>(result.AsArray(), Allocator.Persistent);

            result.Dispose();
            return(asArray);
        }