本文整理汇总了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
}
示例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);
}
}
示例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);
}
示例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);
}
}