コード例 #1
0
    IEnumerator Sort()
    {
        SortClass <int>     sortclass  = new SortClass <int>();
        IntComparer         com        = new IntComparer();
        int                 n          = 0;
        SortParameter <int> sort_param = null;

        switch (sort_type)
        {
        case SortType.Buble:
        {
            sort_param = new BubleSortParameter <int>(
                com,
                () => { },
                (state, sorting_items, item_states) =>
                {
                    ++n;
                    if (dstint_text)
                    {
                        DistSortArray(state, sorting_items, item_states);
                    }
                }
                );
        }
        break;

        case SortType.Quick:
        case SortType.RandomQuick:
        {
            sort_param = new QuickSortParameter <int>(
                com,
                () => { },
                (state, sorting_items, item_states) =>
                {
                    ++n;
                    if (dstint_text)
                    {
                        DistSortArray(state, sorting_items, item_states);
                    }
                }
                );
        }
        break;

        case SortType.Bitonic_NotUseGPGPUDemo:
        {
            sort_param = new BytonicSortParameter <int>(
                com,
                () => { },
                (state, sorting_items, item_states) =>
                {
                    ++n;
                    if (dstint_text)
                    {
                        DistSortArray(state, sorting_items, item_states);
                    }
                }
                );
        }
        break;
        }
        yield return(sortclass.SortUseIEnumerator(
                         items,
                         sort_param,
                         new WaitForSeconds(wait),
                         sort_type
                         ));

        Debug.Log("操作回数:" + n + "回");
    }