本文整理汇总了Java中org.apache.commons.math3.exception.util.LocalizedFormats.INSTANCES_NOT_COMPARABLE_TO_EXISTING_VALUES属性的典型用法代码示例。如果您正苦于以下问题:Java LocalizedFormats.INSTANCES_NOT_COMPARABLE_TO_EXISTING_VALUES属性的具体用法?Java LocalizedFormats.INSTANCES_NOT_COMPARABLE_TO_EXISTING_VALUES怎么用?Java LocalizedFormats.INSTANCES_NOT_COMPARABLE_TO_EXISTING_VALUES使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类org.apache.commons.math3.exception.util.LocalizedFormats
的用法示例。
在下文中一共展示了LocalizedFormats.INSTANCES_NOT_COMPARABLE_TO_EXISTING_VALUES属性的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: incrementValue
/**
* Increments the frequency count for v.
* <p>
* If other objects have already been added to this Frequency, v must
* be comparable to those that have already been added.
* </p>
*
* @param v the value to add.
* @param increment the amount by which the value should be incremented
* @throws MathIllegalArgumentException if <code>v</code> is not comparable with previous entries
* @since 3.1
*/
public void incrementValue(Comparable<?> v, long increment) throws MathIllegalArgumentException {
Comparable<?> obj = v;
if (v instanceof Integer) {
obj = Long.valueOf(((Integer) v).longValue());
}
try {
Long count = freqTable.get(obj);
if (count == null) {
freqTable.put(obj, Long.valueOf(increment));
} else {
freqTable.put(obj, Long.valueOf(count.longValue() + increment));
}
} catch (ClassCastException ex) {
//TreeMap will throw ClassCastException if v is not comparable
throw new MathIllegalArgumentException(
LocalizedFormats.INSTANCES_NOT_COMPARABLE_TO_EXISTING_VALUES,
v.getClass().getName());
}
}