Package net.oijon.stringsorts
Class Comparer
- java.lang.Object
-
- net.oijon.stringsorts.Comparer
-
public class Comparer extends java.lang.Object
Compares two different strings. Used in the various sorting algorithms.
-
-
Constructor Summary
Constructors Constructor Description Comparer(Comparison comparison)
Creates the comparer, and sets a comparison mode
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
compare(java.lang.String a, java.lang.String b)
Compares the two strings using the set comparison mode.void
setComparisonMode(Comparison comparison)
Sets the comparison mode
-
-
-
Constructor Detail
-
Comparer
public Comparer(Comparison comparison)
Creates the comparer, and sets a comparison mode- Parameters:
comparison
- The mode of comparison the comparer should use
-
-
Method Detail
-
setComparisonMode
public void setComparisonMode(Comparison comparison)
Sets the comparison mode- Parameters:
comparison
- The mode of comparison the comparer should use
-
compare
public int compare(java.lang.String a, java.lang.String b)
Compares the two strings using the set comparison mode.- Parameters:
a
- The first string to compareb
- The second string to compare- Returns:
- 0 if a == b; 1 if a > b, -1 if a < b
-
-