本文整理匯總了Java中java.util.LinkedList.removeLast方法的典型用法代碼示例。如果您正苦於以下問題:Java LinkedList.removeLast方法的具體用法?Java LinkedList.removeLast怎麽用?Java LinkedList.removeLast使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類java.util.LinkedList
的用法示例。
在下文中一共展示了LinkedList.removeLast方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: adjustEndGlyphs
import java.util.LinkedList; //導入方法依賴的package包/類
private void adjustEndGlyphs(LinkedList<GSLayoutGlyph> glyphs) {
// Compress last none CRLF glyph if possible
GSLayoutGlyph lastGlyph = glyphs.getLast();
GSLayoutGlyph crlfGlyph = null;
if (GSCharUtils.isNewline(lastGlyph.code()) && glyphs.size() > 1) {
crlfGlyph = lastGlyph;
glyphs.removeLast();
lastGlyph = glyphs.peekLast();
}
if (GSCharUtils.shouldCompressEnd(lastGlyph) && GSCharUtils.canCompress(lastGlyph)) {
lastGlyph.compressEnd = lastGlyph.size * builder.punctuationCompressRate;
}
if (lastGlyph.code() == ' ') {
lastGlyph.compressEnd = lastGlyph.size;
}
if (crlfGlyph != null) {
if (builder.vertical) {
crlfGlyph.y = lastGlyph.getUsedEndSize();
} else {
crlfGlyph.x = lastGlyph.getUsedEndSize();
}
glyphs.addLast(crlfGlyph);
}
}
示例2: save
import java.util.LinkedList; //導入方法依賴的package包/類
private void save(Object entity, LinkedList<Object> context) {
if(entity == null) return;
context.addLast(entity);
EventContainer.addEvent(new Event.SaveEvent(Event.EventType.SAVE, entity));
Collection<Object> cascadeEntity = getCascadeEntity(entity, context);
cascadeEntity.forEach((e) -> {
if(e instanceof Iterable) {
save((Iterable)e, context);
}else {
save(e, context);
}
});
context.removeLast();
}
示例3: getLocalDestination
import java.util.LinkedList; //導入方法依賴的package包/類
/**
* The last arg is expected to be a local path, if only one argument is
* given then the destination will be the current directory
* @param args is the list of arguments
*/
protected void getLocalDestination(LinkedList<String> args)
throws IOException {
String pathString = (args.size() < 2) ? Path.CUR_DIR : args.removeLast();
try {
dst = new PathData(new URI(pathString), getConf());
} catch (URISyntaxException e) {
if (Path.WINDOWS) {
// Unlike URI, PathData knows how to parse Windows drive-letter paths.
dst = new PathData(pathString, getConf());
} else {
throw new IOException("unexpected URISyntaxException", e);
}
}
}
示例4: doVisit
import java.util.LinkedList; //導入方法依賴的package包/類
private void doVisit(FileVisitor visitor, File file, LinkedList<String> relativePath, int segmentIndex, AtomicBoolean stopFlag) {
if (stopFlag.get()) {
return;
}
String segment = patternSegments.get(segmentIndex);
if (segment.contains("**")) {
PatternSet patternSet = new PatternSet();
patternSet.include(includePattern);
patternSet.exclude(excludeSpec);
DirectoryFileTree fileTree = new DirectoryFileTree(baseDir, patternSet);
fileTree.visitFrom(visitor, file, new RelativePath(file.isFile(), relativePath.toArray(new String[relativePath.size()])));
} else if (segment.contains("*") || segment.contains("?")) {
PatternStep step = PatternStepFactory.getStep(segment, false);
File[] children = file.listFiles();
if (children == null) {
if (!file.canRead()) {
throw new GradleException(String.format("Could not list contents of directory '%s' as it is not readable.", file));
}
// else, might be a link which points to nothing, or has been removed while we're visiting, or ...
throw new GradleException(String.format("Could not list contents of '%s'.", file));
}
for (File child : children) {
if (stopFlag.get()) {
break;
}
String childName = child.getName();
if (step.matches(childName)) {
relativePath.addLast(childName);
doVisitDirOrFile(visitor, child, relativePath, segmentIndex + 1, stopFlag);
relativePath.removeLast();
}
}
} else {
relativePath.addLast(segment);
doVisitDirOrFile(visitor, new File(file, segment), relativePath, segmentIndex + 1, stopFlag);
relativePath.removeLast();
}
}
示例5: onMessageConsumed
import java.util.LinkedList; //導入方法依賴的package包/類
private synchronized void onMessageConsumed(ConsumerRecord<String, String> record) {
log.info(String.format("Consumed message: [%s]", record));
TopicPartition topicPartition = new TopicPartition(record.topic(), record.partition());
if (!messagesByTopicPartition.containsKey(topicPartition)) {
messagesByTopicPartition.put(topicPartition, new VersionedMessages(Lists.newLinkedList()));
}
VersionedMessages versionedMessages = messagesByTopicPartition.get(topicPartition);
LinkedList<ConsumerRecord<String, String>> messages = versionedMessages.messages;
messages.addFirst(record);
if (messages.size() > maxTopicMessagesCount) {
messages.removeLast();
}
versionedMessages.version.incrementAndGet();
}
示例6: createTempJsFileWithScript
import java.util.LinkedList; //導入方法依賴的package包/類
private File createTempJsFileWithScript(final Script script, GeneratorOption[] options, final boolean replaceQuotes)
throws IOException {
// Compile script to get file content.
final String content = compile(script, options, replaceQuotes);
final String projectId = getProjectId(script);
Path parentPath = createDirectory(getTempFolder(), projectId); // TODO IDE-
// Get folder structure from qualified names.
final LinkedList<String> segments = moduleQualifiedNameSegments(script);
// Pop the file name from the segments.
final String fileName = segments.removeLast();
// Recursively create temporary folder structure.
for (final String folderName : segments) {
parentPath = createDirectory(parentPath, folderName);
}
final File file = new File(parentPath.toFile(), fileName + ".js");
if (!file.exists()) {
if (!file.createNewFile()) {
throw new RuntimeException("Exception when creating new file: " + file);
}
}
file.deleteOnExit();
try (final PrintWriter pw = new PrintWriter(file)) {
pw.print(content); // Make sure not to append but override content.
}
return file;
}
示例7: insertHighlightedLearner
import java.util.LinkedList; //導入方法依賴的package包/類
/**
* Puts the searched learner in front of other learners in the list.
*/
private static List<User> insertHighlightedLearner(User searchedLearner, List<User> latestLearners, int limit) {
latestLearners.remove(searchedLearner);
LinkedList<User> updatedLatestLearners = new LinkedList<User>(latestLearners);
updatedLatestLearners.addFirst(searchedLearner);
if (updatedLatestLearners.size() > limit) {
updatedLatestLearners.removeLast();
}
return updatedLatestLearners;
}
示例8: addRecentCache
import java.util.LinkedList; //導入方法依賴的package包/類
private static void addRecentCache(Context context, Author... authors) {
final LinkedList<Author> localCache = getRecentCache(context);
// 避免重複添加
for (Author author : authors) {
if (author == null
|| author.getId() <= 0
|| TextUtils.isEmpty(author.getName())
|| author.getId() == AccountHelper.getUserId())
continue;
if (checkInContacts(localCache, author)) {
// 移除後添加到頭部
int index = indexOfContacts(localCache, author);
if (index >= 0) {
localCache.remove(index);
localCache.addFirst(author);
}
} else {
localCache.addFirst(author);
}
}
// 至多存儲15條
while (localCache.size() > 10) {
localCache.removeLast();
}
CacheManager.saveToJson(context, RECENT_CACHE_FILE, localCache);
}
示例9: calcIndents_processClosingTag
import java.util.LinkedList; //導入方法依賴的package包/類
private void calcIndents_processClosingTag(final String tagName, final int tagClosedOnLine, final TransferData transferData, final LinkedList<TagIndentationData> unprocessedOpeningTags, final Collection<TagIndentationData> matchedOpeningTags) throws BadLocationException {
LinkedList<TagIndentationData> tagsToBeRemoved = new LinkedList<TagIndentationData>();
while (!unprocessedOpeningTags.isEmpty()) {
TagIndentationData processedTD = unprocessedOpeningTags.removeLast();
if (areTagNamesEqual(tagName, processedTD.getTagName())) {
processedTD.setClosedOnLine(tagClosedOnLine);
matchedOpeningTags.add(processedTD);
// mark all the stuff between unformattable tag as unformattable
if (isUnformattableTag(tagName)) {
for (int i = tagClosedOnLine - 1; i > processedTD.getLine(); i--) {
transferData.setNonFormattable(i);
}
}
// forgetting preceding tags permanently
tagsToBeRemoved.clear();
break;
} else {
tagsToBeRemoved.add(processedTD);
}
}
// if matching opening tag was not found on the stack put all the tags back
unprocessedOpeningTags.addAll(tagsToBeRemoved);
}
示例10: finalRemove
import java.util.LinkedList; //導入方法依賴的package包/類
protected void finalRemove(JobInfo what, LinkedList<JobInfo> list, int position) {
switch (position) {
case 1:
list.removeFirst();
break;
case 2:
list.removeLast();
break;
default:
list.remove(what);
break;
}
}
示例11: makeVersion
import java.util.LinkedList; //導入方法依賴的package包/類
private String makeVersion ( final String version, final String qualifier )
{
if ( version == null )
{
// no version at all
return null;
}
final LinkedList<String> toks = new LinkedList<String> ( Arrays.asList ( version.split ( "(\\.|-)" ) ) );
getLog ().debug ( "Version split: " + toks );
while ( toks.size () > 3 )
{
toks.removeLast ();
}
while ( toks.size () < 3 )
{
toks.add ( "0" );
}
if ( qualifier != null && !qualifier.isEmpty () )
{
toks.add ( qualifier );
}
final StringBuilder sb = new StringBuilder ();
while ( !toks.isEmpty () )
{
if ( sb.length () > 0 )
{
sb.append ( '.' );
}
sb.append ( toks.pollFirst () );
}
return sb.toString ();
}
示例12: processOptions
import java.util.LinkedList; //導入方法依賴的package包/類
@Override
protected void processOptions(LinkedList<String> args) throws IOException {
if (args.size() == 0) {
throw new IllegalArgumentException("<snapshotDir> is missing.");
}
if (args.size() > 2) {
throw new IllegalArgumentException("Too many arguments.");
}
if (args.size() == 2) {
snapshotName = args.removeLast();
}
}
示例13: deleteEntity
import java.util.LinkedList; //導入方法依賴的package包/類
private void deleteEntity(Object entity, LinkedList<Object> context) {
if(entity == null) return;
context.addLast(entity);
Object id = ReflectionUtils.getAnnotatedFieldValue(entity, Id.class);
if(id == null)
id = ReflectionUtils.getAnnotatedMethodReturnValue(entity, Id.class);
if(id == null)
throw new EventPublishException("Can't get entity id from " + entity);
Class<?> domainClass = entity.getClass();
String index = DocumentUtils.getIndexName(domainClass);
String type = DocumentUtils.getTypeName(domainClass);
EventContainer.addEvent(new Event.DeleteEvent(Event.EventType.DELETE, id, index, type, null));
Collection<Object> cascadeEntity = getCascadeEntity(entity, context);
cascadeEntity.forEach((e) -> {
if(e instanceof Iterable) {
deleteIterable((Iterable)e, context);
}else {
deleteEntity(e, context);
}
});
context.removeLast();
}
示例14: finalRemove
import java.util.LinkedList; //導入方法依賴的package包/類
private void finalRemove(JobInfo what, LinkedList<JobInfo> list, int position) {
switch (position) {
case 1:
list.removeFirst();
break;
case 2:
list.removeLast();
break;
default:
list.remove(what);
break;
}
}
示例15: diff_lineMode
import java.util.LinkedList; //導入方法依賴的package包/類
/**
* Do a quick line-level diff on both strings, then rediff the parts for
* greater accuracy.
* This speedup can produce non-minimal diffs.
* @param text1 Old string to be diffed.
* @param text2 New string to be diffed.
* @param deadline Time when the diff should be complete by.
* @return Linked List of Diff objects.
*/
private LinkedList<Diff> diff_lineMode(String text1, String text2,
long deadline) {
// Scan the text on a line-by-line basis first.
LinesToCharsResult b = diff_linesToChars(text1, text2);
text1 = b.chars1;
text2 = b.chars2;
List<String> linearray = b.lineArray;
LinkedList<Diff> diffs = diff_main(text1, text2, false, deadline);
// Convert the diff back to original text.
diff_charsToLines(diffs, linearray);
// Eliminate freak matches (e.g. blank lines)
diff_cleanupSemantic(diffs);
// Rediff any replacement blocks, this time character-by-character.
// Add a dummy entry at the end.
diffs.add(new Diff(Operation.EQUAL, ""));
int count_delete = 0;
int count_insert = 0;
String text_delete = "";
String text_insert = "";
ListIterator<Diff> pointer = diffs.listIterator();
Diff thisDiff = pointer.next();
while (thisDiff != null) {
switch (thisDiff.operation) {
case INSERT:
count_insert++;
text_insert += thisDiff.text;
break;
case DELETE:
count_delete++;
text_delete += thisDiff.text;
break;
case EQUAL:
// Upon reaching an equality, check for prior redundancies.
if (count_delete >= 1 && count_insert >= 1) {
// Delete the offending records and add the merged ones.
pointer.previous();
for (int j = 0; j < count_delete + count_insert; j++) {
pointer.previous();
pointer.remove();
}
for (Diff newDiff : diff_main(text_delete, text_insert, false,
deadline)) {
pointer.add(newDiff);
}
}
count_insert = 0;
count_delete = 0;
text_delete = "";
text_insert = "";
break;
}
thisDiff = pointer.hasNext() ? pointer.next() : null;
}
diffs.removeLast(); // Remove the dummy entry at the end.
return diffs;
}