本文整理匯總了Java中java.util.List.set方法的典型用法代碼示例。如果您正苦於以下問題:Java List.set方法的具體用法?Java List.set怎麽用?Java List.set使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.List
的用法示例。
在下文中一共展示了List.set方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: swapMoveAdd
import java.util.List; //導入方法依賴的package包/類
private void swapMoveAdd(List<UpdateOp> list, int move, UpdateOp moveOp, int add, UpdateOp addOp) {
int offset = 0;
if (moveOp.itemCount < addOp.positionStart) {
offset = 0 - 1;
}
if (moveOp.positionStart < addOp.positionStart) {
offset++;
}
if (addOp.positionStart <= moveOp.positionStart) {
moveOp.positionStart += addOp.itemCount;
}
if (addOp.positionStart <= moveOp.itemCount) {
moveOp.itemCount += addOp.itemCount;
}
addOp.positionStart += offset;
list.set(move, addOp);
list.set(add, moveOp);
}
示例2: updateFeedMetaDataAt
import java.util.List; //導入方法依賴的package包/類
@SuppressWarnings({"ResultOfMethodCallIgnored", "ConstantConditions"})
public static void updateFeedMetaDataAt(final Context context, final int position,
final List<String> metaData) {
final LinkedListMultimap<String, String> map = getFeedMetaData(context);
final String currentTitle = getFeedMetaDataTitleAt(context, position);
final String newTitle = metaData.get(TITLE);
final String category = metaData.get(FEED_ID);
final List<String> values = new ArrayList<>(map.removeAll(currentTitle));
values.set(CATEGORY, category);
map.putAll(newTitle, values);
putFeedMetaData(context, map);
updateCurrentFeedAdapterPosition(context, newTitle);
}
示例3: getResultList
import java.util.List; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@Override
protected List getResultList(List results, ResultTransformer resultTransformer) throws QueryException {
// meant to handle dynamic instantiation queries...
HolderInstantiator holderInstantiator = buildHolderInstantiator( resultTransformer );
if ( holderInstantiator.isRequired() ) {
for ( int i = 0; i < results.size(); i++ ) {
Object[] row = ( Object[] ) results.get( i );
Object result = holderInstantiator.instantiate(row);
results.set( i, result );
}
if ( !hasSelectNew() && resultTransformer != null ) {
return resultTransformer.transformList(results);
}
else {
return results;
}
}
else {
return results;
}
}
示例4: createFullYear
import java.util.List; //導入方法依賴的package包/類
private List<MonthlyPvDatum> createFullYear(int year, List<MonthlyPvDatum> monthPvData) {
List<MonthlyPvDatum> fullYear = new ArrayList<>();
for (int month = 1; month <= 12; month++) {
fullYear.add(new MonthlyPvDatum(year, month, 0));
}
for (MonthlyPvDatum monthlyPvDatum : monthPvData) {
int fullYearIndex = monthlyPvDatum.getMonth() - 1;
fullYear.set(fullYearIndex, monthlyPvDatum);
}
return fullYear;
}
示例5: resolveResourceIds
import java.util.List; //導入方法依賴的package包/類
public static void resolveResourceIds(final Activity activity, final List<Integer> idRes) {
final TypedValue tv = new TypedValue();
final Resources.Theme theme = activity.getTheme();
int i = 0;
for (final int res : idRes) {
theme.resolveAttribute(res, tv, true);
idRes.set(i, tv.resourceId);
i++;
}
}
示例6: trimGaps
import java.util.List; //導入方法依賴的package包/類
/**
* Remove only deletion/NNNs from the beginning and the end of alignment
*
* @param sequence
* @param firstAA
* @param lastAA
* @param mutations
* @param frameShifts
* @return
*/
private static int[] trimGaps(
Sequence sequence, int firstAA, int lastAA,
Collection<Mutation> mutations, Collection<FrameShift> frameShifts) {
int trimLeft = 0;
int trimRight = 0;
int proteinSize = lastAA - firstAA + 1;
List<Boolean> gapSites = new ArrayList<>(Collections.nCopies(proteinSize, false));
for (Mutation mut : mutations) {
int idx = mut.getPosition() - firstAA;
if (mut.isDeletion() || mut.isUnsequenced()) {
gapSites.set(idx, true);
}
}
// remove initial deletions
for (int idx=0; idx < proteinSize; idx ++) {
if (!gapSites.get(idx)) {
if (idx > trimLeft) {
trimLeft = idx;
}
break;
}
}
// remove trailing deletions
for (int idx=proteinSize-1; idx > -1; idx --) {
if (!gapSites.get(idx)) {
if (proteinSize - idx - 1 > trimRight) {
trimRight = proteinSize - idx - 1;
}
break;
}
}
return new int[]{trimLeft, trimRight};
}
示例7: getProcessBuilder
import java.util.List; //導入方法依賴的package包/類
public static ProcessBuilder getProcessBuilder(String paths, List<String> command) throws IOException {
if (command == null || command.size() == 0) {
throw new IOException("No command paramater");
}
paths = getAllPaths(paths);
command.set(0, searchFullPath(paths, command.get(0)));
ProcessBuilder pb = new ProcessBuilder(command);
Map<String, String> pbEnv = pb.environment();
// must set "Path" for Windows 8.1 64
pbEnv.put(pbEnv.get("PATH") == null ? "Path" : "PATH", paths);
return pb;
}
示例8: setEntanglementStack
import java.util.List; //導入方法依賴的package包/類
default void setEntanglementStack(UUID uuid, ItemStack stack, int slot) {
List<ItemStack> list = getEntanglement(uuid);
if(!hasSlot(uuid, slot)) {
if(!stack.isEmpty()) {
list.add(stack);
}
} else if(!stack.isEmpty()) {
list.set(slot, stack);
} else {
list.remove(slot);
}
}
示例9: testReturnCanBeSet
import java.util.List; //導入方法依賴的package包/類
/***/
@Test
public void testReturnCanBeSet() {
final List<String> ret = transform(new Object[] { "item" }, input -> valueOf(input));
assertFalse(ret.isEmpty());
assertTrue("item".equals(getOnlyElement(ret)));
ret.set(0, "another item");
assertTrue("another item".equals(getOnlyElement(ret)));
}
示例10: main
import java.util.List; //導入方法依賴的package包/類
public static void main(String[] args) {
List<Integer> list = new ArrayList<>();
Integer[] arr = {2,10,3};
list = Arrays.asList(arr);
list.set(0, 3);
System.out.println(list);
list.add(1);
System.out.println(list);
}
示例11: sequencingOfSchemaFieldsInOrderOfInternalSchemaFields
import java.util.List; //導入方法依賴的package包/類
private void sequencingOfSchemaFieldsInOrderOfInternalSchemaFields(List<GridRow> outputSchema,
List<GridRow> internalSchema2) {
for(int index=0;index<internalSchema2.size();index++){
if(!StringUtils.equalsIgnoreCase(outputSchema.get(index).getFieldName(), internalSchema2.get(index).getFieldName())){
outputSchema.set(index,internalSchema2.get(index));
}
}
}
示例12: testAsList_toArray_roundTrip
import java.util.List; //導入方法依賴的package包/類
public void testAsList_toArray_roundTrip() {
char[] array = { (char) 0, (char) 1, (char) 2 };
List<Character> list = Chars.asList(array);
char[] newArray = Chars.toArray(list);
// Make sure it returned a copy
list.set(0, (char) 4);
assertTrue(Arrays.equals(
new char[] { (char) 0, (char) 1, (char) 2 }, newArray));
newArray[1] = (char) 5;
assertEquals((char) 1, (char) list.get(1));
}
示例13: addResultsToList
import java.util.List; //導入方法依賴的package包/類
private void addResultsToList(List<StatusOrException> sliceStatuses) {
for (AtomicArray.Entry<Tuple<BulkByScrollResponse, Exception>> t : results.asList()) {
if (t.value != null) {
if (t.value.v1() != null) {
sliceStatuses.set(t.index, new StatusOrException(t.value.v1().getStatus()));
} else {
sliceStatuses.set(t.index, new StatusOrException(t.value.v2()));
}
}
}
}
示例14: removeSelf
import java.util.List; //導入方法依賴的package包/類
@Override
public boolean removeSelf() {
IRNode header = getChildren().get(DoWhilePart.HEADER.ordinal());
List<IRNode> siblings = getParent().getChildren();
int index = siblings.indexOf(this);
siblings.set(index++, loop.initialization);
if (header instanceof Block) {
siblings.addAll(index, header.getChildren());
} else {
siblings.add(index, header);
}
return true;
}
示例15: answersModification_setByMutator_collectionShouldBeCopied
import java.util.List; //導入方法依賴的package包/類
@Test
public void answersModification_setByMutator_collectionShouldBeCopied() {
// given
GeneralVariables gv = new GeneralVariables();
List<String> answers = Lists.newArrayList("a");
gv.setAnswers(answers);
// when
answers.set(0, "b");
// then
assertThat(gv.getAnswers().get(0)).isEqualTo("a");
}