diff options
author | Shawn O. Pearce <spearce@spearce.org> | 2010-09-01 23:07:08 -0700 |
---|---|---|
committer | Shawn O. Pearce <spearce@spearce.org> | 2010-09-02 00:28:15 -0700 |
commit | 6b6521150502af254e3d23bb02000eb350fd7083 (patch) | |
tree | e709b748534183802b24c616a621e7052d565065 /org.eclipse.jgit | |
parent | 3fa7d3a2d22c3f6e1b800955e7e2bc5ad3df80c4 (diff) | |
download | jgit-6b6521150502af254e3d23bb02000eb350fd7083.tar.gz jgit-6b6521150502af254e3d23bb02000eb350fd7083.zip |
Adding sorting to LongList
Sorting the array can be useful when its being used as a map of pairs
that are appended into the array and then later merge-joined against
another array of similar semantics.
Change-Id: I2e346ef5c99ed1347ec0345b44cda0bc29d03e90
Signed-off-by: Shawn O. Pearce <spearce@spearce.org>
Diffstat (limited to 'org.eclipse.jgit')
-rw-r--r-- | org.eclipse.jgit/src/org/eclipse/jgit/util/LongList.java | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/org.eclipse.jgit/src/org/eclipse/jgit/util/LongList.java b/org.eclipse.jgit/src/org/eclipse/jgit/util/LongList.java index 96b311dfbf..e3aeb83a7e 100644 --- a/org.eclipse.jgit/src/org/eclipse/jgit/util/LongList.java +++ b/org.eclipse.jgit/src/org/eclipse/jgit/util/LongList.java @@ -44,6 +44,8 @@ package org.eclipse.jgit.util; +import java.util.Arrays; + /** A more efficient List<Long> using a primitive long array. */ public class LongList { private long[] entries; @@ -146,6 +148,11 @@ public class LongList { add(val); } + /** Sort the list of longs according to their natural ordering. */ + public void sort() { + Arrays.sort(entries, 0, count); + } + private void grow() { final long[] n = new long[(entries.length + 16) * 3 / 2]; System.arraycopy(entries, 0, n, 0, count); |