下面列出了java.util.concurrent.atomic.AtomicInteger#intValue() 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* Loads an instance of the class from a stream of tuples possibly containing extra information.
*
* @param <U> type of user
* @param <I> type of item
* @param <O> type of additional information
* @param tuples stream of user-item-value triples
* @param uPrefFun creator of preference objects
* @param iPrefFun creator of preference objects
* @return a preference data object
*/
public static <U, I, O> SimplePreferenceData<U, I> load(Stream<Tuple4<U, I, Double, O>> tuples,
Function4<U, I, Double, O, ? extends IdPref<I>> uPrefFun,
Function4<U, I, Double, O, ? extends IdPref<U>> iPrefFun) {
AtomicInteger numPreferences = new AtomicInteger(0);
Map<U, List<IdPref<I>>> userMap = new HashMap<>();
Map<I, List<IdPref<U>>> itemMap = new HashMap<>();
tuples.forEach(t -> {
numPreferences.incrementAndGet();
userMap.computeIfAbsent(t.v1, v1 -> new ArrayList<>()).add(uPrefFun.apply(t));
itemMap.computeIfAbsent(t.v2, v2 -> new ArrayList<>()).add(iPrefFun.apply(t));
});
return new SimplePreferenceData<>(userMap, itemMap, numPreferences.intValue());
}
/**
* Inserts pending items into the Insertable, and adds them to the active positions (correctly managing position shifting). Clears the pending items.
*/
private void insertPending() {
for (Pair<Integer, T> pi : mPendingItemsToInsert) {
for (AtomicInteger existing : mActiveIndexes) {
if (existing.intValue() >= pi.first) {
existing.incrementAndGet();
}
}
mActiveIndexes.add(new AtomicInteger(pi.first));
mInsertable.add(pi.first, pi.second);
}
mPendingItemsToInsert.clear();
}
private static int getSelectedRow() throws Exception {
final AtomicInteger row = new AtomicInteger(-1);
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
row.set(table.getSelectedRow());
}
});
return row.intValue();
}
@Override
protected boolean matchesSafely(final AtomicInteger item) {
return mValue == item.intValue();
}
/** The binary {@code divide} operator. This is the equivalent to
* the Java {@code /} operator. This function is not null-safe.
*
* @param left a number.
* @param right a number.
* @return {@code left/right}
*/
@Pure
@Inline(value = "($1.intValue() / $2)", constantExpression = true)
public static int operator_divide(AtomicInteger left, byte right) {
return left.intValue() / right;
}
/** The binary {@code multiply} operator. This is the equivalent to
* the Java {@code *} operator. This function is not null-safe.
*
* @param left a number.
* @param right a number.
* @return {@code left*right}
*/
@Pure
@Inline(value = "($1.intValue() * $2.byteValue())", constantExpression = true)
public static int operator_multiply(AtomicInteger left, Byte right) {
return left.intValue() * right.byteValue();
}
/** The binary {@code lessThan} operator. This is the equivalent to
* the Java {@code <} operator. This function is not null-safe.
*
* @param left a number.
* @param right a number.
* @return {@code left<right}
*/
@Pure
@Inline(value = "($1.intValue() < $2)", constantExpression = true)
public static boolean operator_lessThan(AtomicInteger left, short right) {
return left.intValue() < right;
}
/** The binary {@code minus} operator. This is the equivalent to
* the Java {@code -} operator. This function is not null-safe.
*
* @param left a number.
* @param right a number.
* @return {@code left-right}
*/
@Pure
@Inline(value = "($1 - $2.intValue())", constantExpression = true)
public static int operator_minus(short left, AtomicInteger right) {
return left - right.intValue();
}
/** The binary {@code plus} operator. This is the equivalent to
* the Java {@code +} operator. This function is not null-safe.
*
* @param left a number.
* @param right a number.
* @return {@code left+right}
*/
@Pure
@Inline(value = "($1.byteValue() + $2.intValue())", constantExpression = true)
public static int operator_plus(Byte left, AtomicInteger right) {
return left.byteValue() + right.intValue();
}
/** The binary {@code divide} operator. This is the equivalent to
* the Java {@code /} operator. This function is not null-safe.
*
* @param left a number.
* @param right a number.
* @return {@code left/right}
*/
@Pure
@Inline(value = "($1.floatValue() / $2.intValue())", constantExpression = true)
public static float operator_divide(Float left, AtomicInteger right) {
return left.floatValue() / right.intValue();
}
/** The binary {@code multiply} operator. This is the equivalent to
* the Java {@code *} operator. This function is not null-safe.
*
* @param left a number.
* @param right a number.
* @return {@code left*right}
*/
@Pure
@Inline(value = "($1 * $2.intValue())", constantExpression = true)
public static long operator_multiply(long left, AtomicInteger right) {
return left * right.intValue();
}
/** The binary {@code greaterEqualsThan} operator. This is the equivalent
* to the Java {@code >=} operator. This function is not null-safe.
*
* @param left a number.
* @param right a number.
* @return {@code left>=right}
*/
@Pure
@Inline(value = "($1.intValue() >= $2)", constantExpression = true)
public static boolean operator_greaterEqualsThan(AtomicInteger left, byte right) {
return left.intValue() >= right;
}
/** The binary {@code divide} operator. This is the equivalent to
* the Java {@code /} operator. This function is not null-safe.
*
* @param left a number.
* @param right a number.
* @return {@code left/right}
*/
@Pure
@Inline(value = "($1.intValue() / $2)", constantExpression = true)
public static float operator_divide(AtomicInteger left, float right) {
return left.intValue() / right;
}
/** The binary {@code modulo} operator. This is the equivalent to
* the Java {@code %} operator. This function is not null-safe.
*
* @param left a number.
* @param right a number.
* @return {@code left%right}
*/
@Pure
@Inline(value = "($1 % $2.intValue())", constantExpression = true)
public static int operator_modulo(short left, AtomicInteger right) {
return left % right.intValue();
}
/** The binary {@code plus} operator. This is the equivalent to
* the Java {@code +} operator. This function is not null-safe.
*
* @param left a number.
* @param right a number.
* @return {@code left+right}
*/
@Pure
@Inline(value = "($1.intValue() + $2.intValue())", constantExpression = true)
public static int operator_plus(AtomicInteger left, AtomicInteger right) {
return left.intValue() + right.intValue();
}
/**
* The binary {@code equals} operator. This is the equivalent to the Java {@code ==} operator.
* This function is null-safe.
*
* @param left a number.
* @param right a number.
* @return {@code left==right}
*/
@Pure
@Inline(value = "($1 != null ? ($1.intValue() == $2) : false)", constantExpression = true)
public static boolean operator_equals(AtomicInteger left, byte right) {
return left != null ? left.intValue() == right : false;
}
/** The binary {@code divide} operator. This is the equivalent to
* the Java {@code /} operator. This function is not null-safe.
*
* @param left a number.
* @param right a number.
* @return {@code left/right}
*/
@Pure
@Inline(value = "($1.intValue() / $2)", constantExpression = true)
public static int operator_divide(AtomicInteger left, int right) {
return left.intValue() / right;
}
/** The binary {@code greaterThan} operator. This is the equivalent
* to the Java {@code >} operator. This function is not null-safe.
*
* @param left a number.
* @param right a number.
* @return {@code left>right}
*/
@Pure
@Inline(value = "($1.intValue() > $2)", constantExpression = true)
public static boolean operator_greaterThan(AtomicInteger left, int right) {
return left.intValue() > right;
}
/** The binary {@code multiply} operator. This is the equivalent to
* the Java {@code *} operator. This function is not null-safe.
*
* @param left a number.
* @param right a number.
* @return {@code left*right}
*/
@Pure
@Inline(value = "($1 * $2.intValue())", constantExpression = true)
public static int operator_multiply(int left, AtomicInteger right) {
return left * right.intValue();
}
/** The binary {@code minus} operator. This is the equivalent to
* the Java {@code -} operator. This function is not null-safe.
*
* @param left a number.
* @param right a number.
* @return {@code left-right}
*/
@Pure
@Inline(value = "($1.intValue() - $2.intValue())", constantExpression = true)
public static int operator_minus(Integer left, AtomicInteger right) {
return left.intValue() - right.intValue();
}