当前位置: 首页>>代码示例>>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;未经允许,请勿转载。