New C# port from Suraj Supekar
[zxing.git] / csharp / common / Collections.cs
diff --git a/csharp/common/Collections.cs b/csharp/common/Collections.cs
new file mode 100755 (executable)
index 0000000..d9b8c29
--- /dev/null
@@ -0,0 +1,60 @@
+/*\r
+* Copyright 2007 ZXing authors\r
+*\r
+* Licensed under the Apache License, Version 2.0 (the "License");\r
+* you may not use this file except in compliance with the License.\r
+* You may obtain a copy of the License at\r
+*\r
+*      http://www.apache.org/licenses/LICENSE-2.0\r
+*\r
+* Unless required by applicable law or agreed to in writing, software\r
+* distributed under the License is distributed on an "AS IS" BASIS,\r
+* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
+* See the License for the specific language governing permissions and\r
+* limitations under the License.\r
+*/\r
+using System;\r
+namespace com.google.zxing.common\r
+{\r
+       \r
+       /// <summary> <p>This is basically a substitute for <code>java.util.Collections</code>, which is not\r
+       /// present in MIDP 2.0 / CLDC 1.1.</p>\r
+       /// \r
+       /// </summary>\r
+       /// <author>  Sean Owen\r
+       /// </author>\r
+       /// <author>www.Redivivus.in (suraj.supekar@redivivus.in) - Ported from ZXING Java Source \r
+       /// </author>\r
+       public sealed class Collections\r
+       {\r
+               \r
+               private Collections()\r
+               {\r
+               }\r
+               \r
+               /// <summary> Sorts its argument (destructively) using insert sort; in the context of this package\r
+               /// insertion sort is simple and efficient given its relatively small inputs.\r
+               /// \r
+               /// </summary>\r
+               /// <param name="vector">vector to sort\r
+               /// </param>\r
+               /// <param name="comparator">comparator to define sort ordering\r
+               /// </param>\r
+               public static void  insertionSort(System.Collections.ArrayList vector, Comparator comparator)\r
+               {\r
+                       int max = vector.Count;\r
+                       for (int i = 1; i < max; i++)\r
+                       {\r
+                               System.Object value_Renamed = vector[i];\r
+                               int j = i - 1;\r
+                               System.Object valueB;\r
+                               while (j >= 0 && comparator.compare((valueB = vector[j]), value_Renamed) > 0)\r
+                               {\r
+                                       vector[j + 1] = valueB;\r
+                                       j--;\r
+                               }\r
+                               vector[j + 1] = value_Renamed;\r
+                       }\r
+               }\r
+       }\r
+}
\ No newline at end of file