MCPcopy Create free account
hub / github.com/OpenSourcePhysics/osp / mergesort

Method mergesort

src/org/opensourcephysics/numerics/ArrayLib.java:603–615  ·  view source on GitHub ↗
(int[] a, double[] b, int p, int r)

Source from the content-addressed store, hash-verified

601 // -- Mergesort --
602
603 protected static final void mergesort(int[] a, double[] b, int p, int r) {
604 if (p >= r) {
605 return;
606 }
607 if (r - p + 1 < SORT_THRESHOLD) {
608 insertionsort(a, b, p, r);
609 } else {
610 int q = (p + r) / 2;
611 mergesort(a, b, p, q);
612 mergesort(a, b, q + 1, r);
613 merge(a, b, p, q, r);
614 }
615 }
616
617 protected static final void merge(int[] a, double[] b, int p, int q, int r) {
618 int[] t = new int[r - p + 1];

Callers 1

sortMethod · 0.95

Calls 2

insertionsortMethod · 0.95
mergeMethod · 0.95

Tested by

no test coverage detected