本文整理匯總了Java中com.google.common.collect.Lists.newLinkedList方法的典型用法代碼示例。如果您正苦於以下問題:Java Lists.newLinkedList方法的具體用法?Java Lists.newLinkedList怎麽用?Java Lists.newLinkedList使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類com.google.common.collect.Lists
的用法示例。
在下文中一共展示了Lists.newLinkedList方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getLogFile
import com.google.common.collect.Lists; //導入方法依賴的package包/類
public static EditLogFile getLogFile(File dir, long startTxId)
throws IOException {
List<EditLogFile> files = matchEditLogs(dir);
List<EditLogFile> ret = Lists.newLinkedList();
for (EditLogFile elf : files) {
if (elf.getFirstTxId() == startTxId) {
ret.add(elf);
}
}
if (ret.isEmpty()) {
// no matches
return null;
} else if (ret.size() == 1) {
return ret.get(0);
} else {
throw new IllegalStateException("More than one log segment in " +
dir + " starting at txid " + startTxId + ": " +
Joiner.on(", ").join(ret));
}
}
示例2: evaluate
import com.google.common.collect.Lists; //導入方法依賴的package包/類
public List<String> evaluate(List<String> input, String baseUrl) {
LinkedHashSet<String> linkedHashSet = Sets.newLinkedHashSet();
int i = 0;
for (String str : input) {
StringContext stringContext = new StringContext(baseUrl, str, input, i);
Object calculate = stringFunction.calculate(stringContext);
if ((calculate instanceof Strings)) {
linkedHashSet.addAll((Strings) calculate);
} else if (calculate instanceof CharSequence) {
linkedHashSet.add(calculate.toString());
} else {
log.warn("result type for function: " + stringFunction.functionName() + " is not strings");
}
i++;
}
return Lists.newLinkedList(linkedHashSet);
}
示例3: testCoalesce
import com.google.common.collect.Lists; //導入方法依賴的package包/類
@Test
public void testCoalesce() throws EventDeliveryException {
initContextForIncrementHBaseSerializer();
ctx.put("batchSize", "100");
ctx.put(HBaseSinkConfigurationConstants.CONFIG_COALESCE_INCREMENTS,
String.valueOf(true));
final Map<String, Long> expectedCounts = Maps.newHashMap();
expectedCounts.put("r1:c1", 10L);
expectedCounts.put("r1:c2", 20L);
expectedCounts.put("r2:c1", 7L);
expectedCounts.put("r2:c3", 63L);
HBaseSink.DebugIncrementsCallback cb = new CoalesceValidator(expectedCounts);
HBaseSink sink = new HBaseSink(testUtility.getConfiguration(), cb);
Configurables.configure(sink, ctx);
Channel channel = createAndConfigureMemoryChannel(sink);
List<Event> events = Lists.newLinkedList();
generateEvents(events, expectedCounts);
putEvents(channel, events);
sink.start();
sink.process(); // Calls CoalesceValidator instance.
sink.stop();
}
示例4: dropTablesIfPresent
import com.google.common.collect.Lists; //導入方法依賴的package包/類
/**
* Drop the specified tables from the schema if they are present.
*
* @param tablesToDrop The tables to delete if they are present in the database.
*/
public void dropTablesIfPresent(Set<String> tablesToDrop) {
ProducerCache producerCache = new ProducerCache();
try {
Collection<String> sql = Lists.newLinkedList();
for (String tableName : tablesToDrop) {
Table cachedTable = getTable(producerCache, tableName);
if (cachedTable != null) {
sql.addAll(dropTable(cachedTable));
}
}
executeScript(sql);
} finally {
producerCache.close();
}
}
示例5: maakResultaatLijst
import com.google.common.collect.Lists; //導入方法依賴的package包/類
private LijstExpressie maakResultaatLijst(final Predicate<MetaAttribuut> attribuutFilter,
final Collection solve, final Context context) {
final List<Expressie> resultaatWaarden = Lists.newLinkedList();
for (final Object metaModel : solve) {
final Literal literal = maakResultaatLiteral(attribuutFilter, context, metaModel);
if (literal != null) {
resultaatWaarden.add(literal);
}
}
return new LijstExpressie(resultaatWaarden);
}
示例6: readEvents
import com.google.common.collect.Lists; //導入方法依賴的package包/類
public List<Event> readEvents(int numEvents, boolean backoffWithoutNL,
boolean addByteOffset) throws IOException {
List<Event> events = Lists.newLinkedList();
for (int i = 0; i < numEvents; i++) {
Event event = readEvent(backoffWithoutNL, addByteOffset);
if (event == null) {
break;
}
events.add(event);
}
return events;
}
示例7: iterator
import com.google.common.collect.Lists; //導入方法依賴的package包/類
@Override
public Iterator<LogicalExpression> iterator() {
List<LogicalExpression> children = Lists.newLinkedList();
children.add(ifCondition.condition);
children.add(ifCondition.expression);
children.add(this.elseExpression);
return children.iterator();
}
示例8: balanceControllerNodes
import com.google.common.collect.Lists; //導入方法依賴的package包/類
/**
* Balances the nodes specified in controllerDevices.
*
* @param controllerDevices controller nodes to devices map
* @param deviceCount number of devices mastered by controller nodes
* @return list of setRole futures for "moved" devices
*/
private List<CompletableFuture<Void>> balanceControllerNodes(
Map<ControllerNode, Set<DeviceId>> controllerDevices, int deviceCount) {
// Now re-balance the buckets until they are roughly even.
List<CompletableFuture<Void>> balanceBucketsFutures = Lists.newLinkedList();
int rounds = controllerDevices.keySet().size();
for (int i = 0; i < rounds; i++) {
// Iterate over the buckets and find the smallest and the largest.
ControllerNode smallest = findBucket(true, controllerDevices);
ControllerNode largest = findBucket(false, controllerDevices);
balanceBucketsFutures.add(balanceBuckets(smallest, largest, controllerDevices, deviceCount));
}
return balanceBucketsFutures;
}
示例9: tokenStream
import com.google.common.collect.Lists; //導入方法依賴的package包/類
private List<TokenHolder> tokenStream() {
stringFunctionTokenQueue.consumeWhitespace();
List<TokenHolder> ret = Lists.newLinkedList();
while (!stringFunctionTokenQueue.isEmpty()) {
if (stringFunctionTokenQueue.matchesFunction()) {
ret.add(new TokenHolder(stringFunctionTokenQueue.consumeFunction(), TokenType.Function));
} else if (stringFunctionTokenQueue.matches("(")) {
String subExpression = stringFunctionTokenQueue.chompBalanced('(', ')');
if (subExpression == null) {
throw new IllegalStateException(
"can not parse token :" + stringFunctionTokenQueue.remainder() + " ,unmatched quote");
}
ret.add(new TokenHolder(subExpression, TokenType.Expression));
} else if (stringFunctionTokenQueue.matchesBoolean()) {
ret.add(new TokenHolder(stringFunctionTokenQueue.consumeWord(), TokenType.Boolean));
} else if (stringFunctionTokenQueue.matchesAny("+", "-", "*", "/", "%")) {
char peek = stringFunctionTokenQueue.peek();
stringFunctionTokenQueue.advance();
ret.add(new TokenHolder(String.valueOf(peek), TokenType.Operator));
} else if (stringFunctionTokenQueue.matchesDigit()) {
ret.add(new TokenHolder(stringFunctionTokenQueue.consumeDigit(), TokenType.Number));
} else if (stringFunctionTokenQueue.matchesAny('\"', '\'')) {
String str;
if (stringFunctionTokenQueue.peek() == '\"') {
str = stringFunctionTokenQueue.chompBalanced('\"', '\"');
} else {
str = stringFunctionTokenQueue.chompBalanced('\'', '\'');
}
ret.add(new TokenHolder(StringFunctionTokenQueue.unescape(str), TokenType.String));
} else {
throw new IllegalStateException("unknown token:" + stringFunctionTokenQueue.remainder());
}
stringFunctionTokenQueue.consumeWhitespace();
}
return ret;
}
示例10: index
import com.google.common.collect.Lists; //導入方法依賴的package包/類
@Override
public String index(SpiderInfo spiderInfo) {
IndexResponse indexResponse;
if (getByDomain(spiderInfo.getDomain(), 10, 1).size() > 0) {
List<SpiderInfo> mayDuplicate = Lists.newLinkedList();
List<SpiderInfo> temp;
int i = 1;
do {
temp = getByDomain(spiderInfo.getDomain(), 100, i++);
mayDuplicate.addAll(temp);
} while (temp.size() > 0);
if (mayDuplicate.indexOf(spiderInfo) != -1 && (spiderInfo = mayDuplicate.get(mayDuplicate.indexOf(spiderInfo))) != null) {
LOG.warn("已經含有此模板,不再存儲");
return spiderInfo.getId();
}
}
try {
indexResponse = client.prepareIndex(INDEX_NAME, TYPE_NAME)
.setSource(gson.toJson(spiderInfo))
.get();
LOG.debug("索引爬蟲模板成功");
return indexResponse.getId();
} catch (Exception e) {
LOG.error("索引 Webpage 出錯," + e.getLocalizedMessage());
}
return null;
}
示例11: maakBerichten
import com.google.common.collect.Lists; //導入方法依賴的package包/類
@Override
public List<Mutatiebericht> maakBerichten(final List<Mutatielevering> mutatieleveringen, Mutatiehandeling handeling) throws StapException {
final ConversieCache conversieCache = new ConversieCache();
final List<Mutatiebericht> leveringList = Lists.newLinkedList();
for (final Mutatielevering mutatielevering : mutatieleveringen) {
if (Stelsel.GBA != mutatielevering.getStelsel()) {
continue;
}
leveringList.addAll(maakBericht(mutatielevering, conversieCache, handeling));
}
return leveringList;
}
示例12: findPath
import com.google.common.collect.Lists; //導入方法依賴的package包/類
private LinkedList<ControlFlowEdge> findPath(Node startNode, Node endNode, Node notVia,
NextEdgesProvider edgeProvider) {
if (startNode == endNode) {
return Lists.newLinkedList();
}
LinkedList<LinkedList<ControlFlowEdge>> allPaths = new LinkedList<>();
// initialization
List<ControlFlowEdge> nextEdges = edgeProvider.getNextEdges(startNode, ControlFlowType.NonDeadTypes);
for (ControlFlowEdge nextEdge : nextEdges) {
LinkedList<ControlFlowEdge> path = new LinkedList<>();
path.add(nextEdge);
if (isEndNode(edgeProvider, endNode, nextEdge)) {
return path; // direct edge from startNode to endNode due to nextEdge
}
allPaths.add(path);
}
// explore all paths, terminate when endNode is found
while (!allPaths.isEmpty()) {
LinkedList<ControlFlowEdge> firstPath = allPaths.removeFirst();
LinkedList<LinkedList<ControlFlowEdge>> ch = getPaths(edgeProvider, firstPath, notVia);
for (LinkedList<ControlFlowEdge> chPath : ch) {
if (isEndNode(edgeProvider, endNode, chPath.getLast())) {
return chPath;
}
}
allPaths.addAll(ch);
}
return null;
}
示例13: testForLinkedListCreate
import com.google.common.collect.Lists; //導入方法依賴的package包/類
/**
* 循環10000000次
* 8841 毫秒
*/
@Test
public void testForLinkedListCreate() {
Instant start = Instant.now();
LinkedList<Object> arrayList = Lists.newLinkedList();
for (int i = 0; i < 10000000; i++) {
arrayList.add(new Object());
}
Instant end = Instant.now();
long millis = Duration.between(start, end).toMillis();
System.out.println(millis);
}
示例14: cleanup
import com.google.common.collect.Lists; //導入方法依賴的package包/類
/**
* For a given host, remove any flow rule which references it's addresses.
* @param host the host to clean up for
*/
private void cleanup(Host host) {
Iterable<Device> devices = deviceService.getDevices();
List<FlowRule> flowRules = Lists.newLinkedList();
for (Device device : devices) {
flowRules.addAll(cleanupDevice(device, host));
}
FlowRule[] flows = new FlowRule[flowRules.size()];
flows = flowRules.toArray(flows);
flowRuleService.removeFlowRules(flows);
}
示例15: buildFlowAdd
import com.google.common.collect.Lists; //導入方法依賴的package包/類
@Override
public OFFlowMod buildFlowAdd() {
Match match = buildMatch();
List<OFAction> deferredActions = buildActions(treatment.deferred());
List<OFAction> immediateActions = buildActions(treatment.immediate());
List<OFInstruction> instructions = Lists.newLinkedList();
if (treatment.clearedDeferred()) {
instructions.add(factory().instructions().clearActions());
}
if (immediateActions.size() > 0) {
instructions.add(factory().instructions().applyActions(immediateActions));
}
if (deferredActions.size() > 0) {
instructions.add(factory().instructions().writeActions(deferredActions));
}
if (treatment.tableTransition() != null) {
instructions.add(buildTableGoto(treatment.tableTransition()));
}
if (treatment.writeMetadata() != null) {
instructions.add(buildMetadata(treatment.writeMetadata()));
}
if (treatment.metered() != null) {
instructions.add(buildMeter(treatment.metered()));
}
long cookie = flowRule().id().value();
OFFlowAdd fm = factory().buildFlowAdd()
.setXid(xid)
.setCookie(U64.of(cookie))
.setBufferId(OFBufferId.NO_BUFFER)
.setInstructions(instructions)
.setMatch(match)
.setFlags(Collections.singleton(OFFlowModFlags.SEND_FLOW_REM))
.setPriority(flowRule().priority())
.setTableId(TableId.of(flowRule().tableId()))
.build();
return fm;
}