Java Code Examples for java.util.concurrent.atomic.AtomicInteger#intValue()

The following examples show how to use java.util.concurrent.atomic.AtomicInteger#intValue() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
/**
 * 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());
}
 
Example 2
/**
 * 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();
}
 
Example 3
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();
}
 
Example 4
Source Project: ListViewAnimations   File: Matchers.java    License: Apache License 2.0 4 votes vote down vote up
@Override
protected boolean matchesSafely(final AtomicInteger item) {
    return mValue == item.intValue();
}
 
Example 5
/** 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;
}
 
Example 6
/** 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();
}
 
Example 7
/** The binary {@code lessThan} operator. This is the equivalent to
 * the Java {@code &lt;} operator. This function is not null-safe.
 *
 * @param left a number.
 * @param right a number.
 * @return {@code left&lt;right}
 */
@Pure
@Inline(value = "($1.intValue() < $2)", constantExpression = true)
public static boolean operator_lessThan(AtomicInteger left, short right) {
	return left.intValue() < right;
}
 
Example 8
/** 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();
}
 
Example 9
Source Project: sarl   File: ByteArithmeticExtensions.java    License: Apache License 2.0 2 votes vote down vote up
/** 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();
}
 
Example 10
Source Project: sarl   File: FloatArithmeticExtensions.java    License: Apache License 2.0 2 votes vote down vote up
/** 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();
}
 
Example 11
/** 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();
}
 
Example 12
/** The binary {@code greaterEqualsThan} operator. This is the equivalent
 * to the Java {@code &gt;=} operator. This function is not null-safe.
 *
 * @param left a number.
 * @param right a number.
 * @return {@code left&gt;=right}
 */
@Pure
@Inline(value = "($1.intValue() >= $2)", constantExpression = true)
public static boolean operator_greaterEqualsThan(AtomicInteger left, byte right) {
	return left.intValue() >= right;
}
 
Example 13
/** 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;
}
 
Example 14
/** 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();
}
 
Example 15
/** 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();
}
 
Example 16
/**
 * 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;
}
 
Example 17
/** 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;
}
 
Example 18
/** The binary {@code greaterThan} operator. This is the equivalent
 * to the Java {@code &gt;} operator. This function is not null-safe.
 *
 * @param left a number.
 * @param right a number.
 * @return {@code left&gt;right}
 */
@Pure
@Inline(value = "($1.intValue() > $2)", constantExpression = true)
public static boolean operator_greaterThan(AtomicInteger left, int right) {
	return left.intValue() > right;
}
 
Example 19
/** 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();
}
 
Example 20
/** 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();
}