2 * Copyright 2007 ZXing authors
\r
4 * Licensed under the Apache License, Version 2.0 (the "License");
\r
5 * you may not use this file except in compliance with the License.
\r
6 * You may obtain a copy of the License at
\r
8 * http://www.apache.org/licenses/LICENSE-2.0
\r
10 * Unless required by applicable law or agreed to in writing, software
\r
11 * distributed under the License is distributed on an "AS IS" BASIS,
\r
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
\r
13 * See the License for the specific language governing permissions and
\r
14 * limitations under the License.
\r
17 namespace com.google.zxing.common
\r
20 /// <summary> <p>This is basically a substitute for <code>java.util.Collections</code>, which is not
\r
21 /// present in MIDP 2.0 / CLDC 1.1.</p>
\r
24 /// <author> Sean Owen
\r
26 /// <author>www.Redivivus.in (suraj.supekar@redivivus.in) - Ported from ZXING Java Source
\r
28 public sealed class Collections
\r
31 private Collections()
\r
35 /// <summary> Sorts its argument (destructively) using insert sort; in the context of this package
\r
36 /// insertion sort is simple and efficient given its relatively small inputs.
\r
39 /// <param name="vector">vector to sort
\r
41 /// <param name="comparator">comparator to define sort ordering
\r
43 public static void insertionSort(System.Collections.ArrayList vector, Comparator comparator)
\r
45 int max = vector.Count;
\r
46 for (int i = 1; i < max; i++)
\r
48 System.Object value_Renamed = vector[i];
\r
50 System.Object valueB;
\r
51 while (j >= 0 && comparator.compare((valueB = vector[j]), value_Renamed) > 0)
\r
53 vector[j + 1] = valueB;
\r
56 vector[j + 1] = value_Renamed;
\r