当前位置: 首页>>代码示例>>Java>>正文


Java ListIterator.previous方法代码示例

本文整理汇总了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();
		}
	};
}
 
开发者ID:j-dong,项目名称:trashjam2017,代码行数:24,代码来源:GlyphPage.java

示例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;
		}
	}
}
 
开发者ID:skarna1,项目名称:javaportfolio,代码行数:20,代码来源:Portfolio.java

示例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();
                }
            };
        }
    };
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:23,代码来源:RangeLayoutHelperFinder.java

示例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;
}
 
开发者ID:wayfair,项目名称:brickkit-android,代码行数:25,代码来源:BrickRecyclerAdapter.java

示例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;
}
 
开发者ID:apache,项目名称:sling-org-apache-sling-query,代码行数:22,代码来源:SiblingsIterator.java

示例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());
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:27,代码来源:OrderedRealmCollectionIteratorTests.java

示例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();
    }
  }
}
 
开发者ID:fengchen8086,项目名称:ditb,代码行数:29,代码来源:MetricSampleQuantiles.java

示例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();
        }
      };
    }
  };
}
 
开发者ID:paul-hammant,项目名称:googles-monorepo-demo,代码行数:25,代码来源:Helpers.java

示例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;
}
 
开发者ID:ArtifexSoftware,项目名称:mupdf-android-viewer-nui,代码行数:19,代码来源:DocPageView.java

示例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;
}
 
开发者ID:jkobject,项目名称:PiPle,代码行数:25,代码来源:Message.java

示例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);
    }
}
 
开发者ID:msayan,项目名称:star-dns-changer,代码行数:19,代码来源:MaskedEditText.java

示例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;
}
 
开发者ID:JacobRoth,项目名称:romanov,代码行数:25,代码来源:Frequency.java

示例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());
}
 
开发者ID:XecureIT,项目名称:PeSanKita-android,代码行数:32,代码来源:MessageNotifier.java

示例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;
}
 
开发者ID:wumpz,项目名称:java-diff-utils,代码行数:16,代码来源:Patch.java

示例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." );
}
 
开发者ID:manifold-systems,项目名称:manifold,代码行数:19,代码来源:ManifoldListCollectionExt.java


注:本文中的java.util.ListIterator.previous方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。