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


Java LinkedList.getLast方法代码示例

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


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

示例1: adjustEndGlyphs

import java.util.LinkedList; //导入方法依赖的package包/类
private void adjustEndGlyphs(LinkedList<GSLayoutGlyph> glyphs) {
    // Compress last none CRLF glyph if possible
    GSLayoutGlyph lastGlyph = glyphs.getLast();
    GSLayoutGlyph crlfGlyph = null;
    if (GSCharUtils.isNewline(lastGlyph.code()) && glyphs.size() > 1) {
        crlfGlyph = lastGlyph;
        glyphs.removeLast();
        lastGlyph = glyphs.peekLast();
    }
    if (GSCharUtils.shouldCompressEnd(lastGlyph) && GSCharUtils.canCompress(lastGlyph)) {
        lastGlyph.compressEnd = lastGlyph.size * builder.punctuationCompressRate;
    }
    if (lastGlyph.code() == ' ') {
        lastGlyph.compressEnd = lastGlyph.size;
    }
    if (crlfGlyph != null) {
        if (builder.vertical) {
            crlfGlyph.y = lastGlyph.getUsedEndSize();
        } else {
            crlfGlyph.x = lastGlyph.getUsedEndSize();
        }
        glyphs.addLast(crlfGlyph);
    }
}
 
开发者ID:geansea,项目名称:GSLayout,代码行数:25,代码来源:GSLayout.java

示例2: testLastElement

import java.util.LinkedList; //导入方法依赖的package包/类
/**
 * getLast returns next element, or throws NSEE if empty
 */
public void testLastElement() {
    LinkedList q = populatedQueue(SIZE);
    for (int i = SIZE - 1; i >= 0; --i) {
        assertEquals(i, q.getLast());
        assertEquals(i, q.pollLast());
    }
    try {
        q.getLast();
        shouldThrow();
    } catch (NoSuchElementException success) {}
    assertNull(q.peekLast());
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:16,代码来源:LinkedListTest.java

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

示例4: copySetListOfChildren

import java.util.LinkedList; //导入方法依赖的package包/类
@Override
public AbstractExpr copySetListOfChildren(LinkedList<AbstractExpr> listChildren)  throws JFCALCExpErrException, JSmartMathErrException {
    if (listChildren == null || listChildren.size() != 2) {
        throw new JSmartMathErrException(ERRORTYPES.ERROR_INVALID_ABSTRACTEXPR);			
    }
    AEBitwiseOpt aeReturn = new AEBitwiseOpt();
    aeReturn.copy(this);
    aeReturn.maeLeft = listChildren.getFirst();
    aeReturn.maeRight = listChildren.getLast();
    aeReturn.validateAbstractExpr();
    return aeReturn;
}
 
开发者ID:woshiwpa,项目名称:SmartMath,代码行数:13,代码来源:AEBitwiseOpt.java

示例5: copySetListOfChildren

import java.util.LinkedList; //导入方法依赖的package包/类
@Override
public AbstractExpr copySetListOfChildren(LinkedList<AbstractExpr> listChildren)  throws JFCALCExpErrException, JSmartMathErrException {
    if (listChildren == null || listChildren.size() != 2) {
        throw new JSmartMathErrException(ERRORTYPES.ERROR_INVALID_ABSTRACTEXPR);			
    }
    AEPowerOpt aeReturn = new AEPowerOpt();
    aeReturn.copy(this);
    aeReturn.maeLeft = listChildren.getFirst();
    aeReturn.maeRight = listChildren.getLast();
    aeReturn.validateAbstractExpr();
    return aeReturn;
}
 
开发者ID:woshiwpa,项目名称:SmartMath,代码行数:13,代码来源:AEPowerOpt.java

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

示例7: GSLayoutLine

import java.util.LinkedList; //导入方法依赖的package包/类
GSLayoutLine(CharSequence text, LinkedList<GSLayoutGlyph> glyphs, PointF origin, boolean vertical) {
    if (glyphs.size() > 0) {
        GSLayoutGlyph first = glyphs.getFirst();
        GSLayoutGlyph last = glyphs.getLast();
        this.text = text;
        start = first.start;
        end = last.end;
        this.glyphs = glyphs;
        originX = origin.x;
        originY = origin.y;
        ascent = GSLayoutHelper.getGlyphsMaxAscent(glyphs, vertical);
        descent = GSLayoutHelper.getGlyphsMaxDescent(glyphs, vertical);
        size = vertical ? last.getUsedRect().bottom : last.getUsedRect().right;
        this.vertical = vertical;
    }
}
 
开发者ID:geansea,项目名称:GSLayout,代码行数:17,代码来源:GSLayoutLine.java

示例8: traverseComponent

import java.util.LinkedList; //导入方法依赖的package包/类
@Override
protected void traverseComponent(byte nodeID, Graph graph) {

  LinkedList<Byte> toExploreQ = new LinkedList<Byte>();
  // start a component traversal
  status(STATUS_START_COMPONENT);
  // visit the node and update the seen nodes
  visit(nodeID);
  // queue the visited node for exploration of its neighbors
  toExploreQ.add(nodeID);
  // done when:
  // (1) all nodes seen OR
  // (2) no new nodes to explore in this connected component
  while (!seenAll() && !toExploreQ.isEmpty()) {
    // retrieve the next node to explore from the queue (DO NOT REMOVE!!!)
    byte explore = toExploreQ.getLast();
    // does the node we are exploring have an unseen neighbor?
    boolean unseenNeighbor = false;
    // visit the first unseen neighbor (if any) and enqueue it for traversal
    for (byte i = 0; i < graph.getOutDegree(explore); i++) {
      byte neighbor = graph.getOutNode(explore, i);
      if (unseenNeighbor(explore, neighbor)) {
        visit(neighbor);
        toExploreQ.add(neighbor);
        unseenNeighbor = true;
        // in DF, we follow the first unseen neighbor
        break;
      }
    }
    // dequeue a node only when all its neighbors are seen;
    // early dequeuing breaks backtracking of the DF traversal;
    if (!unseenNeighbor) {
      toExploreQ.removeLast();
    }
  }
  // this component has been visited
  status(STATUS_VISITED_COMPONENT);
}
 
开发者ID:etomica,项目名称:etomica,代码行数:39,代码来源:DepthFirst.java

示例9: doVerticalLayout

import java.util.LinkedList; //导入方法依赖的package包/类
private void doVerticalLayout() {
    LinkedList<GSLayoutLine> lines = new LinkedList<>();
    float fontSize = builder.getFontSize();
    int lineLocation = getStart();
    float maxHeight = 0;
    float lineRight = getWidth();
    while (lineLocation < getText().length()) {
        GSLayoutLine line = layoutLine(lineLocation);
        PointF origin = line.getOrigin();
        RectF lineRect = line.getUsedRect();
        origin.x = lineRight - lineRect.right;
        lineRight = origin.x + lineRect.left;
        line.setOrigin(origin);
        if (lineRight < 0) {
            break;
        }
        lines.add(line);
        lineLocation = line.getEnd();
        maxHeight = Math.max(maxHeight, lineRect.height());
        lineRight -= fontSize * builder.lineSpacing;
        if (GSCharUtils.isNewline(line.getLastGlyph().code())) {
            lineRight -= fontSize * builder.paragraphSpacing;
        }
    }
    if (lines.size() > 0) {
        GSLayoutLine last = lines.getLast();
        RectF lastRect = last.getUsedRect();
        end = last.getEnd();
        usedWidth = getWidth() - lastRect.left;
        usedHeight = maxHeight;
    }
    this.lines = lines;
}
 
开发者ID:geansea,项目名称:GSLayout,代码行数:34,代码来源:GSLayout.java

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

示例11: main

import java.util.LinkedList; //导入方法依赖的package包/类
public static void main(String[] args) 
{
	LinkedList dogs = new LinkedList();
	Dog dog1 = new Dog("aa", "bb");
	Dog dog2 = new Dog("cc", "dd");
	Dog dog3 = new Dog("ee", "ff");
	Dog dog4 = new Dog("gg", "hh");

	dogs.add(dog1);
	dogs.add(dog2);
	dogs.addFirst(dog3);
	dogs.addLast(dog4);

	Dog dogFirst = (Dog) dogs.getFirst();
	LOGGER.info("第一条狗狗的信息是{}", dogFirst.getName());

	Dog dogLast = (Dog) dogs.getLast();
	LOGGER.info("最后一条狗狗的信息是{}", dogLast.getName());

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

	for (Object element : dogs)
	{
		LOGGER.info(element);
	}
}
 
开发者ID:JAVA201708,项目名称:Homework,代码行数:28,代码来源:LinkedListTest.java

示例12: maybeGetLowerBound

import java.util.LinkedList; //导入方法依赖的package包/类
private static PsiType maybeGetLowerBound( PsiWildcardType type, TypeVarToTypeMap actualParamByVarName, boolean bKeepTypeVars, LinkedHashSet<PsiType> recursiveTypes )
{
  PsiType lower = type.getSuperBound();
  if( lower != PsiType.NULL && recursiveTypes.size() > 0 )
  {
    // This is a "super" (contravariant) wildcard

    LinkedList<PsiType> list = new LinkedList<>( recursiveTypes );
    PsiType enclType = list.getLast();
    if( isParameterizedType( enclType ) )
    {
      PsiType genType = getActualType( ((PsiClassType)enclType).rawType(), actualParamByVarName, bKeepTypeVars, recursiveTypes );
      if( LambdaUtil.isFunctionalType( genType ) )
      {
        // For functional interfaces we keep the lower bound as an upper bound so that blocks maintain contravariance wrt the single method's parameters
        return lower;
      }
    }
  }
  return null;
}
 
开发者ID:manifold-systems,项目名称:manifold-ij,代码行数:22,代码来源:TypeUtil.java

示例13: getShortestPathsIntern

import java.util.LinkedList; //导入方法依赖的package包/类
@Override
protected List<List<E>> getShortestPathsIntern(final V source,
		final V target, int k) {
	LinkedList<List<E>> found_paths = new LinkedList<List<E>>();
	PriorityQueue<WeightedPath> prioQ = new PriorityQueue<WeightedPath>();
	DijkstraShortestPath<V, E> blockedDijkstra;

	// Check if target is reachable from source.
	if (dijkstra.getDistance(source, target) == null)
		return found_paths;

	// Add Dijkstra solution, the first shortest path.
	found_paths.add(dijkstra.getPath(source, target));

	while (found_paths.size() < k) {
		List<E> curShortestPath = found_paths.getLast();

		int maxIndex = curShortestPath.size();

		// Split path into Head and NextEdge
		for (int i = 0; i < maxIndex; i++) {
			List<E> head = curShortestPath.subList(0, i /* excluded */);
			V deviation = head.isEmpty() ? source : graph.getDest(head
					.get(i - 1));

			// 1. Block edges.
			Graph<V, E> blocked = blockFilter(head, deviation, found_paths);

			// 2. Get shortest path in graph with blocked edges.
			blockedDijkstra = new DijkstraShortestPath<V, E>(blocked, nev);

			Number dist = blockedDijkstra.getDistance(deviation, target);
			if (dist == null)
				continue;

			List<E> tail = blockedDijkstra.getPath(deviation, target);

			// 3. Combine head and tail into new path.
			List<E> candidate = new ArrayList<E>(i + tail.size());
			candidate.addAll(head);
			candidate.addAll(tail);

			// Check if we already found this solution
			boolean duplicate = false;
			for (WeightedPath path : prioQ)
				if (ListUtils.isEqualList(path.getPath(), candidate)) {
					duplicate = true;
					break;
				}

			if (!duplicate)
				prioQ.add(new WeightedPath(candidate));
		}

		if (prioQ.isEmpty())
			break; // We have not found any new candidate!
		else
			found_paths.add(prioQ.poll().getPath());
	}

	return found_paths;
}
 
开发者ID:KeepTheBeats,项目名称:alevin-svn2,代码行数:63,代码来源:Yen.java

示例14: insertIntoDataCurves

import java.util.LinkedList; //导入方法依赖的package包/类
public void insertIntoDataCurves(LinkedList<LinkedDataCurve> listDataCurves, MultiLinkedPoint mlp, boolean bConnect)	{
	// assume dD1Value and dD2Value are not Nan nor Inf.
	double dD1Value = mlp.mpnt.getDim(mnMode);
	int nD2Dim = (mnMode == 2)?0:(mnMode == 1)?2:1;

	if (listDataCurves.size() == 0)	{
		// add a brand new linked data curve
		listDataCurves.add(new LinkedDataCurve(dD1Value, mlp));
	} else if (dD1Value < listDataCurves.get(0).mdBaseValue)	{
		listDataCurves.addFirst(new LinkedDataCurve(dD1Value, mlp));
	} else if (dD1Value > listDataCurves.getLast().mdBaseValue)	{
		listDataCurves.addLast(new LinkedDataCurve(dD1Value, mlp));
	} else	{
		int idxLeft = 0, idx = (listDataCurves.size() - 1)/2, idxRight = listDataCurves.size() - 1;
		while (idx != idxLeft)	{
			if (dD1Value < listDataCurves.get(idx).mdBaseValue)	{
				idxRight = idx;
				idx = (idxRight + idxLeft)/2;
			} else if (dD1Value > listDataCurves.get(idx).mdBaseValue)	{
				idxLeft = idx;
				idx = (idxRight + idxLeft)/2;
			} else	{	// find it.
				int index = insertIntoSortedList(listDataCurves.get(idx).mlistPnts, mlp, false, nD2Dim);
				if (index > 0 && bConnect)	{
					listDataCurves.get(idx).mlistPnts.get(index - 1).msetConnects.add(mlp);
					mlp.msetConnects.add(listDataCurves.get(idx).mlistPnts.get(index - 1));
				}
				if (index < listDataCurves.size() - 1 && bConnect)	{
					listDataCurves.get(idx).mlistPnts.get(index + 1).msetConnects.add(mlp);
					mlp.msetConnects.add(listDataCurves.get(idx).mlistPnts.get(index + 1));
				}
			}					
		}
		listDataCurves.add(idxLeft + 1, new LinkedDataCurve(dD1Value, mlp));
	}
}
 
开发者ID:woshiwpa,项目名称:CoreMathImgProc,代码行数:37,代码来源:DataSeriesGridSurface.java

示例15: main

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

	Dog ououDog = new Dog("欧欧");
	Dog yayaDog = new Dog("亚亚");
	Dog meimeiDog = new Dog("美美");
	Dog feifeiDog = new Dog("非非");

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

	LOGGER.info("共有{}条狗狗", dogs.size());
	LOGGER.info("分别是:");
	for (Object element : dogs)
	{
		LOGGER.info(element);
	}

	Dog dogFirst = (Dog)dogs.getFirst();
	LOGGER.info("第一条狗狗的昵称是{}", dogFirst.getName());

	Dog dogLast = (Dog)dogs.getLast();
	LOGGER.info("最后一条狗狗的昵称是{}", dogLast.getName());

	dogs.removeFirst();

	if (dogs.contains(feifeiDog))
	{
		LOGGER.info("非非还在集合中");
	}

	else
	{
		LOGGER.info("非非不在集合中");
	}

	dogs.removeLast();

	if (dogs.contains(meimeiDog))
	{
		LOGGER.info("美美还在集合中");
	}

	else
	{
		LOGGER.info("美美不在集合中");
	}
}
 
开发者ID:JAVA201708,项目名称:Homework,代码行数:53,代码来源:LinkedList01.java


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