// Keeps only one sorting algorithm manager active private SortAlgorithmManager SortingAlgorithmManager(string sortAlgorithm) { switch (sortAlgorithm) { case Util.BUBBLE_SORT: return(GetComponentInChildren <BubbleSortManager>()); case Util.INSERTION_SORT: return(GetComponentInChildren <InsertionSortManager>()); case Util.BUCKET_SORT: int numberOfbuckets = sortSettings.NumberOfBuckets; BucketSortManager bucketSortManager = GetComponentInChildren <BucketSortManager>(); bucketSortManager.NumberOfBuckets = numberOfbuckets; BucketManager bucketManager = GetComponentInChildren <BucketManager>(); // Move to BucketSortManager bucketManager.InitBucketManager(numberOfbuckets); bucketManager.InitManager(); return(bucketSortManager); case Util.MERGE_SORT: return(GetComponentInChildren <MergeSortManager>()); default: Debug.LogError("Sorting algorithm '" + sortAlgorithm + "' not found."); break; } return(null); }