本文整理匯總了Java中java.util.Queue.addAll方法的典型用法代碼示例。如果您正苦於以下問題:Java Queue.addAll方法的具體用法?Java Queue.addAll怎麽用?Java Queue.addAll使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.Queue
的用法示例。
在下文中一共展示了Queue.addAll方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: fillQueueForKey
import java.util.Queue; //導入方法依賴的package包/類
@Override
public void fillQueueForKey(String keyName,
Queue<EncryptedKeyVersion> keyQueue, int numEKVs) throws IOException {
checkNotNull(keyName, "keyName");
Map<String, String> params = new HashMap<String, String>();
params.put(KMSRESTConstants.EEK_OP, KMSRESTConstants.EEK_GENERATE);
params.put(KMSRESTConstants.EEK_NUM_KEYS, "" + numEKVs);
URL url = createURL(KMSRESTConstants.KEY_RESOURCE, keyName,
KMSRESTConstants.EEK_SUB_RESOURCE, params);
HttpURLConnection conn = createConnection(url, HTTP_GET);
conn.setRequestProperty(CONTENT_TYPE, APPLICATION_JSON_MIME);
List response = call(conn, null,
HttpURLConnection.HTTP_OK, List.class);
List<EncryptedKeyVersion> ekvs =
parseJSONEncKeyVersion(keyName, response);
keyQueue.addAll(ekvs);
}
示例2: addFirst
import java.util.Queue; //導入方法依賴的package包/類
@Override
public ReceivePipelineCondition<T> addFirst(final OnReceiveTriple<T> pipelineService) {
final PipelineReceiver<T> pipelineReceiver = new PipelineReceiver<>(pipelineService);
if (isClosed()) {
falseAdd(pipelineService);
} else {
final Queue<PipelineReceiver<T>> newCore = new LinkedList<>();
newCore.add(pipelineReceiver);
synchronized (core) {
newCore.addAll(core);
core.clear();
core.addAll(newCore);
}
pipelineService.onRegistration();
}
return new ReceivePipelineConditionImpl<>(pipelineReceiver);
}
示例3: createCh
import java.util.Queue; //導入方法依賴的package包/類
/**
* Take a competence node that is connected to the triggered action
* that is associated with this widget and create children so it looks
* like this widget is root of competence.
*
* In most widgets, one widget is representing one node.
* This one is representing competence and this function is regenerating competence structure to widgets.
*/
private void createCh() {
Queue<PoshElement> fringe = new LinkedList<PoshElement>();
fringe.add(this.compNode);
while (!fringe.isEmpty()) {
PoshElement head = fringe.poll();
Set<PoshElementListener> listeners = head.getElementListeners();
for (PoshElementListener listener : listeners) {
if (listener instanceof PoshWidget) {
PoshWidget widget = (PoshWidget) listener;
if (widget.isAncestor(this)) {
for (PoshElement child : head.getChildDataNodes()) {
widget.nodeChanged(PoshTreeEvent.NEW_CHILD_NODE, child);
}
}
}
}
fringe.addAll(head.getChildDataNodes());
}
}
示例4: createConnectedComponent
import java.util.Queue; //導入方法依賴的package包/類
private static List<Integer> createConnectedComponent(HashMap<Integer, List<Integer>> graph, int root) {
Queue<Integer> q = new ArrayDeque<>(); // next nodes to visit
List<Integer> visited = new ArrayList<>(); // connected component so far
q.add(root); // init queue
while (!q.isEmpty()) {
Integer poll = q.poll(); // get next node
if (!visited.contains(poll)) { // if it's not already visited
visited.add(poll); // visit it
q.addAll(graph.get(poll)); // and put its neighbourhood in the queue
}
}
visited.forEach(v -> graph.remove(v)); // removes the connected component from the graph
return visited;
}
示例5: parse
import java.util.Queue; //導入方法依賴的package包/類
public Queue<Token> parse(String text) {
final Queue<Token> tokens = new ArrayDeque<>();
if (text != null) {
text = text.trim();
if (!text.isEmpty()) {
boolean matchFound = false;
for (InfoWrapper iw : infos) {
final Matcher matcher = iw.pattern.matcher(text);
if (matcher.find()) {
matchFound = true;
String match = matcher.group().trim();
tokens.add(iw.info.getToken(match));
tokens.addAll(parse(text.substring(match.length())));
break;
}
}
if (!matchFound) {
throw new DateCalcException("Could not parse the expression: " + text);
}
}
}
return tokens;
}
示例6: deliverOutstandingMessages
import java.util.Queue; //導入方法依賴的package包/類
@DatabaseExecutor
private void deliverOutstandingMessages(ClientId c) {
try {
Queue<MessageId> pending = new LinkedList<MessageId>();
Transaction txn = db.startTransaction(true);
try {
pending.addAll(db.getPendingMessages(txn, c));
db.commitTransaction(txn);
} finally {
db.endTransaction(txn);
}
deliverNextPendingMessageAsync(pending);
} catch (DbException e) {
if (LOG.isLoggable(WARNING)) LOG.log(WARNING, e.toString(), e);
}
}
示例7: gatherProcessInfo
import java.util.Queue; //導入方法依賴的package包/類
@Override
public void gatherProcessInfo(HtmlSection section, long pid) {
Queue<Long> pids = new LinkedList<>();
pids.add(pid);
for (Long p = pids.poll(); p != null; p = pids.poll()) {
HtmlSection pidSection = section.createChildren("" + p);
for (ActionSet set : actions) {
set.gatherProcessInfo(pidSection, p);
}
List<Long> children = helper.getChildren(pidSection, p);
if (!children.isEmpty()) {
HtmlSection s = pidSection.createChildren("children");
for (Long c : children) {
s.link(section, c.toString(), c.toString());
}
pids.addAll(children);
}
}
}
示例8: getListeners
import java.util.Queue; //導入方法依賴的package包/類
@Override
public Queue<AbstractEventListener> getListeners(EventType type)
{
final Queue<AbstractEventListener> objectListenres = super.getListeners(type);
final Queue<AbstractEventListener> templateListeners = getTemplate().getListeners(type);
final Queue<AbstractEventListener> globalListeners = isNpc() && !isMonster() ? Containers.Npcs().getListeners(type) : isMonster() ? Containers.Monsters().getListeners(type) : isPlayer() ? Containers.Players().getListeners(type) : EmptyQueue.emptyQueue();
// Attempt to do not create collection
if (objectListenres.isEmpty() && templateListeners.isEmpty() && globalListeners.isEmpty())
{
return EmptyQueue.emptyQueue();
}
else if (!objectListenres.isEmpty() && templateListeners.isEmpty() && globalListeners.isEmpty())
{
return objectListenres;
}
else if (!templateListeners.isEmpty() && objectListenres.isEmpty() && globalListeners.isEmpty())
{
return templateListeners;
}
else if (!globalListeners.isEmpty() && objectListenres.isEmpty() && templateListeners.isEmpty())
{
return globalListeners;
}
final Queue<AbstractEventListener> both = new LinkedBlockingDeque<>(objectListenres.size() + templateListeners.size() + globalListeners.size());
both.addAll(objectListenres);
both.addAll(templateListeners);
both.addAll(globalListeners);
return both;
}
示例9: createCh
import java.util.Queue; //導入方法依賴的package包/類
/**
* Create children of AP. In most widgets, one widget is representing one
* node. This one is representing AP and this function is regenerating AP
* structure to widgets.
*/
private void createCh() {
Queue<PoshWidget<? extends PoshElement>> fringe = new LinkedList<PoshWidget<? extends PoshElement>>(createWidgetChildren(this, apNode));
while (!fringe.isEmpty()) {
PoshWidget<? extends PoshElement> headWidget = fringe.poll();
PoshElement headDataNode = headWidget.getDataNode();
if (!(headDataNode instanceof TriggeredAction)) {
fringe.addAll(createWidgetChildren(headWidget, headDataNode));
}
}
}
示例10: fillQueueForKey
import java.util.Queue; //導入方法依賴的package包/類
@Override
public void fillQueueForKey(String keyName,
Queue<EncryptedKeyVersion> keyQueue, int numKeys) throws IOException {
List<EncryptedKeyVersion> retEdeks =
new LinkedList<EncryptedKeyVersion>();
for (int i = 0; i < numKeys; i++) {
try {
retEdeks.add(keyProviderCryptoExtension.generateEncryptedKey(
keyName));
} catch (GeneralSecurityException e) {
throw new IOException(e);
}
}
keyQueue.addAll(retEdeks);
}
示例11: collectNodes
import java.util.Queue; //導入方法依賴的package包/類
private ImmutableSet<ColumnIdentifier> collectNodes(
ColumnIdentifier node, int nodeIndex,Function<ColumnIdentifier, Set<ColumnIdentifier>> getSuccessor) {
Set<ColumnIdentifier> results = new HashSet<>();
Queue<ColumnIdentifier> queue = new LinkedList<>();
queue.add(node);
while (!queue.isEmpty()) {
ColumnIdentifier nextNode = queue.remove();
ImmutableSet<ColumnIdentifier> nodes = getSuccessor.apply(nextNode).stream()
.filter(column -> getCandidateIndex(column) > nodeIndex)
.collect(toImmutableSet());
queue.addAll(Sets.difference(nodes, results));
results.addAll(nodes);
}
return ImmutableSet.copyOf(results);
}
示例12: expandsExactlyOneContent
import java.util.Queue; //導入方法依賴的package包/類
/**
* Expands content of 'EXACTLY_ONE' node. Direct 'EXACTLY_ONE' child nodes are dissolved in the process.
*/
private Collection<ModelNode> expandsExactlyOneContent(final Collection<ModelNode> content) throws PolicyException {
final Collection<ModelNode> result = new LinkedList<ModelNode>();
final Queue<ModelNode> eoContentQueue = new LinkedList<ModelNode>(content);
ModelNode node;
while ((node = eoContentQueue.poll()) != null) {
// dissolving direct 'EXACTLY_ONE' child nodes
switch (node.getType()) {
case POLICY :
case ALL :
case ASSERTION :
result.add(node);
break;
case POLICY_REFERENCE :
result.add(getReferencedModelRootNode(node));
break;
case EXACTLY_ONE :
eoContentQueue.addAll(node.getChildren());
break;
default :
throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0001_UNSUPPORTED_MODEL_NODE_TYPE(node.getType())));
}
}
return result;
}
示例13: decompose
import java.util.Queue; //導入方法依賴的package包/類
/**
* Decomposes the unprocessed alternative content into two different collections:
* <p/>
* Content of 'EXACTLY_ONE' child nodes is expanded and placed in one list and
* 'ASSERTION' nodes are placed into other list. Direct 'ALL' and 'POLICY' child nodes are 'dissolved' in the process.
*
* Method reuses precreated ContentDecomposition object, which is reset before reuse.
*/
private void decompose(final Collection<ModelNode> content, final ContentDecomposition decomposition) throws PolicyException {
decomposition.reset();
final Queue<ModelNode> allContentQueue = new LinkedList<ModelNode>(content);
ModelNode node;
while ((node = allContentQueue.poll()) != null) {
// dissolving direct 'POLICY', 'POLICY_REFERENCE' and 'ALL' child nodes
switch (node.getType()) {
case POLICY :
case ALL :
allContentQueue.addAll(node.getChildren());
break;
case POLICY_REFERENCE :
allContentQueue.addAll(getReferencedModelRootNode(node).getChildren());
break;
case EXACTLY_ONE :
decomposition.exactlyOneContents.add(expandsExactlyOneContent(node.getChildren()));
break;
case ASSERTION :
decomposition.assertions.add(node);
break;
default :
throw LOGGER.logSevereException(new PolicyException(LocalizationMessages.WSP_0007_UNEXPECTED_MODEL_NODE_TYPE_FOUND(node.getType())));
}
}
}
示例14: searchFoldersInFolder
import java.util.Queue; //導入方法依賴的package包/類
public List<PhotatoFolder> searchFoldersInFolder(String folder, String searchQuery) {
// Search for a folder with the correct name. This is just a recursive exploration since we suppose the number of folders will be low enough and thus we would be able to "bruteforce" it
List<String> searchQuerySplit = SearchQueryHelper.getSplittedTerms(searchQuery);
List<PhotatoFolder> result = new ArrayList<>();
if (!searchQuerySplit.isEmpty()) {
PhotatoFolder currentFolder = isVirtualFolder(folder) ? this.albumsManager.getCurrentFolder(folder) : this.getCurrentFolder(this.rootFolder.fsPath.resolve(folder));
Queue<PhotatoFolder> queue = new LinkedList<>();
queue.add(currentFolder);
while (!queue.isEmpty()) {
currentFolder = queue.remove();
queue.addAll(currentFolder.subFolders.values());
if (!currentFolder.isEmpty()) {
List<String> currentFolderCleanedFilename = SearchQueryHelper.getSplittedTerms(currentFolder.filename);
boolean ok = searchQuerySplit.stream().allMatch((s) -> (currentFolderCleanedFilename.stream().anyMatch((String t) -> (prefixOnlyMode && t.startsWith(s)) || (!prefixOnlyMode && t.contains(s)))));
if (ok) {
result.add(currentFolder);
}
}
}
}
return result;
}
示例15: isHomogeneous
import java.util.Queue; //導入方法依賴的package包/類
/**
* Check if the table contains homogenenous files that can be read by Drill. Eg: parquet, json csv etc.
* However if it contains more than one of these formats or a totally different file format that Drill cannot
* understand then we will raise an exception.
* @param tableName - name of the table to be checked for homogeneous property
* @return
* @throws IOException
*/
private boolean isHomogeneous(String tableName) throws IOException {
FileSelection fileSelection = FileSelection.create(fs, config.getLocation(), tableName);
if (fileSelection == null) {
throw UserException
.validationError()
.message(String.format("Table [%s] not found", tableName))
.build(logger);
}
FormatMatcher matcher = null;
Queue<FileStatus> listOfFiles = new LinkedList<>();
listOfFiles.addAll(fileSelection.getFileStatusList(fs));
while (!listOfFiles.isEmpty()) {
FileStatus currentFile = listOfFiles.poll();
if (currentFile.isDirectory()) {
listOfFiles.addAll(fs.list(true, currentFile.getPath()));
} else {
if (matcher != null) {
if (!matcher.isFileReadable(fs, currentFile)) {
return false;
}
} else {
matcher = findMatcher(currentFile);
// Did not match any of the file patterns, exit
if (matcher == null) {
return false;
}
}
}
}
return true;
}