本文整理汇总了Java中java.util.Deque.removeLast方法的典型用法代码示例。如果您正苦于以下问题:Java Deque.removeLast方法的具体用法?Java Deque.removeLast怎么用?Java Deque.removeLast使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.Deque
的用法示例。
在下文中一共展示了Deque.removeLast方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: visitDepthFirst
import java.util.Deque; //导入方法依赖的package包/类
private void visitDepthFirst(AST ast) {
if ( ast == null ) {
return;
}
Deque<AST> stack = new ArrayDeque<AST>();
stack.addLast( ast );
while ( !stack.isEmpty() ) {
ast = stack.removeLast();
strategy.visit( ast );
if ( ast.getNextSibling() != null ) {
stack.addLast( ast.getNextSibling() );
}
if ( ast.getFirstChild() != null ) {
stack.addLast( ast.getFirstChild() );
}
}
}
示例2: chooseDbSource
import java.util.Deque; //导入方法依赖的package包/类
public static File chooseDbSource(Shell shell, IPreferenceStore prefStore, boolean dir) {
String pathToDump = dir ? getDirPath(shell, prefStore) : getFilePath(shell, prefStore);
if (pathToDump == null) {
return null;
}
File dumpFile = new File(pathToDump);
Deque<File> dumpHistory = stringToDumpFileHistory(prefStore.getString(PREF.DB_STORE_FILES));
dumpHistory.addFirst(dumpFile);
while (dumpHistory.size() > MAX_FILES_HISTORY) {
dumpHistory.removeLast();
}
prefStore.setValue(PREF.DB_STORE_FILES, dumpFileHistoryToPreference(dumpHistory));
prefStore.setValue(PREF.LAST_OPENED_LOCATION,
dir ? dumpFile.getAbsolutePath() : dumpFile.getParent());
return dumpFile;
}
示例3: visit
import java.util.Deque; //导入方法依赖的package包/类
@NonNull
private static List<JavaFileObject> visit(
@NonNull final File folder,
@NonNull final File root,
@NonNull final Charset encoding,
@NullAllowed final JavaFileFilterImplementation filter,
final boolean recursive,
@NonNull Function<File,JavaFileObject.Kind> accept) {
final List<JavaFileObject> res = new ArrayList<>();
final Deque<File> todo = new ArrayDeque<>();
todo.offer(folder);
while (!todo.isEmpty()) {
final File active = todo.removeLast(); //DFS
final File[] content = active.listFiles();
if (content != null) {
for (File f : content) {
final JavaFileObject.Kind fKind = accept.apply(f);
if (fKind != null) {
res.add(FileObjects.fileFileObject(
f,
root,
filter,
fKind == JavaFileObject.Kind.CLASS ?
UNKNOWN_CHARSET :
encoding));
} else if (recursive && f.isDirectory()) {
todo.offer(f);
}
}
}
}
return Collections.unmodifiableList(res);
}
示例4: close
import java.util.Deque; //导入方法依赖的package包/类
@Override
public void close() {
Deque<PathElement> ancestors = getAncestors();
for (int i = 0; i < this.count; i++) {
ancestors.removeLast();
}
}
示例5: writeItem
import java.util.Deque; //导入方法依赖的package包/类
/**
* Write a collection item.
*/
private void writeItem(final Writer writer, final Map<String, Processor<?>> tags, final TagContext tagContext, final int end,
final Deque<Object> contextData, final Object value) throws IOException {
contextData.add(value);
write(writer, tags, tagContext.cursor + tagContext.tag.length() + 4, end, contextData);
contextData.removeLast();
}
示例6: newLogger
import java.util.Deque; //导入方法依赖的package包/类
private TransformerLogger<String> newLogger(final AtomicInteger numberOfMessagesToAdd,
TransformerDebug transformerDebug, TransformerConfig transformerConfig)
{
TransformerLogger<String> log = new TransformerLogger<String>()
{
@Override
protected void addOrModify(Deque<String> entries, Object message)
{
int i = numberOfMessagesToAdd.get();
if (i > 0)
{
for (; i > 0; i--)
{
entries.add((String)message);
}
}
else if (i < 0)
{
for (; i < 0; i++)
{
entries.removeLast();
}
}
else
{
entries.removeLast();
entries.add((String)message);
}
}
@Override
protected int getUpperMaxEntries()
{
return 176;
}
@Override
protected String getPropertyName()
{
return "property.name";
}
};
log.setTransformerDebug(transformerDebug);
log.setTransformerConfig(transformerConfig);
return log;
}
示例7: getScriptContext
import java.util.Deque; //导入方法依赖的package包/类
/**
* @return null if there is no staging folder
*/
private ScriptContext getScriptContext(SectionInfo info, boolean request, boolean clientSide)
{
final Map<String, Object> extra = new HashMap<String, Object>();
extra.put(AdvancedScriptWebControlConstants.PREFIX, getFormName());
if( clientSide )
{
final RenderContext context = (RenderContext) info;
final ScriptVariable thisVar = new ScriptVariable("this");
final OverrideHandler submitHandler = new OverrideHandler(HANDLE_SUBMIT_FUNCTION, thisVar, submitFunction);
extra.put(AdvancedScriptWebControlConstants.SUBMIT_JS,
submitHandler.getStatements(context) + " return false;");
// required!
context.preRender(submitHandler);
}
if( request )
{
Map<Object, Object> paramMap = new HashMap<>();
paramMap.putAll(info.getRequest().getParameterMap());
String submitter = info.getAttribute(SUBMITTER_NAME_KEY);
if( !Check.isEmpty(submitter) )
{
paramMap.put(submitter, info.getAttribute(SUBMITTER_VALUE_KEY));
}
extra.put(AdvancedScriptWebControlConstants.REQUEST_MAP, paramMap);
}
final WebRepository repo = (WebRepository) getRepository();
extra.put(AdvancedScriptWebControlConstants.WIZARD_ID, repo.getWizid());
// add the magic 'attributes' bag (this passes data between
// scripts/templates)
final String attributesKey = repo.getWizid() + "_" + getFormName() + "_attributes";
XmlScriptType att = sessionService.getAttribute(attributesKey);
if( att == null )
{
att = new PropBagWrapper(new PropBagEx());
}
sessionService.setAttribute(attributesKey, att);
extra.put(AdvancedScriptWebControlConstants.ATTRIBUTES, att);
final WizardState wizState = repo.getState();
final ScriptContext scriptContext = wizardService.createScriptContext(wizState, storageControl.getWizardPage(),
storageControl, extra);
scriptContext.setLogger(logger);
PropBagWrapper xml = scriptContext.getXml();
xml.clearOverrides();
Deque<Pair<String, Integer>> pathOverrides = wizState.getPathOverrides();
while( !pathOverrides.isEmpty() )
{
Pair<String, Integer> override = pathOverrides.removeLast();
xml.pushOverride(override.getFirst(), override.getSecond());
}
return scriptContext;
}
示例8: findPaths
import java.util.Deque; //导入方法依赖的package包/类
/**
* Returns all paths reachable from the given targets.
*/
private Set<Deque<Archive>> findPaths(Graph<Archive> graph, Archive target) {
// path is in reversed order
Deque<Archive> path = new LinkedList<>();
path.push(target);
Set<Edge<Archive>> visited = new HashSet<>();
Deque<Edge<Archive>> deque = new LinkedList<>();
deque.addAll(graph.edgesFrom(target));
if (deque.isEmpty()) {
return makePaths(path).collect(Collectors.toSet());
}
Set<Deque<Archive>> allPaths = new HashSet<>();
while (!deque.isEmpty()) {
Edge<Archive> edge = deque.pop();
if (visited.contains(edge))
continue;
Archive node = edge.v;
path.addLast(node);
visited.add(edge);
Set<Edge<Archive>> unvisitedDeps = graph.edgesFrom(node)
.stream()
.filter(e -> !visited.contains(e))
.collect(Collectors.toSet());
trace("visiting %s %s (%s)%n", edge, path, unvisitedDeps);
if (unvisitedDeps.isEmpty()) {
makePaths(path).forEach(allPaths::add);
path.removeLast();
}
// push unvisited adjacent edges
unvisitedDeps.stream().forEach(deque::push);
// when the adjacent edges of a node are visited, pop it from the path
while (!path.isEmpty()) {
if (visited.containsAll(graph.edgesFrom(path.peekLast())))
path.removeLast();
else
break;
}
}
return allPaths;
}