Package org.openstreetmap.josm.tools
Class AlphanumComparator
- java.lang.Object
-
- org.openstreetmap.josm.tools.AlphanumComparator
-
- All Implemented Interfaces:
Serializable
,Comparator<String>
public final class AlphanumComparator extends Object implements Comparator<String>, Serializable
The Alphanum Algorithm is an improved sorting algorithm for strings containing numbers: Instead of sorting numbers in ASCII order like a standard sort, this algorithm sorts numbers in numeric order. The Alphanum Algorithm is discussed at http://www.DaveKoelle.com This is an updated version with enhancements made by Daniel Migowski, Andre Bogus, David Koelle and others.- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description private static AlphanumComparator
INSTANCE
private static long
serialVersionUID
-
Constructor Summary
Constructors Modifier Constructor Description private
AlphanumComparator()
Constructs a new Alphanum Comparator.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compare(String s1, String s2)
private static String
getChunk(String s, int slength, int marker)
Returns an alphanum chunk.static AlphanumComparator
getInstance()
Replies the unique instance.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface java.util.Comparator
equals, reversed, thenComparing, thenComparing, thenComparing, thenComparingDouble, thenComparingInt, thenComparingLong
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
INSTANCE
private static final AlphanumComparator INSTANCE
-
-
Constructor Detail
-
AlphanumComparator
private AlphanumComparator()
Constructs a new Alphanum Comparator.
-
-
Method Detail
-
getInstance
public static AlphanumComparator getInstance()
Replies the unique instance.- Returns:
- the unique instance
-
getChunk
private static String getChunk(String s, int slength, int marker)
Returns an alphanum chunk. Length of string is passed in for improved efficiency (only need to calculate it once).- Parameters:
s
- stringslength
- string lengthmarker
- position- Returns:
- alphanum chunk found at given position
-
-