java.lang.ObjectUtilIan
public class UtilIan
| Field Summary | |
|---|---|
(package private) static java.lang.String |
Digits
|
static java.lang.String |
DOUBLE_PATTERN
|
(package private) static java.lang.String |
Exp
|
| Method Summary | ||
|---|---|---|
static int |
ceil(double x)
The smallest int ≥ to x (same as Math.ceil, but returns int.) |
|
static java.lang.String |
charToString(java.lang.Character c)
Convert a char to a String. |
|
static int |
doubleToInt(java.lang.Double d)
Convert a Double to an int. |
|
static boolean |
equalsApprox(double d1,
double d2)
Return whether two doubles are equal (approximately). |
|
static boolean |
equalsApprox(double d1,
double d2,
double relativeTolerance)
|
|
static boolean |
equalsIgnoreWhitespace(java.lang.String str1,
java.lang.String str2)
Return whether two Strings are equal, ignoring differences in whitespace. |
|
static boolean |
equalsIgnoreWhitespace(java.lang.String str1,
java.lang.String str2,
java.lang.String splitBy)
Return whether two Strings are equal, ignoring differences in whitespace. |
|
static int |
floor(double x)
The largest int ≤ to x (same as Math.floor, but returns int.) |
|
static boolean |
hasNextChar(java.util.Scanner s)
Is there a next (non-white) character to read from a scanner? Same as hasNext(); provided for completeness. |
|
static boolean |
hasNextChar(java.util.Scanner s,
char c)
Is a certain character next, in a scanner's input (skipping whitespace)? This method may advance the scanner over any whitespace. |
|
static boolean |
hasNextDoubleSplittingBy(java.util.Scanner s,
java.lang.String delimiterChars)
|
|
static boolean |
hasNextSplittingBy(java.util.Scanner s,
java.lang.String word,
java.lang.String delimiterChars)
Does the scanner's next token start with a given word, optionally followed by: any of delimiterChars (and.even other chars). |
|
static double |
intToDouble(java.lang.Integer i)
Convert an Integer into to a double. |
|
static
|
max(java.util.Collection<T> ts)
Return the maximum item in a Collection |
|
static
|
max(T... ts)
A var-args version of max(Collection). |
|
static
|
min(java.util.Collection<T> ts)
Return the minimum item in a Collection |
|
static
|
min(T... ts)
A var-args version of min(Collection). |
|
static java.lang.Character |
nextChar(java.util.Scanner s)
Read the next char from a scanner's input (skipping whitespace). |
|
static java.lang.Character |
nextChar(java.util.Scanner s,
char c)
Read the given character from a scanner's input (skipping whitespace). |
|
static double |
nextDoubleSplittingBy(java.util.Scanner s,
java.lang.String delimiterChars)
|
|
static java.lang.String |
nextMatch(java.util.Scanner s,
java.util.regex.Pattern pat)
Return the next match (skipping initial whitespace) of a pattern. |
|
static java.lang.String |
nextMatch(java.util.Scanner s,
java.lang.String pat)
Return the next match (skipping initial whitespace) of a pattern. |
|
static java.lang.String |
nextSplittingBy(java.util.Scanner s,
java.lang.String delimiterChars)
Read a token, but stopping (and not consuming) if we encounter one of delimiterChars. |
|
static double |
roundTo(double x,
int places)
Round a number to a certain number of decimal places. |
|
static int |
roundToInt(double x)
Round a Double to the nearest int. |
|
static void |
skipWhitespace(java.util.Scanner s)
Skip over the whitespace in a Scanner. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
static final java.lang.String Digits
public static final java.lang.String DOUBLE_PATTERN
static final java.lang.String Exp
| Method Detail |
|---|
public static int ceil(double x)
d - The double to find the ceiling of.
public static java.lang.String charToString(java.lang.Character c)
c - The Character to convert to a String.
public static int doubleToInt(java.lang.Double d)
d - The Double to convert to an int.
public static boolean equalsApprox(double d1,
double d2)
d1 - A double to compare.d2 - A double to compare.
public static boolean equalsApprox(double d1,
double d2,
double relativeTolerance)
public static boolean equalsIgnoreWhitespace(java.lang.String str1,
java.lang.String str2)
str1 - The first String to compare.str1 - The second String to compare.
public static boolean equalsIgnoreWhitespace(java.lang.String str1,
java.lang.String str2,
java.lang.String splitBy)
str1 - The first String to compare.str1 - The second String to compare.splitBy - Characters to split by. If you split by ".?!",
.even "hi?" and "hi ?" will be equalsIgnoreWhitespace.
public static int floor(double x)
x - The double to find the floor of.
public static boolean hasNextChar(java.util.Scanner s)
s - The scanner to read from.
public static boolean hasNextChar(java.util.Scanner s,
char c)
s - The scanner to read from.c - The char to read.
public static boolean hasNextDoubleSplittingBy(java.util.Scanner s,
java.lang.String delimiterChars)
public static boolean hasNextSplittingBy(java.util.Scanner s,
java.lang.String word,
java.lang.String delimiterChars)
s - The scanner to read from.word - The initial word to look for, in the first token.delimiterChars - Characters to be treated as delimiters *within* a scanner token.
If there are any special characters, they must *already* be quoted.
public static double intToDouble(java.lang.Integer i)
i - The Integer to convert to a double.
public static <T extends java.lang.Comparable<T>> T max(java.util.Collection<T> ts)
ts - A collection of comparable objects.
public static <T extends java.lang.Comparable<T>> T max(T... ts)
UtilIan.max(Collection).public static <T extends java.lang.Comparable<T>> T min(java.util.Collection<T> ts)
ts - A collection of comparable objects.
public static <T extends java.lang.Comparable<T>> T min(T... ts)
UtilIan.min(Collection).public static java.lang.Character nextChar(java.util.Scanner s)
s - The scanner to read from.
public static java.lang.Character nextChar(java.util.Scanner s,
char c)
s - The scanner to read from.c - The char to read.
public static double nextDoubleSplittingBy(java.util.Scanner s,
java.lang.String delimiterChars)
public static java.lang.String nextMatch(java.util.Scanner s,
java.util.regex.Pattern pat)
s - The scanner to read from.pat - The pattern to look for.
public static java.lang.String nextMatch(java.util.Scanner s,
java.lang.String pat)
s - The scanner to read from.pat - The pattern to look for.
public static java.lang.String nextSplittingBy(java.util.Scanner s,
java.lang.String delimiterChars)
s - The scanner to read from.delimiterChars - Characters to be treated as delimiters *within* a single scanner token.
If there are any special characters, they must *already* be quoted.
public static double roundTo(double x,
int places)
x - The number to round.places - The number of decimal places to round to. Can be negative.
public static int roundToInt(double x)
x - The Double to round.
public static void skipWhitespace(java.util.Scanner s)
s - The scanner to skip over whitespace.