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

The following examples show how to use java.util.concurrent.atomic.AtomicInteger#intValue() . 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
Source File: SimplePreferenceData.java    From RankSys with Mozilla Public License 2.0 6 votes vote down vote up
/**
 * 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
Source File: InsertQueue.java    From android-open-project-demo with Apache License 2.0 5 votes vote down vote up
/**
 * 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
Source File: bug7068740.java    From openjdk-8 with GNU General Public License v2.0 5 votes vote down vote up
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 File: Matchers.java    From ListViewAnimations with Apache License 2.0 4 votes vote down vote up
@Override
protected boolean matchesSafely(final AtomicInteger item) {
    return mValue == item.intValue();
}
 
Example 5
Source File: AtomicIntegerArithmeticExtensions.java    From sarl with 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.intValue() / $2)", constantExpression = true)
public static float operator_divide(AtomicInteger left, float right) {
	return left.intValue() / right;
}
 
Example 6
Source File: IntegerArithmeticExtensions.java    From sarl with Apache License 2.0 2 votes vote down vote up
/** 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();
}
 
Example 7
Source File: PrimitiveIntArithmeticExtensions.java    From sarl with Apache License 2.0 2 votes vote down vote up
/** 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 8
Source File: AtomicIntegerComparisonExtensions.java    From sarl with Apache License 2.0 2 votes vote down vote up
/** 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 9
Source File: AtomicIntegerArithmeticExtensions.java    From sarl with 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.intValue() / $2)", constantExpression = true)
public static int operator_divide(AtomicInteger left, int right) {
	return left.intValue() / right;
}
 
Example 10
Source File: AtomicIntegerComparisonExtensions.java    From sarl with Apache License 2.0 2 votes vote down vote up
/**
 * 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 11
Source File: AtomicIntegerArithmeticExtensions.java    From sarl with 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.intValue() / $2)", constantExpression = true)
public static int operator_divide(AtomicInteger left, byte right) {
	return left.intValue() / right;
}
 
Example 12
Source File: AtomicIntegerArithmeticExtensions.java    From sarl with 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.intValue() + $2.intValue())", constantExpression = true)
public static int operator_plus(AtomicInteger left, AtomicInteger right) {
	return left.intValue() + right.intValue();
}
 
Example 13
Source File: PrimitiveShortArithmeticExtensions.java    From sarl with Apache License 2.0 2 votes vote down vote up
/** 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 14
Source File: AtomicIntegerArithmeticExtensions.java    From sarl with Apache License 2.0 2 votes vote down vote up
/** 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 15
Source File: AtomicIntegerComparisonExtensions.java    From sarl with Apache License 2.0 2 votes vote down vote up
/** 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 16
Source File: PrimitiveLongArithmeticExtensions.java    From sarl with Apache License 2.0 2 votes vote down vote up
/** 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 17
Source File: FloatArithmeticExtensions.java    From sarl with 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 18
Source File: ByteArithmeticExtensions.java    From sarl with 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 19
Source File: PrimitiveShortArithmeticExtensions.java    From sarl with Apache License 2.0 2 votes vote down vote up
/** 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 20
Source File: AtomicIntegerComparisonExtensions.java    From sarl with Apache License 2.0 2 votes vote down vote up
/** 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;
}