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


Java ReadonlyList.getSize方法代码示例

本文整理汇总了Java中com.intellij.util.containers.ReadonlyList.getSize方法的典型用法代码示例。如果您正苦于以下问题:Java ReadonlyList.getSize方法的具体用法?Java ReadonlyList.getSize怎么用?Java ReadonlyList.getSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.intellij.util.containers.ReadonlyList的用法示例。


在下文中一共展示了ReadonlyList.getSize方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: stolenBinarySearch

import com.intellij.util.containers.ReadonlyList; //导入方法依赖的package包/类
private static <T> int stolenBinarySearch(ReadonlyList<? extends T> l, T key, Comparator<? super T> c, final int from) {
    int low = from;
    int high = (l.getSize() - from) -1;

    while (low <= high) {
        int mid = (low + high) >>> 1;
        T midVal = l.get(mid);
        int cmp = c.compare(midVal, key);

        if (cmp < 0)
            low = mid + 1;
        else if (cmp > 0)
            high = mid - 1;
        else
            return mid; // key found
    }
    return -(low + 1);  // key not found
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:19,代码来源:GroupingMerger.java

示例2: execute

import com.intellij.util.containers.ReadonlyList; //导入方法依赖的package包/类
public void execute() {
  final int[] idxs = new int[myLists.size()];
  for (int i = 0; i < myLists.size(); i++) {
    final ReadonlyList<T> member = myLists.get(i);
    idxs[i] = member.getSize() == 0 ? -1 : 0;
  }

  while (true) {
    CompoundNumber minIdxs = null;
    for (int i = 0; i < idxs.length; i++) {
      if (idxs[i] == -1) continue;  // at end
      final ReadonlyList<T> list = myLists.get(i);
      if ((minIdxs == null) || (myComparator.compare(Pair.create(new CompoundNumber(i, idxs[i]), list.get(idxs[i])),
                                                     Pair.create(minIdxs, myLists.get(minIdxs.getMemberNumber()).get(minIdxs.getIdx()))) <= 0)) {
        minIdxs = new CompoundNumber(i, idxs[i]);
      }
    }
    if (minIdxs == null) return;
    myConsumer.consume(minIdxs);
    final int memberIdx = minIdxs.getMemberNumber();
    idxs[memberIdx] = (myLists.get(memberIdx).getSize() == (idxs[memberIdx] + 1) ? -1 : idxs[memberIdx] + 1);
  }
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:ReadonlyListsMerger.java

示例3: firstPlusSecond

import com.intellij.util.containers.ReadonlyList; //导入方法依赖的package包/类
public static<T> void firstPlusSecond(final StepList<T> first, final ReadonlyList<T> second, final Comparator<T> comparator,
                                      @Nullable final Consumer<T> beforeAddListener, final Processor<T> filter) {
  if (second.getSize() == 0) return;
  int idx = stolenBinarySearch(first, second.get(0), comparator, 0);
  if (idx < 0) {
    idx = - (idx + 1);
  }
  // for group headers to not be left alone without its group
  if (idx > 0 && (! filter.process(first.get(idx - 1)))) {
    -- idx;
    if (idx > 0) --idx;
  }
  final ReadonlyList<T> remergePart = first.cut(idx);
  merge(remergePart, second, comparator, new Consumer<T>() {
    @Override
    public void consume(T t) {
      if (beforeAddListener != null) {
        beforeAddListener.consume(t);
      }
      first.add(t);
    }
  }, filter);
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:24,代码来源:ReadonlyListsMerger.java

示例4: execute

import com.intellij.util.containers.ReadonlyList; //导入方法依赖的package包/类
public void execute() {
  final int[] idxs = new int[myLists.size()];
  for (int i = 0; i < myLists.size(); i++) {
    final ReadonlyList<T> member = myLists.get(i);
    idxs[i] = member.getSize() == 0 ? -1 : 0;
  }

  while (true) {
    CompoundNumber minIdxs = null;
    for (int i = 0; i < idxs.length; i++) {
      if (idxs[i] == -1) continue;  // at end
      final ReadonlyList<T> list = myLists.get(i);
      if ((minIdxs == null) || (myComparator.compare(new Pair<CompoundNumber,T>(new CompoundNumber(i, idxs[i]), list.get(idxs[i])),
              new Pair<CompoundNumber,T>(minIdxs, myLists.get(minIdxs.getMemberNumber()).get(minIdxs.getIdx()))) <= 0)) {
        minIdxs = new CompoundNumber(i, idxs[i]);
      }
    }
    if (minIdxs == null) return;
    myConsumer.consume(minIdxs);
    final int memberIdx = minIdxs.getMemberNumber();
    idxs[memberIdx] = (myLists.get(memberIdx).getSize() == (idxs[memberIdx] + 1) ? -1 : idxs[memberIdx] + 1);
  }
}
 
开发者ID:lshain-android-source,项目名称:tools-idea,代码行数:24,代码来源:ReadonlyListsMerger.java


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