本文整理汇总了Java中java.util.LinkedList.removeFirst方法的典型用法代码示例。如果您正苦于以下问题:Java LinkedList.removeFirst方法的具体用法?Java LinkedList.removeFirst怎么用?Java LinkedList.removeFirst使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.LinkedList
的用法示例。
在下文中一共展示了LinkedList.removeFirst方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: allTestsFiltered
import java.util.LinkedList; //导入方法依赖的package包/类
private boolean allTestsFiltered(Runner runner, List<Filter> filters) {
LinkedList<Description> queue = new LinkedList<Description>();
queue.add(runner.getDescription());
while (!queue.isEmpty()) {
Description description = queue.removeFirst();
queue.addAll(description.getChildren());
boolean run = true;
for (Filter filter : filters) {
if (!filter.shouldRun(description)) {
run = false;
break;
}
}
if (run) {
return false;
}
}
return true;
}
示例2: invokes
import java.util.LinkedList; //导入方法依赖的package包/类
/**
* loops
*
* @param beInvokeObjectRoot
* @param methodNames
* @return
*/
public static Object invokes(Object beInvokeObjectRoot, LinkedList<String> methodNames,
LinkedList<Class<?>[]> paramTypes, LinkedList<Object[]> params) {
if (null == beInvokeObjectRoot || null == methodNames) {
return null;
}
if (methodNames.isEmpty()) {
return beInvokeObjectRoot;
}
Class<?>[] firstParamTypes = null;
Object[] firstParams = null;
if (null != paramTypes && null != params) {
firstParamTypes = paramTypes.getFirst();
firstParams = params.getFirst();
paramTypes.removeFirst();
params.removeFirst();
}
Object beInvokeObject = invoke(beInvokeObjectRoot.getClass().getName(), beInvokeObjectRoot,
methodNames.getFirst(), firstParamTypes, firstParams);
methodNames.removeFirst();
return invokes(beInvokeObject, methodNames, paramTypes, params);
}
示例3: parseSendValue
import java.util.LinkedList; //导入方法依赖的package包/类
private void parseSendValue (final int trackIndex, final int sendIndex, final LinkedList<String> parts, final Object value)
{
final AbstractTrackBankProxy tb = this.model.getCurrentTrackBank ();
if (!(tb instanceof TrackBankProxy))
return;
final double numValue = value instanceof Number ? ((Number) value).doubleValue () : -1;
final String p = parts.removeFirst ();
switch (p)
{
case "volume":
if (parts.isEmpty ())
((TrackBankProxy) tb).setSend (trackIndex, sendIndex, numValue);
else if ("indicate".equals (parts.get (0)))
((TrackBankProxy) tb).setSendIndication (trackIndex, sendIndex, numValue > 0);
break;
default:
this.host.println ("Unhandled Send Parameter value: " + p);
break;
}
}
示例4: emitCode
import java.util.LinkedList; //导入方法依赖的package包/类
/**
* Creates the new instructions, inlining each instantiation of each
* subroutine until the code is fully elaborated.
*/
private void emitCode() {
LinkedList<Instantiation> worklist = new LinkedList<Instantiation>();
// Create an instantiation of the "root" subroutine, which is just the
// main routine
worklist.add(new Instantiation(null, mainSubroutine));
// Emit instantiations of each subroutine we encounter, including the
// main subroutine
InsnList newInstructions = new InsnList();
List<TryCatchBlockNode> newTryCatchBlocks = new ArrayList<TryCatchBlockNode>();
List<LocalVariableNode> newLocalVariables = new ArrayList<LocalVariableNode>();
while (!worklist.isEmpty()) {
Instantiation inst = worklist.removeFirst();
emitSubroutine(inst, worklist, newInstructions, newTryCatchBlocks,
newLocalVariables);
}
instructions = newInstructions;
tryCatchBlocks = newTryCatchBlocks;
localVariables = newLocalVariables;
}
示例5: addToTaskLog
import java.util.LinkedList; //导入方法依赖的package包/类
public synchronized void addToTaskLog(List<Serializable> log)
{
@SuppressWarnings("unchecked")
LinkedList<Serializable> existingLog = (LinkedList<Serializable>) stateMap.get(KEY_LOG);
if( existingLog == null )
{
existingLog = Lists.newLinkedList();
stateMap.put(KEY_LOG, existingLog);
}
Iterator<Serializable> iter = log.iterator();
while( iter.hasNext() )
{
Serializable logMsg = iter.next();
if( existingLog.size() >= MAX_LOGS )
{
logOffset++;
existingLog.removeFirst();
}
existingLog.add(logMsg);
}
}
示例6: sendRaw
import java.util.LinkedList; //导入方法依赖的package包/类
private void sendRaw(int index, Object message) {
Reaction selectedReaction = null;
Object[] args = null;
synchronized (this) {
final LinkedList<Object> writing = writes[index];
if (writing == null) {
throw new IndexOutOfBoundsException();
}
writing.addLast(message);
mask |= 1L << index;
final Reaction[] reactions = reactionsPerChannel[index];
for (Reaction reaction : reactions) {
if ((reaction.mask & mask) == reaction.mask) {
final int[] indices = reaction.indices;
args = new Object[indices.length];
for (int i = 0; i < indices.length; ++i) {
final int readIndex = indices[i];
final LinkedList<Object> reading = writes[readIndex];
args[i] = reading.removeFirst();
if (reading.isEmpty()) {
mask &= ~(1L << readIndex);
}
}
selectedReaction = reaction;
break;
}
}
}
if (selectedReaction != null) {
selectedReaction.dispatch(this, args);
}
}
示例7: popPrefixMapping
import java.util.LinkedList; //导入方法依赖的package包/类
public void popPrefixMapping(String prefix) {
LinkedList stack = (LinkedList) xmlPrefixMapper.get(prefix);
if (stack == null || stack.size() == 0) {
// XXX throw new Exception("XXX");
}
stack.removeFirst();
}
示例8: 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();
}
}
示例9: popPrefixMapping
import java.util.LinkedList; //导入方法依赖的package包/类
public void popPrefixMapping(String prefix) {
LinkedList<String> stack = xmlPrefixMapper.get(prefix);
if (stack == null || stack.size() == 0) {
// XXX throw new Exception("XXX");
}
stack.removeFirst();
}
示例10: expandEventQueueCapacity
import java.util.LinkedList; //导入方法依赖的package包/类
/**
* Expands the event queue capacity, or truncates if capacity is lower than
* current capacity. Then only the newest entries are kept
* @param self self reference
* @param newCapacity new capacity
*/
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
public static void expandEventQueueCapacity(final Object self, final Object newCapacity) {
final LinkedList<RuntimeEvent<?>> q = getEventQueue(self);
final int nc = JSType.toInt32(newCapacity);
while (q.size() > nc) {
q.removeFirst();
}
setEventQueueCapacity(self, nc);
}
示例11: traverseEntity
import java.util.LinkedList; //导入方法依赖的package包/类
private Collection<NameSpaceContainer> traverseEntity(final NamespaceKey root) throws NamespaceException {
final LinkedList<NameSpaceContainer> toBeTraversed = new LinkedList<>(listEntity(root));
final LinkedList<NameSpaceContainer> visited = new LinkedList<>();
while (!toBeTraversed.isEmpty()) {
final NameSpaceContainer container = toBeTraversed.removeFirst();
if (NamespaceUtils.isListable(container.getType())) {
toBeTraversed.addAll(listEntity(new NamespaceKey(container.getFullPathList())));
}
visited.add(container);
}
return visited;
}
示例12: runOnFunction
import java.util.LinkedList; //导入方法依赖的package包/类
/**
* Performs constant propagation backend.transform upon given method.
*
* @param f A method where Optimization performed.
* @return Whether execution of backend.transform is successful.
*/
@Override
public boolean runOnFunction(Function f)
{
LinkedList<Instruction> worklist = new LinkedList<>();
// initializes the worklist to all of the instructions ready to
// process
f.getBasicBlockList().forEach(bb->
{
bb.getInstList().forEach(worklist::add);
});
boolean changed = false;
while (!worklist.isEmpty())
{
Instruction inst = worklist.removeFirst();
// ignores it if no other instruction use it
if (!inst.isUseEmpty())
{
Constant val = ConstantFolder.constantFoldInstruction(inst);
if (val != null)
{
// performs constant propagation
for (Use u : inst.usesList)
worklist.addLast((Instruction) u.getUser());
// constant folding and strength reduction
inst.replaceAllUsesWith(val);
worklist.removeFirst();
inst.eraseFromParent();
// marks the changed flag
changed = true;
++numsInstKilled;
}
}
}
return changed;
}
示例13: getLogcat
import java.util.LinkedList; //导入方法依赖的package包/类
@VisibleForTesting
protected List<String> getLogcat() throws IOException, InterruptedException {
// Grab the last lines of the logcat output, with a generous buffer to compensate for any
// microdumps that might be in the logcat output, since microdumps are stripped in the
// extraction code. Note that the repeated check of the process exit value is to account for
// the fact that the process might not finish immediately. And, it's not appropriate to
// call p.waitFor(), because this call will block *forever* if the process's output buffer
// fills up.
Process p = Runtime.getRuntime().exec("logcat -d");
BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
LinkedList<String> rawLogcat = new LinkedList<>();
Integer exitValue = null;
try {
while (exitValue == null) {
String logLn;
while ((logLn = reader.readLine()) != null) {
rawLogcat.add(logLn);
if (rawLogcat.size() > LOGCAT_SIZE * 4) {
rawLogcat.removeFirst();
}
}
try {
exitValue = p.exitValue();
} catch (IllegalThreadStateException itse) {
Thread.sleep(HALF_SECOND);
}
}
} finally {
reader.close();
}
if (exitValue != 0) {
String msg = "Logcat failed: " + exitValue;
Log.w(TAG, msg);
throw new IOException(msg);
}
return trimLogcat(rawLogcat, LOGCAT_SIZE);
}
示例14: addRuntimeEvent
import java.util.LinkedList; //导入方法依赖的package包/类
/**
* Add a runtime event to the runtime event queue. The queue has a fixed
* size {@link RuntimeEvent#RUNTIME_EVENT_QUEUE_SIZE} and the oldest
* entry will be thrown out of the queue is about to overflow
* @param self self reference
* @param event event to add
*/
@Function(attributes = Attribute.NOT_ENUMERABLE, where = Where.CONSTRUCTOR)
public static void addRuntimeEvent(final Object self, final Object event) {
final LinkedList<RuntimeEvent<?>> q = getEventQueue(self);
final int cap = (Integer)getEventQueueCapacity(self);
while (q.size() >= cap) {
q.removeFirst();
}
q.addLast(getEvent(event));
}
示例15: recordBrokerStats
import java.util.LinkedList; //导入方法依赖的package包/类
/**
* Update the broker stats. Note that a broker may continue to send brokerStats that contains
* failure info after the kafka process fails.
*
* @param brokerStats the broker stats
*/
public synchronized void recordBrokerStats(BrokerStats brokerStats) {
try {
int brokerId = brokerStats.getId();
if (!brokerStatsMap.containsKey(brokerId)) {
brokerStatsMap.put(brokerId, new LinkedList<>());
}
LinkedList<BrokerStats> brokerStatsList = brokerStatsMap.get(brokerId);
if (brokerStatsList.size() == MAX_NUM_STATS) {
brokerStatsList.removeFirst();
}
brokerStatsList.addLast(brokerStats);
if (!brokerStats.getHasFailure()) {
// only record brokerstat when there is no failure on that broker.
if (!brokers.containsKey(brokerId)) {
brokers.put(brokerId, new KafkaBroker(clusterConfig, brokerId));
}
KafkaBroker broker = brokers.get(brokerId);
broker.update(brokerStats);
}
if (brokerStats.getLeaderReplicas() != null) {
for (AvroTopicPartition atp : brokerStats.getLeaderReplicas()) {
String topic = atp.getTopic();
TopicPartition tp = new TopicPartition(topic, atp.getPartition());
topics.add(topic);
if (!topicPartitions.containsKey(topic)) {
topicPartitions.put(topic, new HashSet<>());
}
topicPartitions.get(topic).add(tp);
}
}
} catch (Exception e) {
LOG.error("Failed to read broker stats : {}", brokerStats, e);
}
}