Java Code Examples for com.google.common.primitives.Ints#min()
The following examples show how to use
com.google.common.primitives.Ints#min() .
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: EngineProfileManagerDialog.java From mylizzie with GNU General Public License v3.0 | 5 votes |
private void initVariables() { userApproved = false; profileList = Lizzie.optionSetting.getEngineProfileList(); profileTextFields = ImmutableList.of(textFieldProfile1, textFieldProfile2, textFieldProfile3, textFieldProfile4 , textFieldProfile5, textFieldProfile6, textFieldProfile7, textFieldProfile8, textFieldProfile9); if (CollectionUtils.isNotEmpty(profileList)) { for (int i = 0; i < Ints.min(profileList.size(), profileTextFields.size()); ++i) { profileTextFields.get(i).setText(profileList.get(i)); } } }
Example 2
Source File: RaindropListener.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
private int calculateRaindrops(MatchPlayerState player, int count, boolean scaled, double percent) { if(scaled) { final Match match = player.getMatch(); count += (int) ((double) match.getParticipatingPlayers().size() / match.getMaxPlayers() * RaindropConstants.MATCH_FULLNESS_BONUS); if(player.getParty() instanceof Team) { count += Ints.min((int) (Math.sqrt(((Team) player.getParty()).getCumulativeParticipation(player.getPlayerId()).getSeconds()) / RaindropConstants.PLAY_TIME_BONUS), RaindropConstants.PLAY_TIME_BONUS_CUTOFF); } } return RaindropUtil.calculateRaindrops(player.getPlayerId(), (int) (count * percent), true); }
Example 3
Source File: QRcodeUtil.java From wechat-mp-sdk with Apache License 2.0 | 5 votes |
public static QRcodeTicketJsonRtn createTemporaryQRcode(License license, long sceneId, int expireSeconds) { if (expireSeconds <= 0) { return JsonRtnUtil.buildFailureJsonRtn(QRcodeTicketJsonRtn.class, "expireSeconds must be positive"); } expireSeconds = Ints.min(expireSeconds, 1800); QRcodeActionInfo actionInfo = new QRcodeActionInfo(new QRcodeScene(sceneId)); return createQRcode(license, new QRcodeTicket(QRcodeType.TEMPORARY.getActionName(), expireSeconds, actionInfo)); }
Example 4
Source File: TarjanComponentFinder.java From ArchUnit with Apache License 2.0 | 4 votes |
@Override public Integer apply(int[] input) { return Ints.min(input); }
Example 5
Source File: DynamicMetric.java From imhotep with Apache License 2.0 | 4 votes |
@Override public long getMin() { return Ints.min(values); }
Example 6
Source File: MinValueInArray.java From levelup-java-examples with Apache License 2.0 | 4 votes |
@Test public void find_min_value_in_numeric_array_with_guava () { int lowest = Ints.min(numbers); assertEquals(1, lowest); }
Example 7
Source File: HashCode.java From exonum-java-binding with Apache License 2.0 | 3 votes |
/** * Copies bytes from this hash code into {@code dest}. * * @param dest the byte array into which the hash code will be written * @param offset the start offset in the data * @param maxLength the maximum number of bytes to write * @return the number of bytes written to {@code dest} * @throws IndexOutOfBoundsException if there is not enough room in {@code dest} */ @CanIgnoreReturnValue public int writeBytesTo(byte[] dest, int offset, int maxLength) { maxLength = Ints.min(maxLength, bits() / 8); Preconditions.checkPositionIndexes(offset, offset + maxLength, dest.length); writeBytesToImpl(dest, offset, maxLength); return maxLength; }
Example 8
Source File: HashCode.java From codebuff with BSD 2-Clause "Simplified" License | 3 votes |
/** * Copies bytes from this hash code into {@code dest}. * * @param dest the byte array into which the hash code will be written * @param offset the start offset in the data * @param maxLength the maximum number of bytes to write * @return the number of bytes written to {@code dest} * @throws IndexOutOfBoundsException if there is not enough room in {@code dest} */ @CanIgnoreReturnValue public int writeBytesTo(byte[] dest, int offset, int maxLength) { maxLength = Ints.min(maxLength, bits() / 8); Preconditions.checkPositionIndexes(offset, offset + maxLength, dest.length); writeBytesToImpl(dest, offset, maxLength); return maxLength; }
Example 9
Source File: HashCode.java From codebuff with BSD 2-Clause "Simplified" License | 3 votes |
/** * Copies bytes from this hash code into {@code dest}. * * @param dest the byte array into which the hash code will be written * @param offset the start offset in the data * @param maxLength the maximum number of bytes to write * @return the number of bytes written to {@code dest} * @throws IndexOutOfBoundsException if there is not enough room in {@code dest} */ @CanIgnoreReturnValue public int writeBytesTo(byte[] dest, int offset, int maxLength) { maxLength = Ints.min(maxLength, bits() / 8); Preconditions.checkPositionIndexes(offset, offset + maxLength, dest.length); writeBytesToImpl(dest, offset, maxLength); return maxLength; }
Example 10
Source File: HashCode.java From codebuff with BSD 2-Clause "Simplified" License | 3 votes |
/** * Copies bytes from this hash code into {@code dest}. * * @param dest the byte array into which the hash code will be written * @param offset the start offset in the data * @param maxLength the maximum number of bytes to write * @return the number of bytes written to {@code dest} * @throws IndexOutOfBoundsException if there is not enough room in {@code dest} */ @CanIgnoreReturnValue public int writeBytesTo(byte[] dest, int offset, int maxLength) { maxLength = Ints.min(maxLength, bits() / 8); Preconditions.checkPositionIndexes(offset, offset + maxLength, dest.length); writeBytesToImpl(dest, offset, maxLength); return maxLength; }
Example 11
Source File: HashCode.java From codebuff with BSD 2-Clause "Simplified" License | 3 votes |
/** * Copies bytes from this hash code into {@code dest}. * * @param dest the byte array into which the hash code will be written * @param offset the start offset in the data * @param maxLength the maximum number of bytes to write * @return the number of bytes written to {@code dest} * @throws IndexOutOfBoundsException if there is not enough room in {@code dest} */ @CanIgnoreReturnValue public int writeBytesTo(byte[] dest, int offset, int maxLength) { maxLength = Ints.min(maxLength, bits() / 8); Preconditions.checkPositionIndexes(offset, offset + maxLength, dest.length); writeBytesToImpl(dest, offset, maxLength); return maxLength; }
Example 12
Source File: HashCode.java From codebuff with BSD 2-Clause "Simplified" License | 3 votes |
/** * Copies bytes from this hash code into {@code dest}. * * @param dest the byte array into which the hash code will be written * @param offset the start offset in the data * @param maxLength the maximum number of bytes to write * @return the number of bytes written to {@code dest} * @throws IndexOutOfBoundsException if there is not enough room in {@code dest} */ @CanIgnoreReturnValue public int writeBytesTo(byte[] dest, int offset, int maxLength) { maxLength = Ints.min(maxLength, bits() / 8); Preconditions.checkPositionIndexes(offset, offset + maxLength, dest.length); writeBytesToImpl(dest, offset, maxLength); return maxLength; }
Example 13
Source File: GuavaTutorial.java From maven-framework-project with MIT License | 3 votes |
@Test public void example20(){ int[] array1 = { 1, 2, 3, 4, 5 }; int a = 4; boolean contains = Ints.contains(array1, a);//判断数组中是否存在a元素 System.out.println(contains); int indexOf = Ints.indexOf(array1, a); //获取该元素在数组中的下标 System.out.println(indexOf); int max = Ints.max(array1);//求数组中的最大值 System.out.println(max); int min = Ints.min(array1);//求数组中的最小值 System.out.println(min); int[] array2 = {6, 7, 8, 9, 10}; int[] concat = Ints.concat(array1, array2 );//合并数组 System.out.println(Arrays.toString(concat)); }