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


Java FlatteningIterator类代码示例

本文整理汇总了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();
        }
      };
    }
  });
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:StatisticsWeigher.java

示例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();
        }
      };
    }
  };
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:35,代码来源:ComparingClassifier.java

示例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();
        }
      };
    }
  });
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:30,代码来源:StatisticsWeigher.java

示例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();
        }
      };
    }
  };
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:35,代码来源:ComparingClassifier.java

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


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