本文整理汇总了Java中java.util.Deque.remove方法的典型用法代码示例。如果您正苦于以下问题:Java Deque.remove方法的具体用法?Java Deque.remove怎么用?Java Deque.remove使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.Deque
的用法示例。
在下文中一共展示了Deque.remove方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findAncestor
import java.util.Deque; //导入方法依赖的package包/类
/**
* Traverse ancestors of the given type, in the same order as {@link #ancestors(Class, boolean)},
* and return the first ancestor for which the given predicate returns true.
*/
public static @Nullable <U> Class<? extends U> findAncestor(Class<? extends U> type, Class<U> upperBound, java.util.function.Predicate<Class<?>> pred) {
Deque<Class<? extends U>> queue = new ArrayDeque<>();
queue.add(type);
while(!queue.isEmpty()) {
final Class<? extends U> t = queue.remove();
if(pred.test(t)) return t;
if(t.getSuperclass() != null && upperBound.isAssignableFrom(t.getSuperclass())) {
queue.add((Class<? extends U>) t.getSuperclass());
}
for(Class<?> iface : t.getInterfaces()) {
if(upperBound.isAssignableFrom(iface)) {
queue.add((Class<? extends U>) iface);
}
}
}
return null;
}
示例2: extract
import java.util.Deque; //导入方法依赖的package包/类
/**
* Attempts to extract all kernels from the given nested loop tree, according
* to judgements made by the given dependency checker.
*
* @param clazz Class concerned.
* @param loops Root level set of loop nestings.
* @param check Dependency checker.
* @return Number of kernels successfully extracted.
*/
public static int extract(ClassNode clazz, Set<Tree<TrivialLoop>> loops, DependencyCheck check) {
Deque<Tree<TrivialLoop>> consider = new LinkedList<Tree<TrivialLoop>>();
int count = 0;
consider.addAll(loops);
while(!consider.isEmpty()) {
Tree<TrivialLoop> level = consider.remove();
if(extract(clazz, level, check)) {
count++;
} else {
consider.addAll(level.getChildren());
}
}
return count;
}
示例3: abortUndrainedBatches
import java.util.Deque; //导入方法依赖的package包/类
/**
* Abort any batches which have not been drained
*/
void abortUndrainedBatches(RuntimeException reason) {
for (ProducerBatch batch : incomplete.copyAll()) {
Deque<ProducerBatch> dq = getDeque(batch.topicPartition);
boolean aborted = false;
synchronized (dq) {
if (!batch.isClosed()) {
aborted = true;
batch.abortRecordAppends();
dq.remove(batch);
}
}
if (aborted) {
batch.abort(reason);
deallocate(batch);
}
}
}
示例4: finished
import java.util.Deque; //导入方法依赖的package包/类
private <T> void finished(Deque<T> calls, T call, boolean promoteCalls) {
int runningCallsCount;
Runnable idleCallback;
synchronized (this) {
if (!calls.remove(call)) throw new AssertionError("Call wasn't in-flight!");
if (promoteCalls) promoteCalls();
runningCallsCount = runningCallsCount();
idleCallback = this.idleCallback;
}
if (runningCallsCount == 0 && idleCallback != null) {
idleCallback.run();
}
}
示例5: findForAncestor
import java.util.Deque; //导入方法依赖的package包/类
/**
* Traverse ancestors of the given type, in the same order as {@link #ancestors(Class, boolean)},
* applying the given function to each ancestor, and return the first non-null result, or null
* if the function returns null for all ancestors.
*/
public static @Nullable <T, R> R findForAncestor(Class<T> type, Function<Class<? super T>, R> func) {
Deque<Class<? super T>> queue = new ArrayDeque<>();
queue.add(type);
while(!queue.isEmpty()) {
final Class<? super T> t = queue.remove();
final R result = func.apply(t);
if(result != null) return result;
if(t.getSuperclass() != null) queue.add(t.getSuperclass());
Collections.addAll(queue, (Class<? super T>[]) t.getInterfaces());
}
return null;
}
示例6: abortBatches
import java.util.Deque; //导入方法依赖的package包/类
/**
* Abort all incomplete batches (whether they have been sent or not)
*/
void abortBatches(final RuntimeException reason) {
for (ProducerBatch batch : incomplete.copyAll()) {
Deque<ProducerBatch> dq = getDeque(batch.topicPartition);
synchronized (dq) {
batch.abortRecordAppends();
dq.remove(batch);
}
batch.abort(reason);
deallocate(batch);
}
}
示例7: updateRegionLoad
import java.util.Deque; //导入方法依赖的package包/类
/**
* Store the current region loads.
*/
private synchronized void updateRegionLoad() {
// We create a new hashmap so that regions that are no longer there are removed.
// However we temporarily need the old loads so we can use them to keep the rolling average.
Map<String, Deque<RegionLoad>> oldLoads = loads;
loads = new HashMap<String, Deque<RegionLoad>>();
for (ServerName sn : clusterStatus.getServers()) {
ServerLoad sl = clusterStatus.getLoad(sn);
if (sl == null) {
continue;
}
for (Entry<byte[], RegionLoad> entry : sl.getRegionsLoad().entrySet()) {
Deque<RegionLoad> rLoads = oldLoads.get(Bytes.toString(entry.getKey()));
if (rLoads == null) {
// There was nothing there
rLoads = new ArrayDeque<RegionLoad>();
} else if (rLoads.size() >= numRegionLoadsToRemember) {
rLoads.remove();
}
rLoads.add(entry.getValue());
loads.put(Bytes.toString(entry.getKey()), rLoads);
}
}
for(CostFromRegionLoadFunction cost : regionLoadFunctions) {
cost.setLoads(loads);
}
}
示例8: LabelBuilder
import java.util.Deque; //导入方法依赖的package包/类
LabelBuilder(final Feature feature, final TestCase scenario, final Deque<PickleTag> tags) {
final TagParser tagParser = new TagParser(feature, scenario);
getScenarioLabels().add(createFeatureLabel(feature.getName()));
getScenarioLabels().add(createStoryLabel(scenario.getName()));
while (tags.peek() != null) {
final PickleTag tag = tags.remove();
final String tagString = tag.getName();
if (tagString.contains(COMPOSITE_TAG_DELIMITER)) {
final String[] tagParts = tagString.split(COMPOSITE_TAG_DELIMITER, 2);
if (StringUtils.isEmpty(tagParts[1])) {
// skip empty tags, e.g. '@tmsLink=', to avoid formatter errors
continue;
}
final String tagKey = tagParts[0].toUpperCase();
final String tagValue = tagParts[1];
// Handle composite named links
if (tagKey.startsWith(PLAIN_LINK + ".")) {
tryHandleNamedLink(tagString);
continue;
}
switch (tagKey) {
case SEVERITY:
getScenarioLabels().add(createSeverityLabel(tagValue.toLowerCase()));
break;
case TMS_LINK:
getScenarioLinks().add(createTmsLink(tagValue));
break;
case ISSUE_LINK:
getScenarioLinks().add(createIssueLink(tagValue));
break;
case PLAIN_LINK:
getScenarioLinks().add(createLink(null, tagValue, tagValue, null));
break;
default:
LOGGER.warn("Composite tag {} is not supported. adding it as RAW", tagKey);
getScenarioLabels().add(getTagLabel(tag));
break;
}
} else if (tagParser.isPureSeverityTag(tag)) {
getScenarioLabels().add(createSeverityLabel(tagString.substring(1)));
} else if (!tagParser.isResultTag(tag)) {
getScenarioLabels().add(getTagLabel(tag));
}
}
getScenarioLabels().add(new Label().withName("host").withValue(getHostName()));
getScenarioLabels().add(new Label().withName("package").withValue(feature.getName()));
getScenarioLabels().add(new Label().withName("suite").withValue(feature.getName()));
getScenarioLabels().add(new Label().withName("testClass").withValue(scenario.getName()));
getScenarioLabels().add(new Label().withName("thread").withValue(getThreadName()));
}
示例9: LabelBuilder
import java.util.Deque; //导入方法依赖的package包/类
LabelBuilder(final Feature feature, final Scenario scenario, final Deque<Tag> tags) {
final TagParser tagParser = new TagParser(feature, scenario);
getScenarioLabels().add(createFeatureLabel(feature.getName()));
getScenarioLabels().add(createStoryLabel(scenario.getName()));
while (tags.peek() != null) {
final Tag tag = tags.remove();
final String tagString = tag.getName();
if (tagString.contains(COMPOSITE_TAG_DELIMITER)) {
final String[] tagParts = tagString.split(COMPOSITE_TAG_DELIMITER, 2);
if (StringUtils.isEmpty(tagParts[1])) {
// skip empty tags, e.g. '@tmsLink=', to avoid formatter errors
continue;
}
final String tagKey = tagParts[0].toUpperCase();
final String tagValue = tagParts[1];
// Handle composite named links
if (tagKey.startsWith(PLAIN_LINK + ".")) {
tryHandleNamedLink(tagString);
continue;
}
switch (tagKey) {
case SEVERITY:
getScenarioLabels().add(createSeverityLabel(tagValue.toLowerCase()));
break;
case TMS_LINK:
getScenarioLinks().add(ResultsUtils.createTmsLink(tagValue));
break;
case ISSUE_LINK:
getScenarioLinks().add(ResultsUtils.createIssueLink(tagValue));
break;
case PLAIN_LINK:
getScenarioLinks().add(ResultsUtils.createLink(null, tagValue, tagValue, null));
break;
default:
LOGGER.warn("Composite tag {} is not supported. adding it as RAW", tagKey);
getScenarioLabels().add(getTagLabel(tag));
break;
}
} else if (tagParser.isPureSeverityTag(tag)) {
getScenarioLabels().add(createSeverityLabel(tagString.substring(1)));
} else if (!tagParser.isResultTag(tag)) {
getScenarioLabels().add(getTagLabel(tag));
}
}
getScenarioLabels().add(new Label().withName("host").withValue(getHostName()));
getScenarioLabels().add(new Label().withName("package").withValue(feature.getName()));
getScenarioLabels().add(new Label().withName("suite").withValue(feature.getName()));
getScenarioLabels().add(new Label().withName("testClass").withValue(scenario.getName()));
getScenarioLabels().add(new Label().withName("thread").withValue(getThreadName()));
}