using System.Collections; using System.Collections.Generic; using UnityEngine; namespace AlgorithmCollection { public static partial class Algorithms { public static void Swap(ref T v1, ref T v2) { T temp = v1; v1 = v2; v2 = temp; } public static void Swap(ref List data, int i1, int i2) { T temp = data[i1]; data[i1] = data[i2]; data[i2] = temp; } // 阶乘 public static int Factorial(int n) { if (n == 1) return 1; return n * Factorial(n - 1); } } }