コード例 #1
0
        //
        // Summary:
        //    Cuts everything except the selection
        //
        //    {1,2,3,4,5} => Array.Slice(1,3) => {2, 3, 4}
        //
        // Parameters:
        //   start:
        //     A 32-bit integer that represents the start of the selection in System.Array.
        //
        //   end:
        //     A 32-bit integer that represents the end of the selection in System.Array.
        //
        // Returns:
        //     System.Array with clipped unselected area
        public static T[] Slice <T>(this T[] array, int start, int end)
        {
            int size = ExtensionMath.Range(start, end);

            T[] result = new T[size];

            for (int i = start, j = 0; i <= end; i++, j++)
            {
                result[j] = array[i];
            }

            return(result);
        }
コード例 #2
0
        //
        // Summary:
        //    Cuts the selection out.
        //
        //    {1,2,3,4,5} => Array.Cut(1,3) => {1, 5}
        //
        // Parameters:
        //   start:
        //     A 32-bit integer that represents the start of the selection in System.Array.
        //
        //   end:
        //     A 32-bit integer that represents the end of the selection in System.Array.
        //
        // Returns:
        //     System.Array with clipped selection.
        public static T[] Cut <T>(this T[] array, int start, int end)
        {
            int size = array.Length - ExtensionMath.Range(start, end);

            T[] result = new T[size];

            for (int i = 0, j = 0; i < array.Length; i++)
            {
                if ((start > i) | (i > end))
                {
                    result[j] = array[i];
                    j++;
                }
            }

            return(result);
        }