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


Java LinkedList.isEmpty方法代码示例

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


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

示例1: processQueueMessages

import java.util.LinkedList; //导入方法依赖的package包/类
private void processQueueMessages() {
  LinkedList<BPServiceActorAction> duplicateQueue;
  synchronized (bpThreadQueue) {
    duplicateQueue = new LinkedList<BPServiceActorAction>(bpThreadQueue);
    bpThreadQueue.clear();
  }
  while (!duplicateQueue.isEmpty()) {
    BPServiceActorAction actionItem = duplicateQueue.remove();
    try {
      actionItem.reportTo(bpNamenode, bpRegistration);
    } catch (BPServiceActorActionException baae) {
      LOG.warn(baae.getMessage() + nnAddr , baae);
      // Adding it back to the queue if not present
      bpThreadEnqueue(actionItem);
    }
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:18,代码来源:BPServiceActor.java

示例2: 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;
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:25,代码来源:JSRInlinerAdapter.java

示例3: getNextCFEs

import java.util.LinkedList; //导入方法依赖的package包/类
/** @return the set of all next {@link ControlFlowElement} */
private Set<ControlFlowElement> getNextCFEs(NextEdgesProvider nextEdgesProvider, ControlFlowElement cfe,
		Node nextNode) {

	Objects.requireNonNull(cfe);
	Set<ControlFlowElement> nexts = new HashSet<>();

	LinkedList<ControlFlowEdge> allEdges = new LinkedList<>();
	List<ControlFlowEdge> nextEdges = nextEdgesProvider.getNextEdges(nextNode, ControlFlowType.NonDeadTypes);
	allEdges.addAll(nextEdges);

	while (!allEdges.isEmpty()) {
		ControlFlowEdge nextEdge = allEdges.removeFirst();
		nextNode = nextEdgesProvider.getNextNode(nextEdge);
		if (nextNode instanceof RepresentingNode) {
			ControlFlowElement succ = nextNode.getRepresentedControlFlowElement();
			nexts.add(succ);
		} else {
			nextEdges = nextEdgesProvider.getNextEdges(nextNode, ControlFlowType.NonDeadTypes);
			allEdges.addAll(nextEdges);
		}
	}

	return nexts;
}
 
开发者ID:eclipse,项目名称:n4js,代码行数:26,代码来源:SuccessorPredecessorAnalysis.java

示例4: dfs

import java.util.LinkedList; //导入方法依赖的package包/类
public void dfs(int start) {
	LinkedList<Vertex> q = new LinkedList<Vertex>();
	Vertex v = vertexList.get(start);
	visit(v);
	q.addFirst(v);
	while (!q.isEmpty()) {
		v = q.removeFirst();
		Edge n = v.next;
		while (n != null) {
			v = vertexList.get(n.toVertex);
			if (!v.visited) {
				visit(v);
				q.addFirst(v);
			}
			n = n.next;
		}
	}
	System.out.println("end");
}
 
开发者ID:code-squad,项目名称:blue-common,代码行数:20,代码来源:SimpleGraph.java

示例5: shrink

import java.util.LinkedList; //导入方法依赖的package包/类
/**
 * Drop queues which exceed its keepalive
 */
LinkedList<MessageKey> shrink() {
  LinkedList<MessageKey> result = new LinkedList<>();

    Iterator<Entry<MessageKey, SizeBoundedQueue>> iter;
    for (iter = keyToQueue.entrySet().iterator(); iter.hasNext(); ) {
      Entry<MessageKey, SizeBoundedQueue> entry = iter.next();
      MessageKey key = entry.getKey();
      SizeBoundedQueue q = entry.getValue();

      if (now() - key.lastAccessNanos() > pendingKeepaliveNanos) {
        if (q.count > 0) continue;
        iter.remove();
        result.add(key);
      }
    }
  if (logger.isDebugEnabled() && !result.isEmpty()) {
    logger.debug("Timeout queues removed, keys: {}", result);
  }
  return result;
}
 
开发者ID:tramchamploo,项目名称:buffer-slayer,代码行数:24,代码来源:QueueManager.java

示例6: registerComponent

import java.util.LinkedList; //导入方法依赖的package包/类
public void registerComponent ( final LinkedList<String> prefix, final ComponentFolder componentFolder, final Component component )
{
    logger.debug ( "Register - prefix: {}, componentFolder: {}, component: {}", prefix, componentFolder, component );

    // first get the name
    final String next = prefix.pop ();

    if ( prefix.isEmpty () )
    {
        add ( next, componentFolder, component );
    }
    else
    {
        // add another sub level
        ComponentNode node = this.nodes.get ( next );
        if ( node == null )
        {
            if ( this.components.containsKey ( next ) )
            {
                // blocked by component

                // remove all folders we might have created
                checkRemove ();
                // throw exception
                throw new IllegalStateException ( "Namespace blocked by other component" );
            }

            final FolderCommon folder = new FolderCommon ();
            this.folder.add ( next, folder, null );

            node = new ComponentNode ( this, folder );
            this.nodes.put ( next, node );
        }
        node.registerComponent ( prefix, componentFolder, component );
    }
}
 
开发者ID:eclipse,项目名称:neoscada,代码行数:37,代码来源:ComponentNode.java

示例7: processOptions

import java.util.LinkedList; //导入方法依赖的package包/类
@Override
protected void processOptions(LinkedList<String> args) throws IOException {
  name = StringUtils.popOptionWithArgument("-n", args);
  String en = StringUtils.popOptionWithArgument("-e", args);
  if (en != null) {
    try {
      encoding = enValueOfFunc.apply(StringUtils.toUpperCase(en));
    } catch (IllegalArgumentException e) {
      throw new IllegalArgumentException(
          "Invalid/unsupported encoding option specified: " + en);
    }
    Preconditions.checkArgument(encoding != null,
        "Invalid/unsupported encoding option specified: " + en);
  }

  boolean r = StringUtils.popOption("-R", args);
  setRecursive(r);
  dump = StringUtils.popOption("-d", args);

  if (!dump && name == null) {
    throw new HadoopIllegalArgumentException(
        "Must specify '-n name' or '-d' option.");
  }

  if (args.isEmpty()) {
    throw new HadoopIllegalArgumentException("<path> is missing.");
  }
  if (args.size() > 1) {
    throw new HadoopIllegalArgumentException("Too many arguments.");
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:32,代码来源:XAttrCommands.java

示例8: 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;
}
 
开发者ID:JianpingZeng,项目名称:xcc,代码行数:46,代码来源:ConstantPropagation.java

示例9: processOptions

import java.util.LinkedList; //导入方法依赖的package包/类
@Override
protected void processOptions(LinkedList<String> args) throws IOException {
  CommandFormat cf = new CommandFormat(0, Integer.MAX_VALUE, "R");
  cf.parse(args);
  setRecursive(cf.getOpt("R"));
  if (args.isEmpty()) {
    throw new HadoopIllegalArgumentException("<path> is missing");
  }
  if (args.size() > 1) {
    throw new HadoopIllegalArgumentException("Too many arguments");
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:13,代码来源:AclCommands.java

示例10: change

import java.util.LinkedList; //导入方法依赖的package包/类
/**
 * Changes the last Gui in the player's stack (if any) with the one specified in the arguments, this could be thought as backGui + openGui
 *
 * @param player the player
 * @param gui    the Gui that will be appended instead of the last one
 */
public void change(Player player, Gui gui) {
    if (called) return;
    called = true;
    try {
        LinkedList<Gui> g = getOrCreate(player);
        Gui oldGui;
        if (!g.isEmpty())
            oldGui = g.pop();
        else oldGui = null;

        GuiChangeEvent e = new GuiChangeEvent(player, gui, oldGui);
        Bukkit.getPluginManager().callEvent(e);
        if (e.isCancelled()) {
            if (oldGui != null)
                g.push(oldGui);
            return;
        }
        if (oldGui != null)
            oldGui.onClose(player);
        g.push(gui);
        gui.onOpen(player);
        gui.show(player);
    } finally {
        called = false;
    }
}
 
开发者ID:upperlevel,项目名称:uppercore,代码行数:33,代码来源:GuiManager.java

示例11: cvtPath2NameSpace

import java.util.LinkedList; //导入方法依赖的package包/类
public static String[] cvtPath2NameSpace(String strPath)	{
	int i;
	for (i = 0; i < strPath.length(); i ++)	{
		if (strPath.substring(i, i + 1).equals(MFPFileManagerActivity.STRING_PATH_DIV) == false)	{
			break;
		}
	}
	strPath = strPath.substring(i);
	String[] strarray = strPath.split(MFPFileManagerActivity.STRING_PATH_DIV + "+");
	LinkedList<String> listNameSpace = new LinkedList<String>();
	for (i = 0; i < strarray.length; i ++)	{
		if (strarray[i].equals(".."))	{
			if (listNameSpace.isEmpty())	{
				// this means it is not a valid path inside root folder.
				return null;
			} else	{
				listNameSpace.removeLast();
			}
		} else if (strarray[i].equals(".") == false)	{
			listNameSpace.addLast(strarray[i]);
		}
	}
	String[] strarrayNameSpace = new String[listNameSpace.size()];
	int nSize = listNameSpace.size();
	for (i = 0; i < nSize; i ++)	{
		strarrayNameSpace[i] = listNameSpace.remove();
	}
	return strarrayNameSpace;
}
 
开发者ID:woshiwpa,项目名称:SmartMath,代码行数:30,代码来源:MFPFileManagerActivity.java

示例12: processOptions

import java.util.LinkedList; //导入方法依赖的package包/类
@Override
protected void processOptions(LinkedList<String> args) throws IOException {
  cf.parse(args);
  setRecursive(cf.getOpt("R"));
  // Mix of remove and modify acl flags are not allowed
  boolean bothRemoveOptions = cf.getOpt("b") && cf.getOpt("k");
  boolean bothModifyOptions = cf.getOpt("m") && cf.getOpt("x");
  boolean oneRemoveOption = cf.getOpt("b") || cf.getOpt("k");
  boolean oneModifyOption = cf.getOpt("m") || cf.getOpt("x");
  boolean setOption = cf.getOpt("-set");
  if ((bothRemoveOptions || bothModifyOptions)
      || (oneRemoveOption && oneModifyOption)
      || (setOption && (oneRemoveOption || oneModifyOption))) {
    throw new HadoopIllegalArgumentException(
        "Specified flags contains both remove and modify flags");
  }

  // Only -m, -x and --set expects <acl_spec>
  if (oneModifyOption || setOption) {
    if (args.size() < 2) {
      throw new HadoopIllegalArgumentException("<acl_spec> is missing");
    }
    aclEntries = AclEntry.parseAclSpec(args.removeFirst(), !cf.getOpt("x"));
  }

  if (args.isEmpty()) {
    throw new HadoopIllegalArgumentException("<path> is missing");
  }
  if (args.size() > 1) {
    throw new HadoopIllegalArgumentException("Too many arguments");
  }

  // In recursive mode, save a separate list of just the access ACL entries.
  // Only directories may have a default ACL.  When a recursive operation
  // encounters a file under the specified path, it must pass only the
  // access ACL entries.
  if (isRecursive() && (oneModifyOption || setOption)) {
    accessAclEntries = Lists.newArrayList();
    for (AclEntry entry: aclEntries) {
      if (entry.getScope() == AclEntryScope.ACCESS) {
        accessAclEntries.add(entry);
      }
    }
  }
}
 
开发者ID:nucypher,项目名称:hadoop-oss,代码行数:46,代码来源:AclCommands.java

示例13: set

import java.util.LinkedList; //导入方法依赖的package包/类
@SuppressWarnings("unchecked")
static void set(Object object, LinkedList<String> path, @Nullable Object newValue)
{
    String last = path.removeLast();
    Object preLast;
    if (path.isEmpty())
    {
        preLast = object;
    }
    else
    {
        preLast = get(object, path);
    }

    Validate.notNull(preLast);

    try
    {
        if (preLast instanceof Config)
        {
            ((Config) preLast).set(last, newValue);
        }
        else if (preLast instanceof Map)
        {
            ((Map<Object, Object>) preLast).put(last, newValue);
        }
        else if (preLast instanceof List)
        {
            List<Object> list = (List<Object>) preLast;
            int size = list.size();
            int index = Integer.parseInt(last);
            if (index == size)
            {
                list.add(newValue);
            }
            else if (index > size)
            {
                while (index > size++)
                {
                    list.add(null);
                }
                list.add(newValue);
            }
            else
            {
                list.set(index, newValue);
            }
        }
        else
        {
            Class<?> type = preLast.getClass();
            CacheKey cacheKey = new CacheKey(type, last);
            ReflectedProperty<?> property = propertyCache.computeIfAbsent(cacheKey, k -> DioriteReflectionUtils.getReflectedProperty(last, type));
            property.set(preLast, newValue);
        }
    }
    catch (Exception e)
    {
        throw new IllegalStateException("Can't find property: " + last + " (" + path + ") in: " + preLast, e);
    }
}
 
开发者ID:GotoFinal,项目名称:diorite-configs-java8,代码行数:62,代码来源:NestedNodesHelper.java

示例14: execute

import java.util.LinkedList; //导入方法依赖的package包/类
public void execute(GuildMessageReceivedEvent e, String query) {

        final AudioHandler player = JukeBot.getPlayer(e.getGuild().getAudioManager());
        final LinkedList<AudioTrack> queue = player.getQueue();

        if (queue.isEmpty()) {
            e.getChannel().sendMessage(new EmbedBuilder()
                    .setColor(JukeBot.embedColour)
                    .setTitle("No songs queued")
                    .setDescription("Use `" + Database.getPrefix(e.getGuild().getIdLong()) + "now` to view the current track.")
                    .build()
            ).queue();
            return;
        }

        final String queueDuration = Helpers.fTime(queue.stream().map(AudioTrack::getDuration).reduce(0L, (a, b) -> a + b));
        final StringBuilder fQueue = new StringBuilder();

        final int maxPages = (int) Math.ceil((double) queue.size() / 10);
        int page = Helpers.parseNumber(query, 1);

        if (page < 1)
            page = 1;

        if (page > maxPages)
            page = maxPages;

        int begin = (page - 1) * 10;
        int end = (begin + 10) > queue.size() ? queue.size() : (begin + 10);

        for (int i = begin; i < end; i++) {
            final AudioTrack track = queue.get(i);
            fQueue.append("`")
                    .append(i + 1)
                    .append(".` **[")
                    .append(track.getInfo().title)
                    .append("](")
                    .append(track.getInfo().uri)
                    .append(")** <@")
                    .append(track.getUserData())
                    .append(">\n");
        }

        e.getChannel().sendMessage(new EmbedBuilder()
                .setColor(JukeBot.embedColour)
                .setTitle("Queue (" + queue.size() + " songs, " + queueDuration + ")")
                .setDescription(fQueue.toString().trim())
                .setFooter("Viewing page " + (page) + "/" + (maxPages), null)
                .build()
        ).queue();

    }
 
开发者ID:Devoxin,项目名称:JukeBot,代码行数:53,代码来源:Queue.java

示例15: normalize

import java.util.LinkedList; //导入方法依赖的package包/类
private List<UriEncoded> normalize(Iterator<UriEncoded> segments)
{
    LinkedList<UriEncoded> pathSegments = new LinkedList<>();
    int count = 0;
    int backSteps = 0;
    boolean isAbsolute = false;
    boolean endWithEmptySegment = false;
    boolean singleDot = false;
    while (segments.hasNext())
    {
        UriEncoded segment = segments.next();

        if (IdempotentEncoded.EMPTY.equals(segment))
        {
            if (count == 0)
            {
                // this is an absolute Path, it starts with a "/"
                isAbsolute = true;
            }
            else
            {
                // an empty segment has been added, which means we add an empty segment if this is the last segment
                endWithEmptySegment = true;
            }
        }
        else if (IdempotentEncoded.CURRENT.equals(segment))
        {
            // insert a dot if the path is empty and relative (not absolute), otherwise just append a "/"
            if (pathSegments.isEmpty() && !isAbsolute)
            {
                singleDot = true;
            }
            else
            {
                endWithEmptySegment = true;
            }
        }
        else if (IdempotentEncoded.PARENT.equals(segment))
        {
            // go back in the hierarchy
            if (backSteps > 0)
            {
                // we have segments that we can remove
                pathSegments.removeLast();
                backSteps -= 1;
            }
            else if (!isAbsolute)
            {
                // no segments to remove
                pathSegments.addLast(segment);
            }
            // when going back in the hierarchy we always append a "/"
            endWithEmptySegment = true;
            // also we only append a "." if no other segment is left
            singleDot = pathSegments.isEmpty() && !isAbsolute;
        }
        else
        {
            pathSegments.addLast(segment);
            backSteps += 1;
            endWithEmptySegment = false;
            singleDot = false;
        }
        count += 1;
    }
    if (isAbsolute)
    {
        pathSegments.addFirst(IdempotentEncoded.EMPTY);
    }
    if (singleDot)
    {
        pathSegments.addLast(IdempotentEncoded.CURRENT);
        pathSegments.addLast(IdempotentEncoded.EMPTY);
    }
    else if (endWithEmptySegment && (pathSegments.size() <= 1 || !IdempotentEncoded.EMPTY.equals(pathSegments.getLast())))
    {
        pathSegments.addLast(IdempotentEncoded.EMPTY);
    }

    return pathSegments;
}
 
开发者ID:dmfs,项目名称:uri-toolkit,代码行数:82,代码来源:Extended.java


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