void Awake() { if (Instance == null) { Instance = this; } }
void Awake() { if (Instance == null) { Instance = this; } cursorObj = this.gameObject; }
public static void Sort <T>(this T[] source, Comparison <T> comparer) // IComparer -> Comparer { ICursor cursor = new SimpleCursor(0, source.Length - 1); if (source is null) { throw new ArgumentNullException($"{nameof(source)} cannot be null."); } if (comparer is null) { throw new ArgumentNullException($"{nameof(comparer)} cannot be null."); } bool isSorted = false; int i = 0; while (!isSorted) { isSorted = true; cursor.Reset(); int previous = cursor.Start, next = cursor.Next; while (next <= cursor.End - i) { //if (comparer.Invoke(source[previous], source[next]) > 0) if (comparer(source[previous], source[next]) > 0) { Swap(ref source[previous], ref source[next]); isSorted = false; } previous = next; next = cursor.Next; } i++; } }