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


Java LinkedList类代码示例

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


LinkedList类属于java.util包,在下文中一共展示了LinkedList类的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: diff_levenshtein

import java.util.LinkedList; //导入依赖的package包/类
/**
 * Compute the Levenshtein distance; the number of inserted, deleted or
 * substituted characters.
 * @param diffs LinkedList of Diff objects.
 * @return Number of changes.
 */
public int diff_levenshtein(LinkedList<Diff> diffs) {
	int levenshtein = 0;
	int insertions = 0;
	int deletions = 0;
	for (Diff aDiff : diffs) {
		switch (aDiff.operation) {
			case INSERT:
				insertions += aDiff.text.length();
				break;
			case DELETE:
				deletions += aDiff.text.length();
				break;
			case EQUAL:
				// A deletion and an insertion is one substitution.
				levenshtein += Math.max(insertions, deletions);
				insertions = 0;
				deletions = 0;
				break;
		}
	}
	levenshtein += Math.max(insertions, deletions);
	return levenshtein;
}
 
开发者ID:phoenixctms,项目名称:ctsms,代码行数:30,代码来源:diff_match_patch.java

示例3: getWorkflows

import java.util.LinkedList; //导入依赖的package包/类
@Override
public List<WorkflowInstance> getWorkflows(WorkflowInstanceQuery workflowInstanceQuery, int maxItems, int skipCount)
{
    LinkedList<WorkflowInstance> results = new LinkedList<WorkflowInstance>();
    if (Boolean.FALSE.equals(workflowInstanceQuery.getActive()) == false)
    {
        //Add active. 
        results.addAll(getWorkflowsInternal(workflowInstanceQuery, true, maxItems, skipCount));
    }
    if (Boolean.TRUE.equals(workflowInstanceQuery.getActive()) == false)
    {
        //Add complete
        results.addAll(getWorkflowsInternal(workflowInstanceQuery, false, maxItems, skipCount));
    }
    
    return results;
}
 
开发者ID:Alfresco,项目名称:alfresco-repository,代码行数:18,代码来源:ActivitiWorkflowEngine.java

示例4: listCases

import java.util.LinkedList; //导入依赖的package包/类
@DataProvider(name="listProvider", parallel=true)
public static Object[][] listCases() {
    final List<Object[]> cases = new LinkedList<>();
    cases.add(new Object[] { Collections.emptyList() });
    cases.add(new Object[] { new ArrayList<>() });
    cases.add(new Object[] { new LinkedList<>() });
    cases.add(new Object[] { new Vector<>() });
    cases.add(new Object[] { new Stack<>() });
    cases.add(new Object[] { new CopyOnWriteArrayList<>() });
    cases.add(new Object[] { Arrays.asList() });

    List<Integer> l = Arrays.asList(42);
    cases.add(new Object[] { new ArrayList<>(l) });
    cases.add(new Object[] { new LinkedList<>(l) });
    cases.add(new Object[] { new Vector<>(l) });
    Stack<Integer> s = new Stack<>(); s.addAll(l);
    cases.add(new Object[]{s});
    cases.add(new Object[] { new CopyOnWriteArrayList<>(l) });
    cases.add(new Object[] { l });
    return cases.toArray(new Object[0][cases.size()]);
}
 
开发者ID:lambdalab-mirror,项目名称:jdk8u-jdk,代码行数:22,代码来源:ListDefaults.java

示例5: main

import java.util.LinkedList; //导入依赖的package包/类
public static void main(String[] args) {
	LinkedList dimensionlist = Lister.listdimensions();
	LinkedList unitlist = Lister.listUnits();
	for (Iterator e = dimensionlist.iterator(); e.hasNext();) {
		try {
			String enext = e.next().toString();
			Dimension d = stringToDim(enext);
			enext = enext.substring(14, enext.length());
			System.out.println("\n" + enext + ":");
			filter(d, unitlist);
		} catch (Throwable er) {
			System.err.println(er);
		}
	}

}
 
开发者ID:etomica,项目名称:etomica,代码行数:17,代码来源:UnitFilter.java

示例6: testPagingAndSortingByLastName

import java.util.LinkedList; //导入依赖的package包/类
/**
 * Tests the capability to sort and paginate the list of people orderBy =
 * lastName ASC skip = 2, count = 3
 *
 * @throws Exception
 */
@Test
public void testPagingAndSortingByLastName() throws Exception
{
    publicApiClient.setRequestContext(new RequestContext(account4.getId(), account4Admin, "admin"));

    // paging
    int skipCount = 2;
    int maxItems = 3;
    int totalResults = 5;
    PublicApiClient.Paging paging = getPaging(skipCount, maxItems, totalResults, totalResults);

    // orderBy=lastName ASC
    PublicApiClient.ListResponse<Person> resp = listPeople(paging, "lastName", true, 200);

    List<Person> expectedList = new LinkedList<>();
    expectedList.add((Person) personBen);
    expectedList.add((Person) personAliceD);
    expectedList.add((Person) personAlice);

    checkList(expectedList, paging.getExpectedPaging(), resp);
}
 
开发者ID:Alfresco,项目名称:alfresco-remote-api,代码行数:28,代码来源:TestPeople.java

示例7: cntByTimeString

import java.util.LinkedList; //导入依赖的package包/类
public String cntByTimeString() {
    DecimalFormat df = new DecimalFormat(DECIMAL_PATTERN);
    List<String> millisStr = new LinkedList<String>();
    
    Iterator <Entry<Integer,Integer>>iter = millisMap.entrySet().iterator();
    while(iter.hasNext()) {
        Entry<Integer,Integer> millisEntry = iter.next();
        Integer bucket = (Integer)millisEntry.getKey();
        Integer bucketCount = (Integer)millisEntry.getValue();
        
        int minMillis = bucket.intValue() * millisPerBucket;
        int maxMillis = (bucket.intValue() + 1) * millisPerBucket;
        
        millisStr.add(
          df.format(minMillis/MILLIS_PER_SECOND)+" s "+
          "- "+
          df.format(maxMillis/MILLIS_PER_SECOND)+" s "+
          "= " + bucketCount);
    }
    return millisStr.toString();
}
 
开发者ID:WillemJiang,项目名称:acmeair,代码行数:22,代码来源:JtlTotals.java

示例8: read

import java.util.LinkedList; //导入依赖的package包/类
/**
 * Reads the channel buffer and returns object.
 *
 * @param cb channelBuffer
 * @return object of flow spec packet length
 * @throws BgpParseException while parsing BgpFsPacketLength
 */
public static BgpFsPacketLength read(ChannelBuffer cb) throws BgpParseException {
    List<BgpFsOperatorValue> operatorValue = new LinkedList<>();
    byte option;
    short packetLen;

    do {
        option = (byte) cb.readByte();
        int len = (option & Constants.BGP_FLOW_SPEC_LEN_MASK) >> 4;
        if ((1 << len) == 1) {
            packetLen = cb.readByte();
            operatorValue.add(new BgpFsOperatorValue(option, new byte[] {(byte) packetLen}));
        } else {
            packetLen = cb.readShort();
            operatorValue.add(new BgpFsOperatorValue(option,
                              new byte[] {(byte) (packetLen >> 8), (byte) packetLen}));
        }
    } while ((option & Constants.BGP_FLOW_SPEC_END_OF_LIST_MASK) == 0);

    return new BgpFsPacketLength(operatorValue);
}
 
开发者ID:shlee89,项目名称:athena,代码行数:28,代码来源:BgpFsPacketLength.java

示例9: resetConfigParams

import java.util.LinkedList; //导入依赖的package包/类
@Override
protected void resetConfigParams() {
    status = FunGameView.STATUS_GAME_PREPAR;
    controllerPosition = DIVIDING_LINE_SIZE;

    enemySpeed = DensityUtil.dp2px(1);
    bulletSpeed = DensityUtil.dp2px(4);

    levelNum = DEFAULT_TANK_MAGIC_TOTAL_NUM;
    wipeOutNum = 0;

    once = true;

    enemyTankSpace = controllerSize + barrelSize + DEFAULT_ENEMY_TANK_NUM_SPACING;
    bulletSpace = DEFAULT_BULLET_NUM_SPACING;

    eTankSparseArray = new SparseArray<>();
    for (int i = 0; i < TANK_ROW_NUM; i++) {
        Queue<RectF> rectFQueue = new LinkedList<>();
        eTankSparseArray.put(i, rectFQueue);
    }

    mBulletList = new LinkedList<>();
}
 
开发者ID:scwang90,项目名称:SmartRefreshLayout,代码行数:25,代码来源:FunGameBattleCityHeader.java

示例10: prepareRays

import java.util.LinkedList; //导入依赖的package包/类
private void prepareRays() {

        /*Délky postranních paprsků jsou 8 a 12. Délky šikmých se vynásobí 2 a předního se vynásobí odmocninou(3).*/
        int shortLength = 8;
        int longLength = 12;

        shortSideRayLength = (int) (UnrealUtils.CHARACTER_COLLISION_RADIUS * shortLength * DISTANCE_FROM_THE_WALL / 166f);        //8
        longSideRayLength = (int) (UnrealUtils.CHARACTER_COLLISION_RADIUS * longLength * DISTANCE_FROM_THE_WALL / 166f);        //12
        shortSideFrontRayLength = (int) (UnrealUtils.CHARACTER_COLLISION_RADIUS * shortLength * 2 * DISTANCE_FROM_THE_WALL / 166f);  //20
        longSideFrontRayLength = (int) (UnrealUtils.CHARACTER_COLLISION_RADIUS * longLength * 2 * DISTANCE_FROM_THE_WALL / 166f);   //30
        shortFrontRayLength = (int) (UnrealUtils.CHARACTER_COLLISION_RADIUS * shortLength * Math.sqrt(3) * DISTANCE_FROM_THE_WALL / 166f);      //18
        longFrontRayLength = (int) (UnrealUtils.CHARACTER_COLLISION_RADIUS * longLength * Math.sqrt(3) * DISTANCE_FROM_THE_WALL / 166f);       //27
        
        //Five rays are created.
        LinkedList<SteeringRay> rayList = new LinkedList<SteeringRay>();
        rayList.add(new SteeringRay(NLEFT, new Vector3d(0, -1, 0), longSideRayLength));
        rayList.add(new SteeringRay(NLEFTFRONT, new Vector3d(Math.sqrt(3), -1, 0), longSideFrontRayLength));
        rayList.add(new SteeringRay(NRIGHTFRONT, new Vector3d(Math.sqrt(3), 1, 0), longSideFrontRayLength));
        rayList.add(new SteeringRay(NRIGHT, new Vector3d(0, 1, 0), longSideRayLength));
        rayList.add(new SteeringRay(NFRONT, new Vector3d(1, 0, 0), longFrontRayLength));
        rayManager.addRays(SteeringType.WALL_FOLLOWING, rayList, this);
        raysReady = false;
        //System.out.println("Rays wall preparation end.");
    }
 
开发者ID:kefik,项目名称:Pogamut3,代码行数:25,代码来源:WallFollowingSteer.java

示例11: testReplacingObjectsDoesNotGenerateException

import java.util.LinkedList; //导入依赖的package包/类
/** Replacing items with different objects.
 */
public void testReplacingObjectsDoesNotGenerateException () throws Exception {
    LinkedList arr = new LinkedList ();
    
    class R extends Exception implements Cloneable {
    }
    arr.add (new R ());
    arr.add (new R ());
    
    ic.set (arr, null);
    
    arr.clear();
    
    arr.add (new R ());
    arr.add (new R ());
    
    ic.set (arr, null);
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:AbstractLookupBaseHid.java

示例12: rectifyMisRecogCapUnderNotesChar

import java.util.LinkedList; //导入依赖的package包/类
public static void rectifyMisRecogCapUnderNotesChar(CharLearningMgr clm, StructExprRecog ser)   {
    if (ser.mnExprRecogType == EXPRRECOGTYPE_ENUMTYPE
            && !ser.isLetterChar() && !ser.isNumberChar() && ser.mType != UnitProtoType.Type.TYPE_ADD
            && ser.mType != UnitProtoType.Type.TYPE_SUBTRACT && ser.mType != UnitProtoType.Type.TYPE_WAVE
            && ser.mType != UnitProtoType.Type.TYPE_STAR && ser.mType != UnitProtoType.Type.TYPE_DOT)    {  // because it is cap under note, it cannot be dot multiply
        // this letter might be miss recognized, look for another candidate.
        LinkedList<CharCandidate> listCands = clm.findCharCandidates(ser.mType, ser.mstrFont);
        for (int idx1 = 0; idx1 < listCands.size(); idx1 ++)    {
            if (isLetterChar(listCands.get(idx1).mType) || isNumberChar(listCands.get(idx1).mType)
                    || ser.mType == UnitProtoType.Type.TYPE_ADD || ser.mType == UnitProtoType.Type.TYPE_SUBTRACT
                    || ser.mType == UnitProtoType.Type.TYPE_WAVE || ser.mType == UnitProtoType.Type.TYPE_STAR
                    || ser.mType == UnitProtoType.Type.TYPE_DOT) {
                // ok, change it to the new char
                ser.changeSEREnumType(listCands.get(idx1).mType,
                        (listCands.get(idx1).mstrFont.length() == 0)?ser.mstrFont:listCands.get(idx1).mstrFont);
                break;
            }
        }
    }
}
 
开发者ID:woshiwpa,项目名称:CoreMathImgProc,代码行数:21,代码来源:StructExprRecog.java

示例13: main

import java.util.LinkedList; //导入依赖的package包/类
public static void main(String[] args) throws IOException {
	while ((line = in.readLine()) != null) {
		n = Integer.parseInt(line);
		list = new LinkedList<Integer>();
		for (int i = 2; i < n; i += 2) {
			list.add(i);
		}
		c = 3;
		while (list.size() > c) {
			for(int i=0; i < list.size(); i++) {
				if (i % c == 0) {
					
				}
			}
			c++;
		}
	}
	System.out.print(sb.toString());
}
 
开发者ID:elraro,项目名称:AceptaElReto,代码行数:20,代码来源:Problema146.java

示例14: refreshDirectory

import java.util.LinkedList; //导入依赖的package包/类
public static @NonNull RefreshResult refreshDirectory(@NonNull Context context,
                                                      @NonNull SignalServiceAccountManager accountManager,
                                                      @NonNull String localNumber)
    throws IOException
{
  TextSecureDirectory       directory              = TextSecureDirectory.getInstance(context);
  Set<String>               eligibleContactNumbers = directory.getPushEligibleContactNumbers(localNumber);
  List<ContactTokenDetails> activeTokens           = accountManager.getContacts(eligibleContactNumbers);

  if (activeTokens != null) {
    for (ContactTokenDetails activeToken : activeTokens) {
      eligibleContactNumbers.remove(activeToken.getNumber());
      activeToken.setNumber(activeToken.getNumber());
    }

    directory.setNumbers(activeTokens, eligibleContactNumbers);
    return updateContactsDatabase(context, localNumber, activeTokens, true);
  }

  return new RefreshResult(new LinkedList<String>(), false);
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:22,代码来源:DirectoryHelper.java

示例15: ConsolePane

import java.util.LinkedList; //导入依赖的package包/类
public ConsolePane()
{
	WebView view = new WebView();
	view.setContextMenuEnabled(false);
	webEngine = view.getEngine();
	
	messageQueue = new LinkedList<>();
	
	ObservableValue<State> property = webEngine.getLoadWorker().stateProperty();
	OnLoadListener.register(this::onLoad, property);
	
	String content = "<html><head></head><body></body></html>";
	webEngine.loadContent(content);
	
	ConsolePaneEventHandler eventHandler = new ConsolePaneEventHandler();
	EventRegistry.getGlobalRegistry().register(eventHandler);
	
	this.setCenter(view);
}
 
开发者ID:dhawal9035,项目名称:WebPLP,代码行数:20,代码来源:ConsolePane.java


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