/** * Method declaration * * * @param d */ public void add(object[] d) { Record r = new Record(); r.data = d; if (rRoot == null) { rRoot = r; } else { rTail.next = r; } rTail = r; iSize++; }
/** * Method declaration * * * @param a */ public void append(Result a) { if (rRoot == null) { rRoot = a.rRoot; } else { rTail.next = a.rRoot; } rTail = a.rTail; iSize += a.iSize; }
/** * Method declaration * * * @param r * @param order * @param way * * @return * * @throws Exception */ private static Result sortResult(Result r, int[] order, int[] way) { if (r.rRoot == null || r.rRoot.next == null) { return r; } Record source0, source1; Record[] target = new Record[2]; Record[] targetlast = new Record[2]; int dest = 0; Record n = r.rRoot; while (n != null) { Record next = n.next; n.next = target[dest]; target[dest] = n; n = next; dest ^= 1; } for (int blocksize = 1; target[1] != null; blocksize <<= 1) { source0 = target[0]; source1 = target[1]; target[0] = target[1] = targetlast[0] = targetlast[1] = null; for (dest = 0; source0 != null; dest ^= 1) { int n0 = blocksize, n1 = blocksize; while (true) { if (n0 == 0 || source0 == null) { if (n1 == 0 || source1 == null) { break; } n = source1; source1 = source1.next; n1--; } else if (n1 == 0 || source1 == null) { n = source0; source0 = source0.next; n0--; } else if (compareRecord(source0.data, source1.data, r, order, way) > 0) { n = source1; source1 = source1.next; n1--; } else { n = source0; source0 = source0.next; n0--; } if (target[dest] == null) { target[dest] = n; } else { targetlast[dest].next = n; } targetlast[dest] = n; n.next = null; } } } r.rRoot = target[0]; return r; }