Class StringSort
- Namespace
- AlgorithmsSW.String
- Assembly
- AlgorithmsSW.dll
A class that provides string sorting algorithms.
public static class StringSort
- Inheritance
-
StringSort
- Inherited Members
Methods
Accumulate<T>(IReadonlyRandomAccessList<T>)
Accumulates the counts of the sorted items.
public static IRandomAccessList<T> Accumulate<T>(IReadonlyRandomAccessList<T> sortedCounts) where T : INumber<T>
Parameters
sortedCountsIReadonlyRandomAccessList<T>The counts of the sorted items.
Returns
- IRandomAccessList<T>
An array of the accumulated counts of the sorted items.
Type Parameters
TThe type of the items being sorted.
Accumulate<T>(T[])
public static T[] Accumulate<T>(T[] sortedCounts) where T : INumber<T>
Parameters
sortedCountsT[]
Returns
- T[]
Type Parameters
T
CountOccurrences<T>(IEnumerable<T>, IComparer<T>)
Counts the occurrences of each unique string in a given collection.
public static Counter<T> CountOccurrences<T>(this IEnumerable<T> list, IComparer<T> comparer)
Parameters
listIEnumerable<T>The collection of strings to count.
comparerIComparer<T>The comparer to use for comparing the strings.
Returns
- Counter<T>
A Counter<T> object where each unique item is associated with its count.
Type Parameters
TThe type of the items in the collection.
CountSortWithQueues<T>(IRandomAccessList<T>, IComparer<T>)
[ExerciseReference(5, 1, 7)]
public static void CountSortWithQueues<T>(IRandomAccessList<T> list, IComparer<T> comparer)
Parameters
listIRandomAccessList<T>comparerIComparer<T>
Type Parameters
T
CountSort<T>(IRandomAccessList<T>, IComparer<T>)
[ExerciseReference(5, 1, 1)]
public static void CountSort<T>(IRandomAccessList<T> list, IComparer<T> comparer)
Parameters
listIRandomAccessList<T>comparerIComparer<T>
Type Parameters
T
LeastSignificantDigitSort(IRandomAccessList<string>, int, Alphabet)
Sorts an array of strings using the Least Significant Digit (LSD) radix sort algorithm, considering only a specified number of leading characters in each string.
[AlgorithmReference(5, 1)]
[ExerciseReference(5, 1, 12)]
public static void LeastSignificantDigitSort(IRandomAccessList<string> list, int leadingCharsToSort, Alphabet alphabet)
Parameters
listIRandomAccessList<string>The array of strings to be sorted. This algorithm assumes all the strings are of length at least
leadingCharsToSort.leadingCharsToSortintThe number of leading characters to consider during sorting.
alphabetAlphabetThe alphabet used in the strings.
Remarks
This algorithm assumes that the integer values are smaller than the radix. This can be used indirectly to sort strings of any Alphabet provided they are converted to and from integer arrays.
LeastSignificantDigitSort(IRandomAccessList<string>, int, int)
Sorts an array of strings using the Least Significant Digit (LSD) radix sort algorithm, considering only a specified number of leading characters in each string.
[AlgorithmReference(5, 1)]
public static void LeastSignificantDigitSort(IRandomAccessList<string> list, int leadingCharsToSort, int radix)
Parameters
listIRandomAccessList<string>The array of strings to be sorted. This algorithm assumes all the strings are of length at least
leadingCharsToSort.leadingCharsToSortintThe number of leading characters to consider during sorting.
radixintThe radix of the alphabet used to present the strings.
Remarks
This algorithm assumes that the character integer value is smaller than the radix. So for example, this implementation cannot be used to sort binary strings made from 0s and 1s.
LeastSignificantDigitSort(int[][], int, int)
Sorts an array of strings using the Least Significant Digit (LSD) radix sort algorithm, considering only a specified number of leading characters in each string.
[AlgorithmReference(5, 1)]
public static void LeastSignificantDigitSort(int[][] list, int leadingCharsToSort, int radix)
Parameters
listint[][]The array of strings to be sorted. This algorithm assumes all the strings are of length at least
leadingCharsToSort.leadingCharsToSortintThe number of leading characters to consider during sorting.
radixintThe radix of the alphabet used to present the strings.
Remarks
This algorithm assumes that the integer values are smaller than the radix. This can be used indirectly to sort strings of any Alphabet provided they are converted to and from integer arrays.
MostSignificantDigitSort(IRandomAccessList<string>)
Sorts an array of strings using the Most Significant Digit (MSD) radix sort algorithm.
[AlgorithmReference(5, 2)]
public static void MostSignificantDigitSort(IRandomAccessList<string> list)
Parameters
listIRandomAccessList<string>The array of strings to be sorted.
Quicksort3Way(IRandomAccessList<int[]>)
[ExerciseReference(5, 1, 14)]
public static void Quicksort3Way(IRandomAccessList<int[]> list)
Parameters
listIRandomAccessList<int[]>
Quicksort3Way(IRandomAccessList<string>)
Sorts an array of strings using three-way quicksort.
public static void Quicksort3Way(IRandomAccessList<string> list)
Parameters
listIRandomAccessList<string>The list of strings to be sorted.
Radix2Insertion(IRandomAccessList<int>, int)
[ExerciseReference(5, 1, 15)]
public static void Radix2Insertion(IRandomAccessList<int> list, int leadingCharsToSort = 16)
Parameters
listIRandomAccessList<int>leadingCharsToSortint
Radix4Insertion(IRandomAccessList<int>, int)
[ExerciseReference(5, 1, 15)]
public static void Radix4Insertion(IRandomAccessList<int> list, int leadingCharsToSort = 16)
Parameters
listIRandomAccessList<int>leadingCharsToSortint
RadixSort(IRandomAccessList<int>, int)
public static void RadixSort(IRandomAccessList<int> list, int maxElement)
Parameters
listIRandomAccessList<int>maxElementint
RadixSort2(IRandomAccessList<int>, int)
public static void RadixSort2(IRandomAccessList<int> list, int maxElement)
Parameters
listIRandomAccessList<int>maxElementint