static <C, T> Schedule<C, T> create(C context, ImmutableList<ImmutableList<T>> routes, IntList startIndices, RouteEvaluator<C, T> routeEvaluator) { final DoubleList costs = new DoubleArrayList(routes.size()); double sumCost = 0; for (int i = 0; i < routes.size(); i++) { final double cost = routeEvaluator.computeCost(context, i, routes.get(i)); costs.add(cost); sumCost += cost; } return new Schedule<C, T>( context, routes, IntLists.unmodifiable(new IntArrayList(startIndices)), DoubleLists.unmodifiable(costs), sumCost, routeEvaluator); }
@Override public IntList next() { if (!hasNext()) { throw new NoSuchElementException(); } if (index > 0) { for (int i = 0; i < insertionPositions.length; i++) { if (insertionPositions[i] == originalListSize) { insertionPositions[i - 1]++; for (int j = i; j < insertionPositions.length; j++) { insertionPositions[j] = insertionPositions[i - 1]; } break; } else if (i == insertionPositions.length - 1) { insertionPositions[i]++; } } } index++; return IntLists.unmodifiable(new IntArrayList(insertionPositions)); }
static <C, T> Schedule<C, T> create(C context, ImmutableList<ImmutableList<T>> routes, IntList startIndices, DoubleList objectiveValues, double globalObjectiveValue, RouteEvaluator<C, T> routeEvaluator) { return new Schedule<C, T>( context, routes, IntLists.unmodifiable(new IntArrayList(startIndices)), DoubleLists.unmodifiable(new DoubleArrayList(objectiveValues)), globalObjectiveValue, routeEvaluator); }
/** * Removes all items from list and returns the indices of the removed items. * @param list The list to remove items from. * @param item The item to remove from the list. * @return The indices of the removed items, or an empty list if the item was * not found in list. */ static <T> IntList removeAll(List<T> list, T item) { final Iterator<T> it = list.iterator(); final IntArrayList indices = new IntArrayList(); int i = 0; while (it.hasNext()) { if (it.next().equals(item)) { it.remove(); indices.add(i); } i++; } return IntLists.unmodifiable(indices); }
@Override @Nonnull public IntList getValidItemStacksPacked() { boolean normal = isConditionMet.getAsBoolean(); IntList validStacks = normal ? packedConditionMet : packedConditionNotMet; if (validStacks == null) { validStacks = IntLists.singleton(RecipeItemHelper.pack(normal ? stackConditionMet : stackConditionNotMet)); if (normal) packedConditionMet = validStacks; else packedConditionNotMet = validStacks; } return validStacks; }
private MessagePlayOutUnlockRecipes(boolean openRecipeBook, boolean craftingFilter, IntList recipeIds) { this.recipeIds = IntLists.unmodifiable(recipeIds); this.openRecipeBook = openRecipeBook; this.craftingFilter = craftingFilter; }
public Init(boolean openRecipeBook, boolean craftingFilter, IntList recipeIds, IntList recipeIdsToBeDisplayed) { super(openRecipeBook, craftingFilter, recipeIds); this.recipeIdsToBeDisplayed = IntLists.unmodifiable(recipeIdsToBeDisplayed); }
static IntList asIntList(final int... values) { return IntLists.unmodifiable(new IntArrayList(values)); }