本文整理汇总了Java中java.util.List.listIterator方法的典型用法代码示例。如果您正苦于以下问题:Java List.listIterator方法的具体用法?Java List.listIterator怎么用?Java List.listIterator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类java.util.List
的用法示例。
在下文中一共展示了List.listIterator方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: protectIntentFilter
import java.util.List; //导入方法依赖的package包/类
public static void protectIntentFilter(IntentFilter filter) {
if (filter != null) {
List<String> actions = mirror.android.content.IntentFilter.mActions.get(filter);
ListIterator<String> iterator = actions.listIterator();
while (iterator.hasNext()) {
String action = iterator.next();
if (SpecialComponentList.isActionInBlackList(action)) {
iterator.remove();
continue;
}
if (SYSTEM_BROADCAST_ACTION.contains(action)) {
continue;
}
String newAction = SpecialComponentList.protectAction(action);
if (newAction != null) {
iterator.set(newAction);
}
}
}
}
示例2: resolveConflicts
import java.util.List; //导入方法依赖的package包/类
public List<Versioned<T>> resolveConflicts(List<Versioned<T>> items) {
int size = items.size();
if(size <= 1)
return items;
List<Versioned<T>> newItems = Lists.newArrayList();
for(Versioned<T> v1: items) {
boolean found = false;
for(ListIterator<Versioned<T>> it2 =
newItems.listIterator(); it2.hasNext();) {
Versioned<T> v2 = it2.next();
Occurred compare = v1.getVersion().compare(v2.getVersion());
if(compare == Occurred.AFTER) {
if(found)
it2.remove();
else
it2.set(v1);
}
if(compare != Occurred.CONCURRENTLY)
found = true;
}
if(!found)
newItems.add(v1);
}
return newItems;
}
示例3: testListIteratorGetSet
import java.util.List; //导入方法依赖的package包/类
@Test
public void testListIteratorGetSet() {
List<Integer> list = redisson.getList("list");
list.add(1);
list.add(2);
list.add(3);
list.add(4);
ListIterator<Integer> iterator = list.listIterator();
Assert.assertFalse(iterator.hasPrevious());
Assert.assertTrue(1 == iterator.next());
iterator.set(3);
assertThat(list).containsExactly(3, 2, 3, 4);
Assert.assertTrue(2 == iterator.next());
iterator.add(31);
assertThat(list).containsExactly(3, 2, 31, 3, 4);
Assert.assertTrue(3 == iterator.next());
Assert.assertTrue(4 == iterator.next());
Assert.assertFalse(iterator.hasNext());
iterator.add(71);
assertThat(list).containsExactly(3, 2, 31, 3, 4, 71);
iterator.add(8);
assertThat(list).containsExactly(3, 2, 31, 3, 4, 71, 8);
}
示例4: unmarkAndUnloadProjects
import java.util.List; //导入方法依赖的package包/类
/**
* Remove the given marked project from every loaded project that it depends on and unload those projects which have
* no marks anymore, since those are no longer required to process other projects.
*
* @param loadedProjects
* the currently loaded projects
* @param markedProject
* the project that was just processed
* @param resourceSet
* the resource set
* @param recorder
* the progress recorder
*/
private void unmarkAndUnloadProjects(List<MarkedProject> loadedProjects, MarkedProject markedProject,
ResourceSet resourceSet, N4ProgressStateRecorder recorder) {
ListIterator<MarkedProject> loadedIter = loadedProjects.listIterator();
while (loadedIter.hasNext()) {
MarkedProject loaded = loadedIter.next();
loaded.remove(markedProject.project);
if (!loaded.hasMarkers()) {
if (logger.isCreateDebugOutput()) {
logger.debug("Unloading project " + loaded.project);
}
loaded.unload(resourceSet, recorder);
loadedIter.remove();
}
}
}
示例5: getNextCategory
import java.util.List; //导入方法依赖的package包/类
private String getNextCategory(String category, int dir) {
if (dir>0) dir = 1;
if (dir<0) dir = -1;
List<String> categories = db().getCategories();
for (ListIterator<String> it = categories.listIterator(); it.hasNext();) {
String cat = it.next();
if (Categories.isHiddenCategory(cat)) it.remove();
}
int last = categories.size() -1;
for (int i=0; i<categories.size(); i++) {
if (categories.get(i).equals(category)) {
if (i==0 && dir==-1) return categories.get(last);
if (i==last && dir==1) return categories.get(0);
return categories.get(i+dir);
}
}
return null;
}
示例6: seg2sentence
import java.util.List; //导入方法依赖的package包/类
/**
* 切分为句子形式
*
* @param text
* @param filterArrayChain 自定义过滤器链
* @return
*/
public static List<List<Term>> seg2sentence(String text, Filter... filterArrayChain)
{
List<List<Term>> sentenceList = SEGMENT.seg2sentence(text);
for (List<Term> sentence : sentenceList)
{
ListIterator<Term> listIterator = sentence.listIterator();
while (listIterator.hasNext())
{
if (filterArrayChain != null)
{
Term term = listIterator.next();
for (Filter filter : filterArrayChain)
{
if (!filter.shouldInclude(term))
{
listIterator.remove();
break;
}
}
}
}
}
return sentenceList;
}
示例7: equals
import java.util.List; //导入方法依赖的package包/类
@Override
public boolean equals(final Object obj) {
if (obj == this) {
return true;
}
if (obj instanceof List == false) {
return false;
}
final List<?> other = (List<?>) obj;
if (other.size() != size()) {
return false;
}
final ListIterator<?> it1 = listIterator();
final ListIterator<?> it2 = other.listIterator();
while (it1.hasNext() && it2.hasNext()) {
final Object o1 = it1.next();
final Object o2 = it2.next();
if (!(o1 == null ? o2 == null : o1.equals(o2))) {
return false;
}
}
return !(it1.hasNext() || it2.hasNext());
}
示例8: PermutationIterator
import java.util.List; //导入方法依赖的package包/类
public PermutationIterator(List<T> toPermute) {
ListIterator<T> iter = toPermute.listIterator();
if (iter.hasNext())
head = new DirInt(iter.nextIndex(), iter.next());
DirInt prev = head;
while (iter.hasNext()) {
DirInt di = new DirInt(iter.nextIndex(), iter.next());
di.left = prev;
prev.right = di;
prev = di;
}
}
示例9: apply
import java.util.List; //导入方法依赖的package包/类
/**
* 对分词结果应用过滤
* @param termList
*/
public static void apply(List<Term> termList)
{
ListIterator<Term> listIterator = termList.listIterator();
while (listIterator.hasNext())
{
if (shouldRemove(listIterator.next())) listIterator.remove();
}
}
示例10: FallbackJSBundleLoader
import java.util.List; //导入方法依赖的package包/类
/**
* @param loaders Loaders for the sources to try, in descending order of
* preference.
*/
public FallbackJSBundleLoader(List<JSBundleLoader> loaders) {
mLoaders = new Stack();
ListIterator<JSBundleLoader> it = loaders.listIterator(loaders.size());
while (it.hasPrevious()) {
mLoaders.push(it.previous());
}
}
示例11: indexOfImpl
import java.util.List; //导入方法依赖的package包/类
/**
* An implementation of {@link List#indexOf(Object)}.
*/
static int indexOfImpl(List<?> list, @Nullable Object element) {
ListIterator<?> listIterator = list.listIterator();
while (listIterator.hasNext()) {
if (Objects.equal(element, listIterator.next())) {
return listIterator.previousIndex();
}
}
return -1;
}
示例12: testUnmodListIteratorSet
import java.util.List; //导入方法依赖的package包/类
@Test(dataProvider = "unsettable",
expectedExceptions = UnsupportedOperationException.class)
public void testUnmodListIteratorSet(List<Integer> list, int from, int to) {
List<Integer> subList = list.subList(from, to);
ListIterator<Integer> it = subList.listIterator();
it.next();
it.set(42);
}
示例13: executeAction
import java.util.List; //导入方法依赖的package包/类
@Override
public void executeAction(String superProcessInstanceId) {
List<String> subProcessIds = getActiveExecutionIds(superProcessInstanceId);
ListIterator<String> subProcessesIdsIterator = subProcessIds.listIterator(subProcessIds.size());
while (subProcessesIdsIterator.hasPrevious()) {
String subProcessId = subProcessesIdsIterator.previous();
retryProcess(subProcessId);
}
}
示例14: visitImpl
import java.util.List; //导入方法依赖的package包/类
@Override
protected KeyValuePair<K, V> visitImpl(Map<K, V> map, boolean hasExtra, MapOperateInterceptor<K, V> moip,
IterationInfo info, Object param, MapPredicateVisitor<K, V> predicate, List<KeyValuePair<K, V>> out) {
final List<KeyValuePair<K, V>> keyValues = map.getKeyValues();
final ListIterator<KeyValuePair<K, V>> it = keyValues.listIterator();
KeyValuePair<K, V> pair;
if (hasExtra) {
for (; it.hasNext();) {
pair = it.next();
if (moip.intercept(map, pair, param, info)) {
continue;
}
if (isTrue(predicate.visit(pair, param))) {
out.add(pair);
}
}
} else {
// no extra ops
for (; it.hasNext();) {
pair = it.next();
if (isTrue(predicate.visit(pair, param))) {
out.add(pair);
}
}
}
return null;
}
示例15: testListIteratorOK
import java.util.List; //导入方法依赖的package包/类
@Test
public void testListIteratorOK() {
List<Integer> list = redisson.getList("simpleList");
list.add(1);
ListIterator<Integer> iterator = list.listIterator();
iterator.next();
iterator.set(3);
iterator.set(4);
}