本文整理汇总了Java中java.util.ListIterator.previous方法的典型用法代码示例。如果您正苦于以下问题:Java ListIterator.previous方法的具体用法?Java ListIterator.previous怎么用?Java ListIterator.previous使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.ListIterator
的用法示例。
在下文中一共展示了ListIterator.previous方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getIterator
import java.util.ListIterator; //导入方法依赖的package包/类
/**
* Returns an iterator for the specified glyphs, sorted either ascending or descending.
*
* @param glyphs The glyphs to return if present
* @return An iterator of the sorted list of glyphs
*/
private Iterator getIterator(List glyphs) {
if (orderAscending) return glyphs.iterator();
final ListIterator iter = glyphs.listIterator(glyphs.size());
return new Iterator() {
public boolean hasNext () {
return iter.hasPrevious();
}
public Object next () {
return iter.previous();
}
public void remove () {
iter.remove();
}
};
}
示例2: processChangeTransactions
import java.util.ListIterator; //导入方法依赖的package包/类
private void processChangeTransactions(
ListIterator<ChangeTransaction> chIter, Date date) {
while (chIter.hasNext()) {
ChangeTransaction ct = chIter.next();
if (ct.getDate().before(date) && ct.getDate().before(portfolioDate)) {
// System.out.println("process date: " + ct.getDate() + " " +
// date);
for (Account a : accounts) {
a.process(ct);
}
} else {
// System.out.println("date: " + ct.getDate() + " " + date);
chIter.previous();
break;
}
}
}
示例3: reverse
import java.util.ListIterator; //导入方法依赖的package包/类
@Override
protected Iterable<LayoutHelper> reverse() {
final ListIterator<LayoutHelper> i = mLayoutHelpers.listIterator(mLayoutHelpers.size());
return new Iterable<LayoutHelper>() {
@Override
public Iterator<LayoutHelper> iterator() {
return new Iterator<LayoutHelper>() {
public boolean hasNext() {
return i.hasPrevious();
}
public LayoutHelper next() {
return i.previous();
}
public void remove() {
i.remove();
}
};
}
};
}
示例4: getSectionHeader
import java.util.ListIterator; //导入方法依赖的package包/类
/**
* Get the first header before the given position.
* @param position position before which to find the next header
* @return the first header before the given position.
*/
public BaseBrick getSectionHeader(int position) {
if (position >= 0) {
BaseBrick brick = dataManager.getRecyclerViewItems().get(position);
if (brick != null && brick.isHeader()) {
return brick;
}
ListIterator<BaseBrick> iterator = dataManager.getRecyclerViewItems().listIterator(position);
while (iterator.hasPrevious()) {
brick = iterator.previous();
if (brick != null && brick.isHeader()) {
return brick;
}
}
}
return null;
}
示例5: getRewindedIterator
import java.util.ListIterator; //导入方法依赖的package包/类
private ListIterator<T> getRewindedIterator(T resource, Type type) {
String resourceName = provider.getName(resource);
T parent = provider.getParent(resource);
Iterator<T> iterator;
if (parent == null) {
iterator = IteratorUtils.singleElementIterator(resource);
} else {
iterator = provider.listChildren(parent);
}
ListIterator<T> listIterator = new LazyList<T>(iterator).listIterator();
while (listIterator.hasNext()) {
T sibling = listIterator.next();
if (provider.getName(sibling).equals(resourceName)) {
break;
}
}
if (type == Type.PREV) {
listIterator.previous();
}
return listIterator;
}
示例6: listIterator_set
import java.util.ListIterator; //导入方法依赖的package包/类
@Test
public void listIterator_set() {
if (skipTest(CollectionClass.REALMRESULTS, CollectionClass.REALMRESULTS_SNAPSHOT_RESULTS_BASE,
CollectionClass.REALMRESULTS_SNAPSHOT_LIST_BASE)) {
return;
}
realm.beginTransaction();
ListIterator<AllJavaTypes> it = collection.listIterator();
// Calling set() before next() should throw.
try {
it.set(new AllJavaTypes());
fail();
} catch (IllegalStateException ignored) {
}
AllJavaTypes obj = it.next();
assertEquals(0, obj.getFieldLong());
it.set(new AllJavaTypes(42));
it.next();
it.previous(); // A big ListIterator WTF!, but it is by design.
obj = it.previous();
assertEquals(42, obj.getFieldLong());
}
示例7: compress
import java.util.ListIterator; //导入方法依赖的package包/类
/**
* Try to remove extraneous items from the set of sampled items. This checks
* if an item is unnecessary based on the desired error bounds, and merges it
* with the adjacent item if it is.
*/
private void compress() {
if (samples.size() < 2) {
return;
}
ListIterator<SampleItem> it = samples.listIterator();
SampleItem prev = null;
SampleItem next = it.next();
while (it.hasNext()) {
prev = next;
next = it.next();
if (prev.g + next.g + next.delta <= allowableError(it.previousIndex())) {
next.g += prev.g;
// Remove prev. it.remove() kills the last thing returned.
it.previous();
it.previous();
it.remove();
// it.next() is now equal to next, skip it back forward again
it.next();
}
}
}
示例8: reverse
import java.util.ListIterator; //导入方法依赖的package包/类
static <T> Iterable<T> reverse(final List<T> list) {
return new Iterable<T>() {
@Override
public Iterator<T> iterator() {
final ListIterator<T> listIter = list.listIterator(list.size());
return new Iterator<T>() {
@Override
public boolean hasNext() {
return listIter.hasPrevious();
}
@Override
public T next() {
return listIter.previous();
}
@Override
public void remove() {
listIter.remove();
}
};
}
};
}
示例9: getSelectedNoteAnnotation
import java.util.ListIterator; //导入方法依赖的package包/类
public NoteAnnotation getSelectedNoteAnnotation()
{
if (mAnnotations != null)
{
// iterate in reverse order
ListIterator<PageAnnotation> li = mAnnotations.listIterator(mAnnotations.size());
while (li.hasPrevious())
{
PageAnnotation annot = li.previous();
if ((annot instanceof NoteAnnotation) && annot.isSelected())
{
return (NoteAnnotation)annot;
}
}
}
return null;
}
示例10: toMap
import java.util.ListIterator; //导入方法依赖的package包/类
/***
*
* convert the object into a map and al its children
*
* @return the map
*/
public HashMap<String, Object> toMap() {
HashMap<String, Object> result = new HashMap<>();
result.put("mMessage", mmessage);
result.put("IdUser", iduser);
result.put("IdMessage", idmessage);
if(children!=null){
ListIterator iterator = children.listIterator();
while(iterator.hasNext()){
Message child= (Message) iterator.next();
HashMap<String,Object> contacthashed= child.toMap();
iterator.previous();
iterator.set(contacthashed);
iterator.next();
}}
result.put("Children", children);
return result;
}
示例11: getNextAvailablePosition
import java.util.ListIterator; //导入方法依赖的package包/类
private int getNextAvailablePosition(int index, boolean isDeletion) {
if (listValidCursorPositions.contains(index)) {
final int i = listValidCursorPositions.indexOf(index);
final ListIterator<Integer> iterator = listValidCursorPositions.listIterator(i);
if (isDeletion) {
if (iterator.hasPrevious()) return iterator.previous() + 1;
} else {
if (iterator.hasNext()) return iterator.next();
}
return index;
} else {
return findCloserIndex(index, isDeletion);
}
}
示例12: initializeNoteNameRegex
import java.util.ListIterator; //导入方法依赖的package包/类
private static String initializeNoteNameRegex()
{
// noteName is built using the keys from the noteNameOffsets hashmap
// The reverserList is a bit ridiculous, but necessary to reverse the
// order of the the keys so that Do and Fa come before D and F.
// (There is no .previous() method for a regular Iterator.)
ArrayList< String > reverserList = new ArrayList< String >();
Iterator< String > iterator = noteNameOffsets.keySet().iterator();
while( iterator.hasNext() )
{
reverserList.add( iterator.next() );
}
// so that Do comes before D and is found first.
String nNR = "(";
ListIterator< String > listIterator = reverserList.listIterator( reverserList.size() );
while( listIterator.hasPrevious() )
{
nNR += listIterator.previous() + "|";
}
// remove last | or empty string is included
nNR = nNR.substring( 0, nNR.length() - 1 );
nNR += ")";
return nNR;
}
示例13: sendMultipleThreadNotification
import java.util.ListIterator; //导入方法依赖的package包/类
private static void sendMultipleThreadNotification(@NonNull Context context,
@NonNull NotificationState notificationState,
boolean signal)
{
MultipleRecipientNotificationBuilder builder = new MultipleRecipientNotificationBuilder(context, TextSecurePreferences.getNotificationPrivacy(context));
List<NotificationItem> notifications = notificationState.getNotifications();
builder.setMessageCount(notificationState.getMessageCount(), notificationState.getThreadCount());
builder.setMostRecentSender(notifications.get(0).getIndividualRecipient());
builder.setGroup(NOTIFICATION_GROUP);
long timestamp = notifications.get(0).getTimestamp();
if (timestamp != 0) builder.setWhen(timestamp);
builder.addActions(notificationState.getMarkAsReadIntent(context, SUMMARY_NOTIFICATION_ID));
ListIterator<NotificationItem> iterator = notifications.listIterator(notifications.size());
while(iterator.hasPrevious()) {
NotificationItem item = iterator.previous();
builder.addMessageBody(item.getIndividualRecipient(), item.getText());
}
if (signal) {
builder.setAlarms(notificationState.getRingtone(), notificationState.getVibrate());
builder.setTicker(notifications.get(0).getIndividualRecipient(),
notifications.get(0).getText());
}
NotificationManagerCompat.from(context).notify(SUMMARY_NOTIFICATION_ID, builder.build());
}
示例14: restore
import java.util.ListIterator; //导入方法依赖的package包/类
/**
* Restore the text to original. Opposite to applyTo() method.
*
* @param target the given target
* @return the restored text
*/
public List<T> restore(List<T> target) {
List<T> result = new ArrayList<>(target);
ListIterator<Delta<T>> it = getDeltas().listIterator(deltas.size());
while (it.hasPrevious()) {
Delta<T> delta = it.previous();
delta.restore(result);
}
return result;
}
示例15: last
import java.util.ListIterator; //导入方法依赖的package包/类
/**
* Returns the last element matching the given [predicate].
*
* @throws [NoSuchElementException] if no such element is found.
*/
public static <E> E last( @This List<E> thiz, Predicate<E> predicate )
{
ListIterator<E> iterator = thiz.listIterator( thiz.size() );
while( iterator.hasPrevious() )
{
E element = iterator.previous();
if( predicate.test( element ) )
{
return element;
}
}
throw new NoSuchElementException( "List contains no element matching the predicate." );
}