From 8938c3447d88e31f77f20553ed185fc8e64c9ac8 Mon Sep 17 00:00:00 2001 From: chai Date: Tue, 22 Jun 2021 14:58:53 +0800 Subject: +misc --- Assets/Algorithms/Algorithms.cs | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'Assets/Algorithms/Algorithms.cs') diff --git a/Assets/Algorithms/Algorithms.cs b/Assets/Algorithms/Algorithms.cs index f376ac6..a6005d3 100644 --- a/Assets/Algorithms/Algorithms.cs +++ b/Assets/Algorithms/Algorithms.cs @@ -15,6 +15,13 @@ namespace AlgorithmCollection v2 = temp; } + public static void Swap(ref IList data, int i1, int i2) + { + T temp = data[i1]; + data[i1] = data[i2]; + data[i2] = temp; + } + public static void Swap(ref List data, int i1, int i2) { T temp = data[i1]; @@ -42,6 +49,13 @@ namespace AlgorithmCollection return v1.CompareTo(v2) < 0 ? v1 : v2; } + public static string ListToString(List data) + { + string content = ""; + data.ForEach((T v) => { content += v.ToString(); }); + return content; + } + } } \ No newline at end of file -- cgit v1.1-26-g67d0