本文整理汇总了Java中com.intellij.util.containers.FlatteningIterator类的典型用法代码示例。如果您正苦于以下问题:Java FlatteningIterator类的具体用法?Java FlatteningIterator怎么用?Java FlatteningIterator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
FlatteningIterator类属于com.intellij.util.containers包,在下文中一共展示了FlatteningIterator类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: classify
import com.intellij.util.containers.FlatteningIterator; //导入依赖的package包/类
@Override
public Iterable<LookupElement> classify(Iterable<LookupElement> source, final ProcessingContext context) {
checkPrefixChanged(context);
final Collection<List<LookupElement>> byWeight = buildMapByWeight(source, context).descendingMap().values();
List<LookupElement> initialList = getInitialNoStatElements(source, context);
//noinspection unchecked
final THashSet<LookupElement> initialSet = new THashSet<LookupElement>(initialList, TObjectHashingStrategy.IDENTITY);
final Condition<LookupElement> notInInitialList = new Condition<LookupElement>() {
@Override
public boolean value(LookupElement element) {
return !initialSet.contains(element);
}
};
return ContainerUtil.concat(initialList, new Iterable<LookupElement>() {
@Override
public Iterator<LookupElement> iterator() {
return new FlatteningIterator<List<LookupElement>, LookupElement>(byWeight.iterator()) {
@Override
protected Iterator<LookupElement> createValueIterator(List<LookupElement> group) {
return myNext.classify(ContainerUtil.findAll(group, notInInitialList), context).iterator();
}
};
}
});
}
示例2: classify
import com.intellij.util.containers.FlatteningIterator; //导入依赖的package包/类
@Override
public Iterable<T> classify(final Iterable<T> source, final ProcessingContext context) {
List<T> nulls = null;
TreeMap<Comparable, List<T>> map = new TreeMap<Comparable, List<T>>();
for (T t : source) {
final Comparable weight = getWeight(t, context);
if (weight == null) {
if (nulls == null) nulls = new SmartList<T>();
nulls.add(t);
} else {
List<T> list = map.get(weight);
if (list == null) {
map.put(weight, list = new SmartList<T>());
}
list.add(t);
}
}
final List<List<T>> values = new ArrayList<List<T>>();
values.addAll(myNegated ? map.descendingMap().values() : map.values());
ContainerUtil.addIfNotNull(values, nulls);
return new Iterable<T>() {
@Override
public Iterator<T> iterator() {
return new FlatteningIterator<List<T>, T>(values.iterator()) {
@Override
protected Iterator<T> createValueIterator(List<T> group) {
return myNext.classify(group, context).iterator();
}
};
}
};
}
示例3: classify
import com.intellij.util.containers.FlatteningIterator; //导入依赖的package包/类
@Override
public Iterable<LookupElement> classify(Iterable<LookupElement> source, final ProcessingContext context) {
checkPrefixChanged(context);
final Collection<List<LookupElement>> byWeight = buildMapByWeight(source).descendingMap().values();
List<LookupElement> initialList = getInitialNoStatElements(source, context);
//noinspection unchecked
final THashSet<LookupElement> initialSet = new THashSet<LookupElement>(initialList, TObjectHashingStrategy.IDENTITY);
final Condition<LookupElement> notInInitialList = new Condition<LookupElement>() {
@Override
public boolean value(LookupElement element) {
return !initialSet.contains(element);
}
};
return ContainerUtil.concat(initialList, new Iterable<LookupElement>() {
@Override
public Iterator<LookupElement> iterator() {
return new FlatteningIterator<List<LookupElement>, LookupElement>(byWeight.iterator()) {
@Override
protected Iterator<LookupElement> createValueIterator(List<LookupElement> group) {
return myNext.classify(ContainerUtil.findAll(group, notInInitialList), context).iterator();
}
};
}
});
}
示例4: classify
import com.intellij.util.containers.FlatteningIterator; //导入依赖的package包/类
@Override
public Iterable<T> classify(final Iterable<T> source, final ProcessingContext context) {
List<T> nulls = null;
TreeMap<Comparable, List<T>> map = new TreeMap<Comparable, List<T>>();
for (T t : source) {
final Comparable weight = getWeight(t);
if (weight == null) {
if (nulls == null) nulls = new SmartList<T>();
nulls.add(t);
} else {
List<T> list = map.get(weight);
if (list == null) {
map.put(weight, list = new SmartList<T>());
}
list.add(t);
}
}
final List<List<T>> values = new ArrayList<List<T>>();
values.addAll(myNegated ? map.descendingMap().values() : map.values());
ContainerUtil.addIfNotNull(values, nulls);
return new Iterable<T>() {
@Override
public Iterator<T> iterator() {
return new FlatteningIterator<List<T>, T>(values.iterator()) {
@Override
protected Iterator<T> createValueIterator(List<T> group) {
return myNext.classify(group, context).iterator();
}
};
}
};
}
示例5: classify
import com.intellij.util.containers.FlatteningIterator; //导入依赖的package包/类
@Nonnull
@Override
public Iterable<T> classify(@Nonnull final Iterable<T> source, @Nonnull final ProcessingContext context) {
List<T> nulls = null;
TreeMap<Comparable, List<T>> map = new TreeMap<Comparable, List<T>>();
for (T t : source) {
final Comparable weight = getWeight(t, context);
if (weight == null) {
if (nulls == null) nulls = new SmartList<T>();
nulls.add(t);
} else {
List<T> list = map.get(weight);
if (list == null) {
map.put(weight, list = new SmartList<T>());
}
list.add(t);
}
}
final List<List<T>> values = new ArrayList<List<T>>();
values.addAll(myNegated ? map.descendingMap().values() : map.values());
ContainerUtil.addIfNotNull(values, nulls);
return new Iterable<T>() {
@Override
public Iterator<T> iterator() {
return new FlatteningIterator<List<T>, T>(values.iterator()) {
@Override
protected Iterator<T> createValueIterator(List<T> group) {
return myNext.classify(group, context).iterator();
}
};
}
};
}