当前位置: 首页>>代码示例>>Java>>正文


Java ArrayList.set方法代码示例

本文整理汇总了Java中java.util.ArrayList.set方法的典型用法代码示例。如果您正苦于以下问题:Java ArrayList.set方法的具体用法?Java ArrayList.set怎么用?Java ArrayList.set使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.util.ArrayList的用法示例。


在下文中一共展示了ArrayList.set方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: retornarMatrizComPivot

import java.util.ArrayList; //导入方法依赖的package包/类
/**
 * Metodo usado para pegar pegar a linha linha do pivot e de seguida fazer a permutacao de linhas! colocando acima a linha do pivot
 * @param matriz - matriz dos valores
 * @param coluna - coluna com a qual estamos a trabalhar
 * @return matriz com zeros abaixo do pivot
 */
public ArrayList<ArrayList<Double>> retornarMatrizComPivot(ArrayList<ArrayList<Double>> matriz,int coluna){
    int linhaDoPivot = this.retornarLinhaDoPivot(matriz, coluna);
    
    ArrayList<Double> auxParaTroca = new ArrayList();
    auxParaTroca = matriz.get(coluna);
    matriz.set(coluna, matriz.get(linhaDoPivot));
    matriz.set(linhaDoPivot, auxParaTroca);
    
    /**
     * Para q possa imprimir a matriz depois de fazer a permutacao de linhas
     */
    this.imprimirMatriz(matriz);
    
    return retornarZeroAbaixo(matriz, coluna);
}
 
开发者ID:AlfredoSebastiao,项目名称:Metodo-de-Gaus-Com-Pivot,代码行数:22,代码来源:Controle.java

示例2: getDisplay

import java.util.ArrayList; //导入方法依赖的package包/类
public ArrayList<String> getDisplay() {
    if (desc == null) {
        desc = new ArrayList<String>();
        desc.add(ChatColor.GOLD + "Recommended Level: " + ChatColor.YELLOW + recLevel);
        desc.add(ChatColor.AQUA + description);
        desc.add("");
        desc.add(ChatColor.WHITE + "Tips");
        for (String s : tips) {
            ArrayList<String> temp = RFormatter.stringToLore(s, "   ");
            if (temp.size() > 0)
                temp.set(0, "-" + temp.get(0).substring(2));
            for (String t : temp)
                desc.add(ChatColor.GRAY + t);
        }
    }
    return desc;
}
 
开发者ID:edasaki,项目名称:ZentrelaRPG,代码行数:18,代码来源:Dungeon.java

示例3: remove

import java.util.ArrayList; //导入方法依赖的package包/类
public void remove(final Element pointer) {
    synchronized (mExpandableArrayOfActivePointers) {
        if (DEBUG) {
            Log.d(TAG, "remove: " + pointer + " " + this);
        }
        final ArrayList<Element> expandableArray = mExpandableArrayOfActivePointers;
        final int arraySize = mArraySize;
        int newIndex = 0;
        for (int index = 0; index < arraySize; index++) {
            final Element element = expandableArray.get(index);
            if (element == pointer) {
                if (newIndex != index) {
                    Log.w(TAG, "Found duplicated element in remove: " + pointer);
                }
                continue; // Remove this element from the expandableArray.
            }
            if (newIndex != index) {
                // Shift this element toward the beginning of the expandableArray.
                expandableArray.set(newIndex, element);
            }
            newIndex++;
        }
        mArraySize = newIndex;
    }
}
 
开发者ID:sergeychilingaryan,项目名称:AOSP-Kayboard-7.1.2,代码行数:26,代码来源:PointerTrackerQueue.java

示例4: testUpdateNotice

import java.util.ArrayList; //导入方法依赖的package包/类
@Test
public void testUpdateNotice() {
    ArrayList<String> notices = new ArrayList<String>();
    notices.add("haha");
    Notice notice = new Notice(1, notices);
    noticeDao.addNotice(notice);

    notice = noticeDao.getAllNotices().get(0);
    notices = notice.getNotices();
    notices.set(0, "heihei");
    notice.setNotices(notices);
    noticeDao.updateNotice(notice);

    Assert.assertEquals(noticeDao.getAllNotices().get(0).getNotices(), notice.getNotices());

    noticeDao.deleteNotice(notice);
}
 
开发者ID:qinjr,项目名称:TeamNote,代码行数:18,代码来源:NoticeDaoImplTest.java

示例5: getMeanNeuralData

import java.util.ArrayList; //导入方法依赖的package包/类
public ArrayList<Double> getMeanNeuralData(){
    ArrayList<Double> result=new ArrayList<>();
    for(int j=0;j<numberOfOutputs;j++){
        Double r=0.0;
        result.add(r);
        for(int k=0;k<numberOfRecords;k++){
            r+=neuralData.get(k).get(j);
        }
        result.set(j, r/((double)numberOfRecords));
    }
    return result;
}
 
开发者ID:PacktPublishing,项目名称:Neural-Network-Programming-with-Java-SecondEdition,代码行数:13,代码来源:NeuralOutputData.java

示例6: getMeanInputData

import java.util.ArrayList; //导入方法依赖的package包/类
public ArrayList<Double> getMeanInputData(){
    ArrayList<Double> result=new ArrayList<>();
    for(int i=0;i<numberOfInputs;i++){
        Double r=0.0;
        result.add(r);
        for(int k=0;k<numberOfRecords;k++){
            r+=data.get(k).get(i);
        }
        result.set(i, r/((double)numberOfRecords));
    }
    return result;
}
 
开发者ID:PacktPublishing,项目名称:Neural-Network-Programming-with-Java-SecondEdition,代码行数:13,代码来源:NeuralInputData.java

示例7: selectCourseCost

import java.util.ArrayList; //导入方法依赖的package包/类
private ArrayList<Double> selectCourseCost() {
    ArrayList<Double> coursePrice = new ArrayList<Double>();
    coursePrice.add(500D);
    coursePrice.add(600D);
    coursePrice.add(750D);
    coursePrice.add(800D);
    coursePrice.add(1100D);
    coursePrice.add(3, 2300D);
    coursePrice.add(1490D);
    coursePrice.set(4, 1500D);
    coursePrice.get(0);
    return coursePrice;

}
 
开发者ID:cyber-coders-j2017a,项目名称:modern.core.java.repo,代码行数:15,代码来源:Courses.java

示例8: testEquals_otherListWithDifferentElements

import java.util.ArrayList; //导入方法依赖的package包/类
@CollectionSize.Require(absent = CollectionSize.ZERO)
public void testEquals_otherListWithDifferentElements() {
  ArrayList<E> other = new ArrayList<E>(getSampleElements());
  other.set(other.size() / 2, getSubjectGenerator().samples().e3());
  assertFalse(
      "A List should not equal another List containing different elements.",
      getList().equals(other));
}
 
开发者ID:zugzug90,项目名称:guava-mock,代码行数:9,代码来源:ListEqualsTester.java

示例9: AttrCalculation

import java.util.ArrayList; //导入方法依赖的package包/类
private ArrayList<String> AttrCalculation(ArrayList<String> attrTemI){
    int randomID = attrTemI.size();
    int randomI = Integer.parseInt(attrTemI.get(randomID - 2));
    int value,bonuses,impairment;
    for (int i = 1;i < randomID -7;i++){
        value = Integer.parseInt(attrTemI.get(i));
        bonuses = random.nextInt(randomI + 1);
        impairment = random.nextInt(randomI + 1);
        value = value + bonuses - impairment;
        attrTemI.set(i,Integer.toString(value));
    }
    return attrTemI;
}
 
开发者ID:pokemonchw,项目名称:chiefproject,代码行数:14,代码来源:AttributeCreator.java

示例10: main

import java.util.ArrayList; //导入方法依赖的package包/类
public static void main(String[] args) {
    ArrayList<Integer> numbers2 = new ArrayList();
    for (int counter = 0 ; counter < 5 ; counter++) {
        numbers2.add(0, counter);
    }
    // 4, 3, 2, 1, 0

    ArrayList<Integer> numbers = new ArrayList();

    numbers.add(10);
    numbers.add(11);
    numbers.add(12);
    numbers.add(13);
    numbers.add(14);
    // 10, 11, 12, 13, 14

    numbers.add(0, 16); // 16, 10, 11, 12, 13, 14

    numbers.add(3, 20); // 16, 10, 11, 20, 12, 13, 14

    // Contains

    numbers.contains(10);

    int indexOfElement = numbers.indexOf(20);

    numbers.set(indexOfElement, 20 * 20);
    // 16, 10, 11, 400, 12, 13, 14
}
 
开发者ID:thelittlehawk,项目名称:CSIS280,代码行数:30,代码来源:Main.java

示例11: processPrivate

import java.util.ArrayList; //导入方法依赖的package包/类
/**
 * Just the run method
 * @param arraylist
 * @param threadPoolSize 
 */
private final void processPrivate(final ArrayList<Object> arraylist, final int threadPoolSize) {
    final ExecutorService executor = Executors.newFixedThreadPool(threadPoolSize);
    if(arraylist.size() >= threadPoolSize && arraylist.size() >= MINARRAYLISTSIZE) {
        final int steps = arraylist.size() / threadPoolSize;
        for(int i = 0; i < threadPoolSize; i++) {
            final int u = i;
            Runnable run = new Runnable() {
                
                @Override
                public void run() {
                    final int extra = ((u == threadPoolSize - 1) ? (steps * threadPoolSize) - arraylist.size() : 0);
                    for(int z = 0; z < steps + extra; z++) {
                        final int pos = (u * steps + z);
                        arraylist.set(pos, process(arraylist.get(pos)));
                    }
                }
                
            };
            executor.execute(run);
        }
        executor.shutdown();
        try {
            executor.awaitTermination(1, TimeUnit.DAYS);
        } catch (Exception ex) {
        }
    } else {
        for(int i = 0; i < arraylist.size(); i++) {
            arraylist.set(i, process(arraylist.get(i)));
        }
    }
}
 
开发者ID:Panzer1119,项目名称:JAddOn,代码行数:37,代码来源:ArrayListProcessor.java

示例12: calcBatch

import java.util.ArrayList; //导入方法依赖的package包/类
public ArrayList<Double> calcBatch(ArrayList<ArrayList<Double>> _input){
    ArrayList<Double> result = new ArrayList<>();
    for(int i=0;i<_input.size();i++){
        result.add(0.0);
        Double _outputBeforeActivation=0.0;
        for(int j=0;j<numberOfInputs;j++){
            _outputBeforeActivation+=(j==numberOfInputs?bias:_input.get(i).get(j))*weight.get(j);
        }
        result.set(i,activationFunction.calc(_outputBeforeActivation));
    }
    return result;
}
 
开发者ID:PacktPublishing,项目名称:Neural-Network-Programming-with-Java-SecondEdition,代码行数:13,代码来源:Neuron.java

示例13: main

import java.util.ArrayList; //导入方法依赖的package包/类
/**
 * Run java org.hsqldb.util.TestScripts --help.
 * For each script run, the connection will be closed or persisted
 * depending on whether "--ephConnId=x" or "--persistConnId=x" preceded
 * the file name (defaulting to closing).
 * So, by default, for each script file, a new connection will be made
 * and closed immediately after the script runs.
 */
public static void main(String[] argv) {

    if (argv.length > 0 && argv[0].equals("--help")) {
        System.err.println(SYNTAX_MSG);
        System.exit(2);
    }

    ArrayList scripts   = new ArrayList();
    ArrayList connIds   = new ArrayList();
    ArrayList retains   = new ArrayList();
    int       i         = -1;
    int       curscript = 0;

    // java.util.ArrayLists may contain null elements.
    connIds.add(null);
    retains.add(null);

    String newName = null;

    while (++i < argv.length) {
        if (argv[i].startsWith("--ephConnId=")) {
            newName = getIdName(argv[i]);

            if (newName == null
                    || connIds.set(connIds.size() - 1, getIdName(argv[i]))
                       != null) {
                System.err.println(SYNTAX_MSG);
                System.exit(2);
            }

            if (retains.set(retains.size() - 1, Boolean.FALSE) != null) {
                System.err.println(SYNTAX_MSG);
                System.exit(2);
            }
        } else if (argv[i].startsWith("--persistConnId=")) {
            newName = getIdName(argv[i]);

            if (newName == null
                    || connIds.set(connIds.size() - 1, newName) != null) {
                System.err.println(SYNTAX_MSG);
                System.exit(2);
            }

            if (retains.set(retains.size() - 1, Boolean.TRUE) != null) {
                System.err.println(SYNTAX_MSG);
                System.exit(2);
            }
        } else if (argv[i].startsWith("-")) {
            System.err.println(SYNTAX_MSG);
            System.exit(2);
        } else {
            scripts.add(argv[i]);
            connIds.add(null);
            retains.add(null);
        }
    }

    test(DEF_URL, DEF_USER, DEF_PASSWORD, DEF_DB,
         (String[]) scripts.toArray(new String[0]),
         (String[]) connIds.toArray(new String[0]),
         (Boolean[]) retains.toArray(new Boolean[0]));
}
 
开发者ID:tiweGH,项目名称:OpenDiabetes,代码行数:71,代码来源:TestScripts.java

示例14: process

import java.util.ArrayList; //导入方法依赖的package包/类
/**
 * Renames all the variables in this block and inserts appriopriate
 * phis in successor blocks.
 */
public void process() {
    /*
     * From Appel:
     *
     * Rename(n) =
     *   for each statement S in block n   // 'statement' in 'block'
     */

    block.forEachInsn(this);

    updateSuccessorPhis();

    // Delete all move insns in this block.
    ArrayList<SsaInsn> insns = block.getInsns();
    int szInsns = insns.size();

    for (int i = szInsns - 1; i >= 0 ; i--) {
        SsaInsn insn = insns.get(i);
        SsaInsn replaceInsn;

        replaceInsn = insnsToReplace.get(insn);

        if (replaceInsn != null) {
            insns.set(i, replaceInsn);
        } else if (insn.isNormalMoveInsn()
                && !movesToKeep.contains(insn)) {
            insns.remove(i);
        }
    }

    // Store the start states for our dom children.
    boolean first = true;
    for (SsaBasicBlock child : block.getDomChildren()) {
        if (child != block) {
            // Don't bother duplicating the array for the first child.
            RegisterSpec[] childStart = first ? currentMapping
                : dupArray(currentMapping);

            startsForBlocks[child.getIndex()] = childStart;
            first = false;
        }
    }

    // currentMapping is owned by a child now.
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:50,代码来源:SsaRenamer.java

示例15: getdCoreferencedText

import java.util.ArrayList; //导入方法依赖的package包/类
public static ArrayList<String> getdCoreferencedText(String text){
	Annotation document = new Annotation(text);
	pipeline.annotate(document);
	ArrayList<String> sentences = new ArrayList<String>();
	DocumentPreprocessor dp = new DocumentPreprocessor(
		new StringReader(text));
	ArrayList<List<HasWord>> processedText = new ArrayList<List<HasWord>>();
	for (List<HasWord> sentence : dp){
		processedText.add(sentence);
	}
	
	//用 representative mention 把 mention替换掉
	Map<Integer, CorefChain> graph = 
	document.get(CorefChainAnnotation.class);
	for (Map.Entry<Integer, CorefChain> entry : graph.entrySet()){
		CorefChain c = entry.getValue();
		
		CorefMention cm = c.getRepresentativeMention();
		for (Entry<IntPair, Set<CorefMention>> e : 
			c.getMentionMap().entrySet()){
			if (cm.endIndex - cm.startIndex >2){
				continue; //如果representative mention 词数大于2 就不换了
			}
			for(CorefMention mention : e.getValue()){
				perClusterUpdateSen(processedText,
						mention.sentNum,cm.sentNum,
					cm.startIndex,cm.endIndex,
					mention.startIndex,mention.endIndex);
			}
		}
	}
	
	for (List<HasWord> senlist : processedText){
		sentences.add("");
		for (HasWord word:senlist){
			if (!word.toString().equals("")){
				//System.out.print(word.toString()+" ");
				String str = sentences.
						get(sentences.size()-1) + word.toString().toLowerCase()+" ";
				sentences.set(sentences.size()-1, str);
			}
		}
		
		//System.out.println();
	}
	for (int i=0; i < sentences.size(); i++){
		String s = sentences.get(i);
		sentences.set(i, (""+s.charAt(0)).toUpperCase() + s.substring(1)) ;
	}
	return sentences;
}
 
开发者ID:cs-zyluo,项目名称:CausalNet,代码行数:52,代码来源:Coreferencer.java


注:本文中的java.util.ArrayList.set方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。