當前位置: 首頁>>代碼示例>>Java>>正文


Java LinkedList.getFirst方法代碼示例

本文整理匯總了Java中java.util.LinkedList.getFirst方法的典型用法代碼示例。如果您正苦於以下問題:Java LinkedList.getFirst方法的具體用法?Java LinkedList.getFirst怎麽用?Java LinkedList.getFirst使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在java.util.LinkedList的用法示例。


在下文中一共展示了LinkedList.getFirst方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: push

import java.util.LinkedList; //導入方法依賴的package包/類
/**
 * FIFO to calculate the correct purchase amount.
 * purchases are added to the head of a queue. sales are deducted from the tail of purchases.
 *
 * @param order the order to process into the queue
 * @param fifo the queue
 */
private void push(OrderData order, LinkedList<OrderData>fifo) {
    if(order.getCategory().equals(PurchaseCategory.PURCHASE.code)) {
        fifo.addLast(order);
    } else {
        double deduct = order.getAmount();
        do {
            if( fifo.isEmpty() ) {deduct = 0; continue; }

            OrderData first = fifo.getFirst();
            if(first.getAmount() <= deduct) {
                deduct-=first.getAmount();
                fifo.removeFirst();
            }
            else {
                first.setAmount(first.getAmount()-deduct);
                deduct = 0;
            }
        } while(deduct > 0);
    }
}
 
開發者ID:asciimo71,項目名稱:hashnest,代碼行數:28,代碼來源:StatisticService.java

示例2: findSendablePacket

import java.util.LinkedList; //導入方法依賴的package包/類
private Packet findSendablePacket(LinkedList<Packet> outgoingQueue,
                                  boolean clientTunneledAuthenticationInProgress) {
    synchronized (outgoingQueue) {
        if (outgoingQueue.isEmpty()) {
            return null;
        }
        if (outgoingQueue.getFirst().bb != null // If we've already starting sending the first packet, we better finish
            || !clientTunneledAuthenticationInProgress) {
            return outgoingQueue.getFirst();
        }

        // Since client's authentication with server is in progress,
        // send only the null-header packet queued by primeConnection().
        // This packet must be sent so that the SASL authentication process
        // can proceed, but all other packets should wait until
        // SASL authentication completes.
        ListIterator<Packet> iter = outgoingQueue.listIterator();
        while (iter.hasNext()) {
            Packet p = iter.next();
            if (p.requestHeader == null) {
                // We've found the priming-packet. Move it to the beginning of the queue.
                iter.remove();
                outgoingQueue.add(0, p);
                return p;
            } else {
                // Non-priming packet: defer it until later, leaving it in the queue
                // until authentication completes.
                if (LOG.isDebugEnabled()) {
                    LOG.debug("deferring non-priming packet: " + p +
                            "until SASL authentication completes.");
                }
            }
        }
        // no sendable packet found.
        return null;
    }
}
 
開發者ID:l294265421,項目名稱:ZooKeeper,代碼行數:38,代碼來源:ClientCnxnSocketNIO.java

示例3: validate

import java.util.LinkedList; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@Override
public void validate() throws ValidationException {
	final LinkedList<ValidationException> failures = new LinkedList<>();
	forEach(p -> {
		try {
			p.validate(getValue(p));
		} catch (ValidationException e) {
			failures.add(e);
		}
	});
	if (!failures.isEmpty()) {
		throw (failures.size() == 1) ? failures.getFirst()
				: new ValidationException(failures.toArray(new ValidationException[failures.size()]));
	}
}
 
開發者ID:holon-platform,項目名稱:holon-core,代碼行數:17,代碼來源:AbstractPropertyBox.java

示例4: getMethodForExactParamTypes

import java.util.LinkedList; //導入方法依賴的package包/類
@Override
SingleDynamicMethod getMethodForExactParamTypes(final String paramTypes) {
    final LinkedList<SingleDynamicMethod> matchingMethods = new LinkedList<>();
    for(final SingleDynamicMethod method: methods) {
        final SingleDynamicMethod matchingMethod = method.getMethodForExactParamTypes(paramTypes);
        if(matchingMethod != null) {
            matchingMethods.add(matchingMethod);
        }
    }
    switch(matchingMethods.size()) {
        case 0: {
            return null;
        }
        case 1: {
            return matchingMethods.getFirst();
        }
        default: {
            throw new BootstrapMethodError("Can't choose among " + matchingMethods + " for argument types "
                    + paramTypes + " for method " + getName());
        }
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:23,代碼來源:OverloadedDynamicMethod.java

示例5: computeStatsData

import java.util.LinkedList; //導入方法依賴的package包/類
private static StatsSnapshot computeStatsData(final LinkedList<CallSnapshot> csList) {
    StatsSnapshot statsSnapshot = new StatsSnapshot();
    synchronized (csList) {
        double tps = 0;
        double avgpt = 0;
        long sum = 0;
        if (!csList.isEmpty()) {
            CallSnapshot first = csList.getFirst();
            CallSnapshot last = csList.getLast();
            sum = last.getValue() - first.getValue();
            tps = (sum * 1000.0d) / (last.getTimestamp() - first.getTimestamp());

            long timesDiff = last.getTimes() - first.getTimes();
            if (timesDiff > 0) {
                avgpt = (sum * 1.0d) / timesDiff;
            }
        }

        statsSnapshot.setSum(sum);
        statsSnapshot.setTps(tps);
        statsSnapshot.setAvgpt(avgpt);
    }

    return statsSnapshot;
}
 
開發者ID:lirenzuo,項目名稱:rocketmq-rocketmq-all-4.1.0-incubating,代碼行數:26,代碼來源:StatsItem.java

示例6: 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

示例7: deleteDeadBlock

import java.util.LinkedList; //導入方法依賴的package包/類
/**
 * Delete the specified dead basic block.
 * @param bb    A dead basic block to be removed from CFG.
 */
private void deleteDeadBlock(BasicBlock bb)
{
    LinkedList<Instruction> list = bb.getInstList();
    while (!list.isEmpty())
    {
        Instruction inst = list.getFirst();
        list.removeFirst();
        if (inst == null)
            continue;
        if (inst.hasOneUses())
            inst.replaceAllUsesWith(UndefValue.get(inst.getType()));
        inst.eraseFromParent();
    }
}
 
開發者ID:JianpingZeng,項目名稱:xcc,代碼行數:19,代碼來源:ConditionalPropagate.java

示例8: computeStatsData

import java.util.LinkedList; //導入方法依賴的package包/類
private static StatsSnapshot computeStatsData(final LinkedList<CallSnapshot> csList) {
    StatsSnapshot statsSnapshot = new StatsSnapshot();
    synchronized (csList) {
        double tps = 0;
        double avgpt = 0;
        long sum = 0;
        if (!csList.isEmpty()) {
            CallSnapshot first = csList.getFirst();
            CallSnapshot last = csList.getLast();
            sum = last.getValue() - first.getValue();
            //這裏sum乘以1000的原因是,getTimestamp的單位是ms
            tps = (sum * 1000.0d) / (last.getTimestamp() - first.getTimestamp());

            long timesDiff = last.getTimes() - first.getTimes();
            if (timesDiff > 0) { //times增加訪問內,value平均增加了多少
                avgpt = (sum * 1.0d) / (timesDiff);
            }
        }

        statsSnapshot.setSum(sum);
        statsSnapshot.setTps(tps);
        statsSnapshot.setAvgpt(avgpt);
    }

    return statsSnapshot;
}
 
開發者ID:y123456yz,項目名稱:reading-and-annotate-rocketmq-3.4.6,代碼行數:27,代碼來源:StatsItem.java

示例9: processArguments

import java.util.LinkedList; //導入方法依賴的package包/類
@Override
protected void processArguments(LinkedList<PathData> items)
    throws IOException {
  super.processArguments(items);
  if (numErrors != 0) { // check for error collecting paths
    return;
  }
  Preconditions.checkArgument(items.size() == 1);
  PathData sroot = items.getFirst();
  sroot.fs.renameSnapshot(sroot.path, oldName, newName);
}
 
開發者ID:nucypher,項目名稱:hadoop-oss,代碼行數:12,代碼來源:SnapshotCommands.java

示例10: close

import java.util.LinkedList; //導入方法依賴的package包/類
@Override
public void close() throws IOException {
	if (!tenantDataSources.isEmpty()) {
		LinkedList<Throwable> exceptions = new LinkedList<>();

		for (DataSource dataSource : tenantDataSources.values()) {
			if (dataSource instanceof Closeable) {
				try {
					((Closeable) dataSource).close();
				} catch (Exception e) {
					exceptions.add(e);
				}
			}
		}

		if (!exceptions.isEmpty()) {
			if (exceptions.size() == 1) {
				throw new IOException(exceptions.getFirst());
			}
			StringBuilder sb = new StringBuilder();
			sb.append("Multiple exceptions detected when closing tenant DataSources: ");
			for (Throwable exception : exceptions) {
				sb.append(ExceptionUtils.getRootCauseMessage(exception));
				sb.append(";");
			}
			throw new IOException(sb.toString());
		}
	}
}
 
開發者ID:holon-platform,項目名稱:holon-jdbc,代碼行數:30,代碼來源:DefaultMultiTenantDataSource.java

示例11: validateInputs

import java.util.LinkedList; //導入方法依賴的package包/類
/**
 * Validate all the {@link Input}s.
 * @throws ValidationException If one or more input is not valid
 */
private void validateInputs() throws ValidationException {

	LinkedList<ValidationException> failures = new LinkedList<>();

	// get all property configurations
	List<PropertyConfiguration<?>> configurations = propertySet.stream().map(p -> _propertyConfiguration(p))
			.filter(cfg -> !cfg.isReadOnly() && !cfg.isHidden() && cfg.getInput().isPresent())
			.collect(Collectors.toList());

	if (configurations != null) {

		if (isStopValidationAtFirstFailure()) {
			// reset validation status
			configurations.forEach(c -> resetValidationStatus(c.getInput().get(), c.getProperty()));
		}

		for (PropertyConfiguration<?> configuration : configurations) {
			try {
				validateProperty(configuration);
			} catch (ValidationException e) {
				failures.add(e);

				if (isStopValidationAtFirstFailure()) {
					// break if stop validation at first failure
					break;
				}
			}
		}
	}

	// collect validation exceptions, if any
	if (!failures.isEmpty()) {
		if (failures.size() == 1) {
			throw failures.getFirst();
		} else {
			throw new ValidationException(failures.toArray(new ValidationException[0]));
		}
	}
}
 
開發者ID:holon-platform,項目名稱:holon-vaadin,代碼行數:44,代碼來源:DefaultPropertyInputGroup.java

示例12: getURI

import java.util.LinkedList; //導入方法依賴的package包/類
public String getURI(String prefix) {

        String uri = null;

        LinkedList<String> stack = xmlPrefixMapper.get(prefix);
        if (stack == null || stack.size() == 0) {
            uri = jspPrefixMapper.get(prefix);
        } else {
            uri = stack.getFirst();
        }

        return uri;
    }
 
開發者ID:liaokailin,項目名稱:tomcat7,代碼行數:14,代碼來源:PageInfo.java

示例13: copySetListOfChildren

import java.util.LinkedList; //導入方法依賴的package包/類
@Override
public AbstractExpr copySetListOfChildren(LinkedList<AbstractExpr> listChildren)  throws JFCALCExpErrException, JSmartMathErrException {
    if (listChildren == null || listChildren.size() != 1) {
        throw new JSmartMathErrException(ERRORTYPES.ERROR_INVALID_ABSTRACTEXPR);			
    }
    AEOnOffUnaryOpt aeReturn = new AEOnOffUnaryOpt();
    aeReturn.copy(this);
    aeReturn.maexprChild = listChildren.getFirst();
    aeReturn.validateAbstractExpr();
    return aeReturn;
}
 
開發者ID:woshiwpa,項目名稱:SmartMath,代碼行數:12,代碼來源:AEOnOffUnaryOpt.java

示例14: main

import java.util.LinkedList; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
public static void main(String[] args) 
{
	Dog ououDog = new Dog("歐歐", "雪娜瑞");
	Dog yayaDog = new Dog("亞亞", "拉布拉多");
	Dog feifeiDog = new Dog("菲菲", "拉布拉多");
	Dog meimeiDog = new Dog("美美", "雪娜瑞");

	LinkedList dogs = new LinkedList();
	dogs.add(ououDog);
	dogs.add(yayaDog);
	dogs.addLast(meimeiDog);
	dogs.addFirst(feifeiDog);

	Dog firstDog = (Dog) dogs.getFirst();
	LOGGER.info("第一條狗狗的信息是:{}", firstDog);

	Dog lastDog = (Dog) dogs.getLast();
	LOGGER.info("最後一條狗狗的信息是:{}", lastDog);

	dogs.removeFirst();
	dogs.removeLast();

	LOGGER.info("剩下的狗狗是:");
	for (Object element : dogs) 
	{
		LOGGER.info(element);
	}

}
 
開發者ID:JAVA201708,項目名稱:Homework,代碼行數:31,代碼來源:Collection01.java

示例15: getPath

import java.util.LinkedList; //導入方法依賴的package包/類
private LinkedList<? extends Tree> getPath(final int startOffset) {
    final LinkedList<Tree> path = new LinkedList<Tree>();

    // When right at the token end move to previous token; otherwise move to the token that "contains" the offset
    if (ts.move(startOffset) == 0 && startOffset > 0 || !ts.moveNext()) {
        ts.movePrevious();
    }
    final int offset = (ts.token().id() == JavaTokenId.IDENTIFIER
            || ts.token().id().primaryCategory().startsWith("keyword") || //NOI18N
            ts.token().id().primaryCategory().startsWith("string") || //NOI18N
            ts.token().id().primaryCategory().equals("literal")) //NOI18N
            ? ts.offset() : startOffset;

    new ErrorAwareTreeScanner<Void, Void>() {

        @Override
        public Void scan(Tree node, Void p) {
            if (node != null) {
                if (getStartPosition(node) < offset && getEndPosition(node) >= offset) {
                    super.scan(node, p);
                    if (node.getKind() != Tree.Kind.ERRONEOUS || !path.isEmpty()) {
                        path.add(node);
                    }
                }
            }
            return null;
        }
    }.scan(parsedTree, null);

    if (path.isEmpty() || path.getFirst() == parsedTree || getEndPosition(path.getFirst()) > offset) {
        return path;
    }

    if (!path.isEmpty() && ts.move(offset) == 0) {
        if (ts.movePrevious()) {
            switch (ts.token().id()) {
                case RPAREN:
                    if (!EnumSet.of(Kind.ENHANCED_FOR_LOOP, Kind.FOR_LOOP, Kind.IF, Kind.WHILE_LOOP, Kind.DO_WHILE_LOOP,
                            Kind.TYPE_CAST, Kind.SYNCHRONIZED).contains(path.getFirst().getKind())) {
                        path.removeFirst();
                    }
                    break;
                case GTGTGT:
                case GTGT:
                case GT:
                    if (EnumSet.of(Kind.MEMBER_SELECT, Kind.CLASS, Kind.GREATER_THAN).contains(path.getFirst().getKind())) {
                        break;
                    }
                case SEMICOLON:
                    if (path.getFirst().getKind() == Kind.FOR_LOOP
                            && ts.offset() <= getStartPosition(((ForLoopTree)path.getFirst()).getUpdate().get(0))) {
                        break;
                    }
                case RBRACE:
                    path.removeFirst();
                    switch (path.getFirst().getKind()) {
                        case CATCH:
                            path.removeFirst();
                        case METHOD:
                        case FOR_LOOP:
                        case ENHANCED_FOR_LOOP:
                        case IF:
                        case SYNCHRONIZED:
                        case WHILE_LOOP:
                        case TRY:
                            path.removeFirst();
                    }
                    break;
            }
        }
    }

    return path;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:75,代碼來源:Reindenter.java


注:本文中的java.util.LinkedList.getFirst方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。