本文整理汇总了Java中java.util.Deque.isEmpty方法的典型用法代码示例。如果您正苦于以下问题:Java Deque.isEmpty方法的具体用法?Java Deque.isEmpty怎么用?Java Deque.isEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.Deque
的用法示例。
在下文中一共展示了Deque.isEmpty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: floodIndices
import java.util.Deque; //导入方法依赖的package包/类
private Set<Coordinate> floodIndices(final Coordinate coordinate) {
final Set<Coordinate> flood = new LinkedHashSet<>();
final Color floodColor = getColor(coordinate);
final Deque<Coordinate> queue = new LinkedList<>();
queue.add(coordinate);
while (!queue.isEmpty()) {
final Coordinate location = queue.pop();
flood.add(location);
queue.addAll(getNeighbors(location).stream()
.filter(neighbor -> floodColor.equals(getColor(neighbor)) && !flood.contains(neighbor))
.collect(Collectors.toList()));
}
return flood;
}
示例2: readEffectiveConfig
import java.util.Deque; //导入方法依赖的package包/类
private static Map<String, Object> readEffectiveConfig(Path filePath){
Map<String, Object> config = getConfigParametersFromFile(filePath);
Deque<Map<String, Object>> configs = new ArrayDeque<>();
configs.add(config);
while (config.get(INHERIT) != null) {
String inherit = String.valueOf(config.get(INHERIT));
filePath = filePath.getParent().resolve(inherit);
config = getConfigParametersFromFile(filePath);
if (!config.isEmpty()) {
configs.addFirst(config);
}
}
Map<String, Object> effectiveConfig = configs.pollFirst();
while (!configs.isEmpty()) {
overwriteInnerProperties(effectiveConfig, configs.pollFirst());
}
effectiveConfig.remove(INHERIT);
return effectiveConfig;
}
示例3: buildThriftType
import java.util.Deque; //导入方法依赖的package包/类
private ThriftType buildThriftType(Type javaType)
{
ThriftType thriftType = buildThriftTypeInternal(javaType);
typeCache.putIfAbsent(javaType, thriftType);
if (stack.get().isEmpty()) {
// The stack represents the processing of nested types, so when the stack is empty
// at this point, we've just finished processing and caching the originally requested
// type. There may be some unresolved type references we should revisit now.
Deque<Type> unresolvedJavaTypes = deferredTypesWorkList.get();
do {
if (unresolvedJavaTypes.isEmpty()) {
break;
}
Type unresolvedJavaType = unresolvedJavaTypes.pop();
if (!typeCache.containsKey(unresolvedJavaType)) {
ThriftType resolvedThriftType = buildThriftTypeInternal(unresolvedJavaType);
typeCache.putIfAbsent(unresolvedJavaType, resolvedThriftType);
}
}
while (true);
}
return thriftType;
}
示例4: unavailableTransformer
import java.util.Deque; //导入方法依赖的package包/类
/**
* Called to identify a transformer that cannot be used during working out
* available transformers.
*/
public void unavailableTransformer(ContentTransformer transformer, String sourceMimetype, String targetMimetype, long maxSourceSizeKBytes)
{
if (isEnabled())
{
Deque<Frame> ourStack = ThreadInfo.getStack();
Frame frame = ourStack.peek();
if (frame != null)
{
Deque<String> isTransformableStack = ThreadInfo.getIsTransformableStack();
String name = (!isTransformableStack.isEmpty())
? isTransformableStack.getFirst()
: getName(transformer);
boolean debug = (maxSourceSizeKBytes != 0);
if (frame.unavailableTransformers == null)
{
frame.unavailableTransformers = new TreeSet<UnavailableTransformer>();
}
String priority = gePriority(transformer, sourceMimetype, targetMimetype);
frame.unavailableTransformers.add(new UnavailableTransformer(name, priority, maxSourceSizeKBytes, debug));
}
}
}
示例5: doLoadAsync
import java.util.Deque; //导入方法依赖的package包/类
@Override
public Future<Optional<SelectedSnapshot>> doLoadAsync(final String persistenceId,
final SnapshotSelectionCriteria criteria) {
LOG.debug("In doLoadAsync - persistenceId: {}, criteria: {}", persistenceId, criteria);
// Select the youngest 'maxLoadAttempts' snapshots that match the criteria. This may help in situations where
// saving of a snapshot could not be completed because of a JVM crash. Hence, an attempt to load that snapshot
// will fail but loading an older snapshot may succeed.
Deque<SnapshotMetadata> metadatas = getSnapshotMetadatas(persistenceId, criteria).stream()
.sorted(LocalSnapshotStore::compare).collect(reverse()).stream().limit(maxLoadAttempts)
.collect(Collectors.toCollection(ArrayDeque::new));
if (metadatas.isEmpty()) {
return Futures.successful(Optional.empty());
}
LOG.debug("doLoadAsync - found: {}", metadatas);
return Futures.future(() -> doLoad(metadatas), executionContext);
}
示例6: canSendMore
import java.util.Deque; //导入方法依赖的package包/类
/**
* Can we send more requests to this node?
*
* @param node Node in question
* @return true iff we have no requests still being sent to the given node
*/
// 判断是否可以向指定Node发送请求的条件之一
public boolean canSendMore(String node) {
Deque<NetworkClient.InFlightRequest> queue = requests.get(node);
return queue == null || queue.isEmpty() ||
(queue.peekFirst().send.completed() && // 为true标示当前队头的请求已经发送完成
queue.size() < this.maxInFlightRequestsPerConnection); // 判断队列中是否堆积过多请求,如果堆积了很多未响应的请求,说明这个节点负载可能较大
}
示例7: getAllModuleDependencies
import java.util.Deque; //导入方法依赖的package包/类
public Set<ResolvedDependency> getAllModuleDependencies() {
Set<ResolvedDependency> resolvedElements = new LinkedHashSet<ResolvedDependency>();
Deque<ResolvedDependency> workQueue = new LinkedList<ResolvedDependency>();
workQueue.addAll(loadTransientGraphResults(selectedArtifacts).getRootNode().getPublicView().getChildren());
while (!workQueue.isEmpty()) {
ResolvedDependency item = workQueue.removeFirst();
if (resolvedElements.add(item)) {
final Set<ResolvedDependency> children = item.getChildren();
if (children != null) {
workQueue.addAll(children);
}
}
}
return resolvedElements;
}
示例8: computeSubstitution
import java.util.Deque; //导入方法依赖的package包/类
private final TypeName computeSubstitution(final ClassName input) {
// If the FQ name for this type starts with the root class FQ name,
// then it's a nested type and so the substitution will be in the
// same relative place in the output class. Otherwise, this is
// a supertype/superinterface.
if (input.toString().startsWith(rootClassName.toString())) { // Nested type (or the root type itself)
// Stack the simple names of the nested types starting at the
// end (most deeply nested) back until we hit the root
final Deque<String> stack = new ArrayDeque<>();
for (ClassName iterator = input;
!iterator.equals(rootClassName);
iterator = iterator.enclosingClassName()) {
stack.push(iterator.simpleName());
}
// Now, append the simple names to the output class
// as nested classes
ClassName result = outputClassName;
while (!stack.isEmpty()) {
result = result.nestedClass(stack.pop());
}
return result;
} else { // Supertype/superinterface
return outputClassName;
}
}
示例9: handleSplit
import java.util.Deque; //导入方法依赖的package包/类
private void handleSplit(Deque<Flow> executionDeque, SplitNode splitNode) {
FlowBuilder<Flow> taskAppFlowBuilder =
new FlowBuilder<>("Flow" + UUID.randomUUID().toString());
List<Flow> flows = new ArrayList<>();
//For each node in the split process it as a DSL flow.
for (LabelledTaskNode taskNode : splitNode.getSeries()) {
Deque<Flow> elementFlowDeque = processSplitFlow(taskNode);
while (!elementFlowDeque.isEmpty()) {
flows.add(elementFlowDeque.pop());
}
}
Flow splitFlow = new FlowBuilder.SplitBuilder<>(
new FlowBuilder<Flow>("Split" + UUID.randomUUID().toString()),
taskExecutor)
.add(flows.toArray(new Flow[flows.size()]))
.build();
//remove the nodes of the split since it has already been processed
while (!(this.visitorDeque.peek() instanceof SplitNode)) {
this.visitorDeque.pop();
}
// pop the SplitNode that marks the beginning of the split from the deque
this.visitorDeque.pop();
executionDeque.push(taskAppFlowBuilder.start(splitFlow).end());
}
开发者ID:spring-cloud-task-app-starters,项目名称:composed-task-runner,代码行数:29,代码来源:ComposedRunnerJobFactory.java
示例10: maxSlidingWindow
import java.util.Deque; //导入方法依赖的package包/类
public int[] maxSlidingWindow(int[] nums, int k) {
if (k == 0) {
return new int[0];
}
int n = nums.length;
int[] result = new int[n - k + 1];
int current = 0;
Deque<Integer> deque = new ArrayDeque<>();
for (int i = 0; i < n; i++) {
while (!deque.isEmpty() && deque.peek() < i - k + 1) {
deque.poll();
}
while(!deque.isEmpty() && nums[deque.peekLast()] < nums[i]) {
deque.pollLast();
}
deque.offer(i);
if (i >= k - 1) { // allowing sliding window to fit in full initially
result[current++] = nums[deque.peek()];
}
}
return result;
}
示例11: processSplitFlow
import java.util.Deque; //导入方法依赖的package包/类
/**
* Processes each node in split as a DSL Flow.
* @param node represents a single node in the split.
* @return Deque of Job Flows that was obtained from the Node.
*/
private Deque<Flow> processSplitFlow(LabelledTaskNode node) {
TaskParser taskParser = new TaskParser("split_flow", node.stringify(),
false, true);
ComposedRunnerVisitor splitElementVisitor = new ComposedRunnerVisitor();
taskParser.parse().accept(splitElementVisitor);
Deque splitElementDeque = splitElementVisitor.getFlow();
Deque<Flow> elementFlowDeque = new LinkedList<>();
Deque<Flow> resultFlowDeque = new LinkedList<>();
while (!splitElementDeque.isEmpty()) {
if (splitElementDeque.peek() instanceof TaskAppNode) {
TaskAppNode taskAppNode = (TaskAppNode) splitElementDeque.pop();
if (taskAppNode.hasTransitions()) {
handleTransition(elementFlowDeque, taskAppNode);
}
else {
elementFlowDeque.push(
getTaskAppFlow(taskAppNode));
}
}
else if (splitElementDeque.peek() instanceof FlowNode) {
handleFlowForSegment(elementFlowDeque, resultFlowDeque);
splitElementDeque.pop();
}
}
return resultFlowDeque;
}
开发者ID:spring-cloud-task-app-starters,项目名称:composed-task-runner,代码行数:38,代码来源:ComposedRunnerJobFactory.java
示例12: createMapping
import java.util.Deque; //导入方法依赖的package包/类
private static Map<Class, QName> createMapping(Class... implementations) {
Map<Class, QName> result = new HashMap<>(implementations.length);
for (Class implementation : implementations) {
Deque<Class> toProcess = new ArrayDeque<>();
toProcess.add(implementation);
Class webServiceInterface = null;
do {
Class clazz = toProcess.poll();
if (clazz.getAnnotation(WebService.class) != null && clazz.isInterface()) {
webServiceInterface = clazz;
break;
}
if (clazz.getSuperclass() != null) {
toProcess.add(clazz.getSuperclass());
}
if (clazz.getInterfaces() != null) {
toProcess.addAll(Arrays.asList(clazz.getInterfaces()));
}
}
while (!toProcess.isEmpty());
if (webServiceInterface != null) {
WebService webService = (WebService)webServiceInterface.getAnnotation(WebService.class);
String targetNamespace = webService.targetNamespace();
if (targetNamespace.isEmpty()) {
targetNamespace = getDefaultTargetNamespace(implementation);
}
String serviceName = webService.serviceName();
if (serviceName.isEmpty()) {
serviceName = getDefaultServiceName(implementation);
}
result.put(webServiceInterface, new QName(targetNamespace, serviceName));
}
}
return result;
}
示例13: deleteDirectoryContents
import java.util.Deque; //导入方法依赖的package包/类
/**
* Wipes out content of a directory starting from a given directory.
*
* @param directory to be cleaned
* @param retain if true, the given directory will be retained.
* @throws IOException
*/
public static void deleteDirectoryContents(File directory, boolean retain) throws IOException {
if (!directory.isDirectory()) {
throw new IOException("Not a directory: " + directory);
}
// avoid using guava's Queues.newArrayDeque() since this is a utility class that can be used in
// all sorts of
// contexts, some of which may use clashing guava versions... For example, when explore launches
// a Hive query,
// it includes hive-exec.jar which bundles guava 11 in its jar...
Deque<File> stack = new ArrayDeque<>();
stack.addAll(listFiles(directory));
while (!stack.isEmpty()) {
File file = stack.peekLast();
List<File> files = listFiles(file);
if (files.isEmpty()) {
if (!file.delete()) {
throw new IOException("Failed to delete file " + file);
}
stack.pollLast();
} else {
stack.addAll(files);
}
}
if (!retain) {
if (!directory.delete()) {
throw new IOException("Failed to delete directory " + directory);
}
}
}
示例14: buildNext
import java.util.Deque; //导入方法依赖的package包/类
/**
* Builds the next attempt, plus all reachable verdict attempts.
* Directly after construction of the builder, this will build the start attempt.
*/
void buildNext() {
buildAttempt(getFresh(false).poll());
Deque<TermKey> fresh = getFresh(true);
while (!fresh.isEmpty()) {
buildAttempt(fresh.poll());
}
}
示例15: setAnimation
import java.util.Deque; //导入方法依赖的package包/类
public void setAnimation(Animation animation)
{
this.animation = animation;
Deque<Node<?>> q = new ArrayDeque<Node<?>>(nodes.values());
while(!q.isEmpty())
{
Node<?> node = q.pop();
if(node.getAnimation() != null) continue;
node.setAnimation(animation);
q.addAll(node.getNodes().values());
}
}