Programming > CODING SOLUTION > SIT 221 Classes, Libraries and Algorithms__Import and explore the attached ISorter.cs file. It conta (All)
Import and explore the attached ISorter.cs file. It contains the ISorter interface, which consists of only a single generic method with the following signature and purpose: void Sort<K>( K[ ] ... array, int index, int num, IComparer<K> comparer ) Sorts the data elements stored in the specified one-dimensional array in the range defined by the starting position index and the number of subsequent elements num. The order of sorted elements is determined by the specified comparer, or, if the comparer is null, by the default comparer for type K obtained through the Comparer<K>.Default property. This method must throw the following exceptions: ArgumentNullException if the array is null, . ArgumentOutOfRangeException if the given index or num or both are negative, . ArgumentException if the values of index and num do not specify a valid range within the given array. In order to make the type K compatible with the Sort method, there is a constraint applied to this generic type that expects the implementation of the IComparable<K> interface. That is, any concrete type to replace the placeholder K during the runtime must implement the IComparable<K> and its mandatory CompareTo(K another) method. This requirement ensures that the call to the Comparer<K>.Default property is possible in case when the specified comparer equals null. Extend your Vector<T> class by adding the following method: - void Sort( ISorter algorithm, IComparer<T> comparer ) Sorts the elements in the entire Vector<T> collection using the specified sorting algorithm and comparer. If the algorithm is null, the sorting operation should be delegated to the Array.Sort as the default sorting method. If the comparer isnull, the order of sorted elements is determined by the default comparer for type T; that is, by Comparer<T>.Default. [Show More]
Last updated: 1 year ago
Preview 1 out of 5 pages
Connected school, study & course
About the document
Uploaded On
Apr 26, 2023
Number of pages
5
Written in
This document has been written for:
Uploaded
Apr 26, 2023
Downloads
0
Views
50
In Browsegrades, a student can earn by offering help to other student. Students can help other students with materials by upploading their notes and earn money.
We're available through e-mail, Twitter, Facebook, and live chat.
FAQ
Questions? Leave a message!
Copyright © Browsegrades · High quality services·