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


Java LinkedList.set方法代码示例

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


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

示例1: populatePredicates

import java.util.LinkedList; //导入方法依赖的package包/类
/**
 * input query = field:abcAND(field<bcdOR(field:defANDfield>=efg))
 * return field:abc,field<bcd,field:def,field>=efg,AND,OR,AND
 * @param root 
 * @param query
 * @param predicates 
 * @return 
 * @return
 */
private Predicate populatePredicates(Root<T> root, String query)
{
	if(StringUtils.countOccurrencesOf(query, Conjunctions.SP.toString()) == StringUtils.countOccurrencesOf(query, Conjunctions.EP.toString())) {
		LinkedList<String> postfix = createPostfixExpression(query);
		boolean hasSingleSearchField = postfix.size() == 1;  
		
		Map<String, Predicate> predicateMap = new LinkedHashMap<>();
		
		for (int i = 0; i < postfix.size(); i++)
		{
			String attr = postfix.get(i);
			if(Conjunctions.isConjunction(attr)) {
				
				String rightOperand = postfix.get(i-1);
				String leftOperand = postfix.get(i-2);
				
				String key = rightOperand + attr + leftOperand;
				
				Predicate rightPredicate = (predicateMap.containsKey(rightOperand))? predicateMap.get(rightOperand) : buildPredicate(root, new SearchField(rightOperand)); 
				
				Predicate leftPredicate = (predicateMap.containsKey(leftOperand))? predicateMap.get(leftOperand) : buildPredicate(root, new SearchField(leftOperand));
				
				postfix.set(i-2, key);
				postfix.remove(i);
				postfix.remove(i-1);
				
				//reset loop
				i=0;
				
				List<Predicate> combinedPredicates = new ArrayList<>();
				combinedPredicates.add(leftPredicate);
				combinedPredicates.add(rightPredicate);
				
				Predicate combinedPredicate = buildPredicateWithOperator(root, Conjunctions.getEnum(attr), combinedPredicates);
				predicateMap.put(key, combinedPredicate);
			}
		}
		
		if(hasSingleSearchField) {
			SearchField field = new SearchField(postfix.get(0));
			predicateMap.put(postfix.get(0), buildPredicate(root, field));
		}
		
		return (Predicate) predicateMap.values().toArray()[predicateMap.size()-1];
	} else {
		throw new RuntimeException("MALFORMED.QUERY");
	}
}
 
开发者ID:tairmansd,项目名称:CriteriaBuilder,代码行数:58,代码来源:CriteriaServiceImpl.java

示例2: addPrinEntry

import java.util.LinkedList; //导入方法依赖的package包/类
/**
 * Add a Principal entry to an existing PolicyEntry at the specified index.
 * A Principal entry consists of a class, and name.
 *
 * If the principal already exists, it is not added again.
 */
boolean addPrinEntry(PolicyEntry pe,
                    PolicyParser.PrincipalEntry newPrin,
                    int index) {

    // first add the principal to the Policy Parser entry
    PolicyParser.GrantEntry grantEntry = pe.getGrantEntry();
    if (grantEntry.contains(newPrin) == true)
        return false;

    LinkedList<PolicyParser.PrincipalEntry> prinList =
                                            grantEntry.principals;
    if (index != -1)
        prinList.set(index, newPrin);
    else
        prinList.add(newPrin);

    modified = true;
    return true;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:26,代码来源:PolicyTool.java

示例3: transferThroughList

import java.util.LinkedList; //导入方法依赖的package包/类
private String transferThroughList(String in, int index) {
    LinkedList<String> list = new LinkedList<String>();
    list.add(System.getenv("")); // taints the list
    list.clear(); // makes the list safe again
    list.add(1, "xx");
    list.addFirst(in); // can taint the list
    list.addLast("yy");
    list.push(in);
    return list.element() + list.get(index) + list.getFirst() + list.getLast()
            + list.peek() + list.peekFirst() + list.peekLast() + list.poll()
            + list.pollFirst() + list.pollLast() + list.pop() + list.remove()
            + list.remove(index) + list.removeFirst() + list.removeLast()
            + list.set(index, "safe") + list.toString();
}
 
开发者ID:blackarbiter,项目名称:Android_Code_Arbiter,代码行数:15,代码来源:CommandInjection.java

示例4: main

import java.util.LinkedList; //导入方法依赖的package包/类
public static void main(String[] args) {

		// Cria LinkedList e adiciona 2 contas.
		LinkedList<Conta> ll = new LinkedList<Conta>();
		
		ll.add(new Conta(new Cliente("Falula"), 1));
		ll.add(new Conta(new Cliente("Bolula"), 2));
		System.out.println(ll + ", tamanho = " + ll.size());

		// Insere novo cliente no inicio e fim da LinkedList.
		ll.addFirst(new Conta(new Cliente("Zelula"), 3));
		ll.addLast(new Conta(new Cliente("Solula"), 4));

		System.out.println(ll);
		System.out.println(ll.getFirst() + ", " + ll.getLast());
		System.out.println(ll.get(1) + ", " + ll.get(2));

		// Remove o primero e o ultimo
		ll.removeFirst();
		ll.removeLast();
		System.out.println(ll);

		// Adiciona outro cliente na posicao 2 da lista
		ll.add(1, new Conta(new Cliente("Zoiudinha"), 5));
		System.out.println(ll);

		// Substitui objeto no indice 2
		ll.set(2, new Conta(new Cliente("Zoiudinha"), 5));
		System.out.println(ll);
	}
 
开发者ID:alexferreiradev,项目名称:3way_laboratorios,代码行数:31,代码来源:TesteLinkedList.java

示例5: sortXYList

import java.util.LinkedList; //导入方法依赖的package包/类
/**
 * 根据与中心点的距离由近到远进行冒泡排序。
 *
 * @param endIdx  起始位置。
 * @param listTxt 待排序的数组。
 */
private void sortXYList(LinkedList<CircleView> listTxt, int endIdx) {
    for (int i = 0; i < endIdx; i++) {
        for (int k = i + 1; k < endIdx; k++) {
            if (((int[]) listTxt.get(k).getTag())[IDX_DIS_Y] < ((int[]) listTxt
                    .get(i).getTag())[IDX_DIS_Y]) {
                CircleView iTmp = listTxt.get(i);
                CircleView kTmp = listTxt.get(k);
                listTxt.set(i, kTmp);
                listTxt.set(k, iTmp);
            }
        }
    }
}
 
开发者ID:lpy19930103,项目名称:MinimalismJotter,代码行数:20,代码来源:KeywordsFlow.java

示例6: createBdaJob

import java.util.LinkedList; //导入方法依赖的package包/类
/**
 * Create a EML job in database
 * @param bdaJobName
 * @param bdaJobId
 * @param graph
 * @param account
 * @param desc
 * @return
 * @throws Exception
 */
private BdaJob createBdaJob(String bdaJobName, String bdaJobId,
		OozieGraph graph, String account, String desc) throws Exception {

	if (bdaJobName == null)
		bdaJobName = "Not Specified";
	if (bdaJobId == null)
		bdaJobId = GenerateSequenceUtil.generateSequenceNo() + "-bda";

	// Create the corresponding bda job in the database
	BdaJob job = new BdaJob();
	job.setJobName(bdaJobName);
	job.setJobId(bdaJobId);
	job.setGraphxml(graph.toXML());
	job.setAccount(account);
	job.setDesc(desc);
	job.setLastSubmitTime(TimeUtils.getTime());

	//Modify the programs in the graph xml of the bda job to latest
	OozieGraph tmpGraph = OozieGraphXMLParser.parse(graph.toXML());
	LinkedList<OozieProgramNode> proNodes =  tmpGraph.getProgramNodes();
	for(int i=0 ; i < proNodes.size() ; i++)
	{
		OozieProgramNode proNode = proNodes.get(i);
		proNode.setOozJobId("latest");
		proNode.setWorkPath("${appPath}/" + proNode.getId() + "/");
		proNodes.set(i, proNode	);
	}
	job.setGraphxml(tmpGraph.toXML());
	SecureDao.insert(job);

	job.setOozieGraph(graph);
	return job;
}
 
开发者ID:ICT-BDA,项目名称:EasyML,代码行数:44,代码来源:JobServiceImpl.java

示例7: updateBdaJob

import java.util.LinkedList; //导入方法依赖的package包/类
/**
 * Update a EML job in the database
 * @param bdaJobName
 * @param bdaJobId
 * @param graph
 * @param account
 * @param desc
 * @return Bda job object
 * @throws Exception
 */
private BdaJob updateBdaJob(String bdaJobName, String bdaJobId,
		OozieGraph graph, String account, String desc) throws Exception {

	if (bdaJobName == null)
		bdaJobName = "Not Specified";
	BdaJob job = new BdaJob();
	job.setJobName(bdaJobName);
	job.setJobId(bdaJobId);
	job.setGraphxml(graph.toXML());
	job.setAccount(account);
	job.setDesc(desc);
	job.setLastSubmitTime(TimeUtils.getTime());

	String[] cond = {"job_id"};
	String[] sets = {"job_name", "graphxml", "account", "description",
	"last_submit_time"};
	
	//Modify the programs in the graph xml of the bda job to latest
    OozieGraph tmpGraph = OozieGraphXMLParser.parse(graph.toXML());
    LinkedList<OozieProgramNode> proNodes =  tmpGraph.getProgramNodes();
    for(int i=0 ; i < proNodes.size() ; i++)
    {
      OozieProgramNode proNode = proNodes.get(i);
      proNode.setOozJobId("latest");
      proNodes.set(i, proNode  );
    }
    job.setGraphxml(tmpGraph.toXML());
    
	SecureDao.update(job, sets, cond);
	job.setOozieGraph(graph);
	return job;
}
 
开发者ID:ICT-BDA,项目名称:EasyML,代码行数:43,代码来源:JobServiceImpl.java

示例8: replaceExprPattern

import java.util.LinkedList; //导入方法依赖的package包/类
public static AbstractExpr replaceExprPattern(AbstractExpr aeExpression, LinkedList<PatternExprUnitMap> listFromToMap, boolean bExpr2Pattern) throws JFCALCExpErrException, JSmartMathErrException	{
	for (int idx = 0; idx < listFromToMap.size(); idx ++)	{
		if (bExpr2Pattern && aeExpression.isEqual(listFromToMap.get(idx).maeExprUnit))	{
			return listFromToMap.get(idx).maePatternUnit;
		} else if ((!bExpr2Pattern) && aeExpression.isEqual(listFromToMap.get(idx).maePatternUnit)) {
			return listFromToMap.get(idx).maeExprUnit;
		}
	}
	LinkedList<AbstractExpr> listReplacedChildren = new LinkedList<AbstractExpr>();
       aeExpression = aeExpression.replaceChildren(listFromToMap, bExpr2Pattern, listReplacedChildren);
	LinkedList<AbstractExpr> listChildren = new LinkedList<AbstractExpr>();
       listChildren.addAll(aeExpression.getListOfChildren());
	for (int idx = 0; idx < listChildren.size(); idx ++)	{
		boolean bIsReplacedChild = false;
		for (int idx1 = 0; idx1 < listReplacedChildren.size(); idx1 ++)	{
			if (listChildren.get(idx) == listReplacedChildren.get(idx1))	{
				bIsReplacedChild = true;
				break;
			}
		}
		if (bIsReplacedChild == false)	{
			// this child hasn't been replaced
               listChildren.set(idx, replaceExprPattern(listChildren.get(idx),listFromToMap, bExpr2Pattern));
		}
	}
       aeExpression = aeExpression.copySetListOfChildren(listChildren);
	return aeExpression;
}
 
开发者ID:woshiwpa,项目名称:SmartMath,代码行数:29,代码来源:PatternManager.java

示例9: integRecurChildren

import java.util.LinkedList; //导入方法依赖的package包/类
public AbstractExpr integRecurChildren(AbstractExpr aeIntegrated, LinkedList<LinkedList<Variable>> lVarNameSpaces)
		throws JFCALCExpErrException, JSmartMathErrException, InterruptedException	{
       LinkedList<AbstractExpr> listOfChildren = new LinkedList<AbstractExpr>();
       listOfChildren.addAll(aeIntegrated.getListOfChildren());
	// first go through all the non-function children to ensure all the grand-children and grand-grand-children etc are processed.
	for (int idx = 0; idx < listOfChildren.size(); idx ++) {
		if (!(listOfChildren.get(idx) instanceof AEFunction)
				|| !((AEFunction)listOfChildren.get(idx)).mstrFuncName.equalsIgnoreCase("integrate")) {
			// only if it is not integrate function we recursively process its children.
			listOfChildren.set(idx, integRecurChildren(listOfChildren.get(idx), lVarNameSpaces));
		}
	}
       aeIntegrated = aeIntegrated.copySetListOfChildren(listOfChildren);
       
	LinkedList<PatternExprUnitMap> listFromToMap = new LinkedList<PatternExprUnitMap>();
	ExprEvaluator exprEvaluator = new ExprEvaluator(lVarNameSpaces);
	for (int idx = 0; idx < listOfChildren.size(); idx ++) {
		if (listOfChildren.get(idx) instanceof AEFunction
				&& ((AEFunction)listOfChildren.get(idx)).mstrFuncName.equalsIgnoreCase("integrate")) {
			// should only be integrate function. If throw an undefined variable exception, then there must be an error in the expression.
			DataClass datumChildReturn = exprEvaluator.evaluateExpression(listOfChildren.get(idx).output(), new CurPos());
			AbstractExpr aeChildReturn = null;
			if (datumChildReturn.getDataType() == DATATYPES.DATUM_STRING) {
				// seems to return an expression. Note that the returned expression should not include any pseudo const in the parameter.
				aeChildReturn = ExprAnalyzer.analyseExpression(datumChildReturn.getStringValue(), new CurPos(), new LinkedList<Variable>());
			} else if (datumChildReturn.isNumericalData(false)) {
				// return a value
				aeChildReturn = new AEConst(datumChildReturn);
			} else {
				throw new JSmartMathErrException(ERRORTYPES.ERROR_CANNOT_SOLVE_CALCULATION);
			}
			listFromToMap.add(new PatternExprUnitMap(listOfChildren.get(idx), aeChildReturn));
		}
	}
	if (listFromToMap.size() > 0) {
		aeIntegrated = aeIntegrated.replaceChildren(listFromToMap, true, new LinkedList<AbstractExpr>());
	}
       return aeIntegrated;
}
 
开发者ID:woshiwpa,项目名称:SmartMath,代码行数:40,代码来源:PatternManager.java

示例10: comparePages

import java.util.LinkedList; //导入方法依赖的package包/类
/**
    * (non-Javadoc)
    *
    * @see org.lamsfoundation.lams.tool.wiki.service.IWikiService#comparePages(String,String)
    */
   @Override
   public String comparePages(String old, String current) {
String oldArray[] = old.replaceAll("[\\t\\n\\r]", "").split("<div>");
String currentArray[] = current.replaceAll("[\\t\\n\\r]", "").split("<div>");

Diff diff = new Diff(oldArray, currentArray);
List<Difference> diffOut = diff.diff();

LinkedList<String> result = new LinkedList<String>(Arrays.asList(currentArray));

int resultOffset = 0;
for (Difference difference : diffOut) {
    if (difference.getDeletedEnd() == -1) {
	// Added
	for (int i = difference.getAddedStart(); i <= difference.getAddedEnd(); i++) {
	    result.set(i + resultOffset,
		    "<div style='background-color:#99FFCC; width: 90%;'> " + currentArray[i]);
	}
    } else if (difference.getAddedEnd() == -1) {
	// Deleted
	for (int i = difference.getDeletedStart(); i <= difference.getDeletedEnd(); i++) {
	    if (result.size() > (i + resultOffset)) {
		result.add(i + resultOffset,
			"<div style='background-color:#FF9999; width: 90%;'>" + oldArray[i]);
	    } else {
		result.add("<div style='background-color:#FF9999; width: 90%;'>" + oldArray[i]);
	    }
	    resultOffset++;
	}
    } else {

	// Replaced
	for (int i = difference.getAddedStart(); i <= difference.getAddedEnd(); i++) {
	    result.set(i + resultOffset,
		    "<div style='background-color:#99FFCC; width: 90%;'>" + currentArray[i]);
	}
	for (int i = difference.getDeletedStart(); i <= difference.getDeletedEnd(); i++) {
	    if (result.size() > (i + resultOffset)) {
		result.add(i + resultOffset,
			"<div style='background-color:#FF9999; width: 90%;'>" + oldArray[i]);
	    } else {
		result.add("<div style='background-color:#FF9999; width: 90%;'>" + oldArray[i]);
	    }
	    resultOffset++;
	}
    }
}

StringBuffer retBuf = new StringBuffer();
for (String line : result) {
    line = line.replaceAll("[//r][//n][//t]", "");

    // fix up lines that dont have the div tag on them
    if (!line.startsWith("<div")) {
	retBuf.append("<div>");
    }

    retBuf.append(line);

    // fix up lines that dont have the div tag on them
    if (!line.contains("</div>")) {
	retBuf.append("</div>");
    }
}
WikiService.logger.debug("Result:");
WikiService.logger.debug(retBuf);
return retBuf.toString();
   }
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:74,代码来源:WikiService.java

示例11: evaluateAExpr

import java.util.LinkedList; //导入方法依赖的package包/类
@Override
public AbstractExpr evaluateAExpr(
		LinkedList<UnknownVariable> lUnknownVars,
		LinkedList<LinkedList<Variable>> lVarNameSpaces)
		throws InterruptedException, JSmartMathErrException, JFCALCExpErrException {
	validateAbstractExpr(); // still needs to do some basic validation.
       LinkedList<AbstractExpr> listNewChildren = new LinkedList<AbstractExpr>();
       LinkedList<CalculateOperator> listNewOpts = new LinkedList<CalculateOperator>();
       DataClass datumZero = new DataClass(DATATYPES.DATUM_DOUBLE, MFPNumeric.ZERO);
       for (int idx0 = 0; idx0 < mlistChildren.size(); idx0 ++)	{
           DataClass datumLast = datumZero;
           int idx = idx0;
           AbstractExpr aexpr2Add = null;
           for (; idx < mlistChildren.size(); idx ++)	{
               AbstractExpr aexpr = mlistChildren.get(idx).evaluateAExpr(lUnknownVars, lVarNameSpaces);
               if (aexpr instanceof AEConst) {
                   if (mlistOpts.get(idx).getOperatorType() == OPERATORTYPES.OPERATOR_ADD
                           || mlistOpts.get(idx).getOperatorType() == OPERATORTYPES.OPERATOR_POSSIGN) {
                       datumLast = ExprEvaluator.evaluateTwoOperandCell(datumLast, new CalculateOperator(OPERATORTYPES.OPERATOR_ADD, 2), ((AEConst)aexpr).getDataClassRef());
                   } else {
                       datumLast = ExprEvaluator.evaluateTwoOperandCell(datumLast, new CalculateOperator(OPERATORTYPES.OPERATOR_SUBTRACT, 2), ((AEConst)aexpr).getDataClassRef());
                   }
               } else {
                   aexpr2Add = aexpr;
                   break;
               }
           }
           if (!datumLast.isEqual(datumZero)) {
               listNewOpts.add(new CalculateOperator(OPERATORTYPES.OPERATOR_ADD, 2));
               listNewChildren.add(new AEConst(datumLast));
           }
           if (aexpr2Add != null) {
               if (mlistOpts.get(idx).getOperatorType() == OPERATORTYPES.OPERATOR_ADD
                           || mlistOpts.get(idx).getOperatorType() == OPERATORTYPES.OPERATOR_POSSIGN) {
                   listNewOpts.add(new CalculateOperator(OPERATORTYPES.OPERATOR_ADD, 2));
               } else {
                   listNewOpts.add(new CalculateOperator(OPERATORTYPES.OPERATOR_SUBTRACT, 2));
               }
               listNewChildren.add(aexpr2Add);
           }
           idx0 = idx;
       }
       if (listNewChildren.size() == 0) {
           // this means returns zero
           return new AEConst(datumZero);
       }
       if (listNewOpts.getFirst().getOperatorType() == OPERATORTYPES.OPERATOR_ADD
               || listNewOpts.getFirst().getOperatorType() == OPERATORTYPES.OPERATOR_POSSIGN) {
           listNewOpts.set(0, new CalculateOperator(OPERATORTYPES.OPERATOR_POSSIGN, 1, true));
       } else {
           listNewOpts.set(0, new CalculateOperator(OPERATORTYPES.OPERATOR_NEGSIGN, 1, true));
       }
       if (listNewChildren.size() == 1) {
           if (listNewOpts.getFirst().getOperatorType() == OPERATORTYPES.OPERATOR_NEGSIGN) {
               // if there is only one child and it is negsign, the child cannot be aeConst.
               return new AEPosNegOpt(listNewChildren, listNewOpts);
           } else {
               return listNewChildren.getFirst();
           }
       } else {
           return new AEPosNegOpt(listNewChildren, listNewOpts);
       }
   }
 
开发者ID:woshiwpa,项目名称:SmartMath,代码行数:64,代码来源:AEPosNegOpt.java


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