use of com.intellij.vcs.log.graph.utils.IntList in project intellij-community by JetBrains.
the class BekSorter method createBekIntMap.
private static BekIntMap createBekIntMap(final List<Integer> result) {
final int[] reverseMap = new int[result.size()];
for (int i = 0; i < result.size(); i++) {
reverseMap[result.get(i)] = i;
}
final IntList compressedBekMap = CompressedIntList.newInstance(new IntList() {
@Override
public int size() {
return result.size();
}
@Override
public int get(int index) {
return result.get(index);
}
}, CompressedIntList.DEFAULT_BLOCK_SIZE);
final IntList compressedReverseMap = CompressedIntList.newInstance(reverseMap);
return new BekIntMap() {
@Override
public int size() {
return compressedBekMap.size();
}
@Override
public int getBekIndex(int usualIndex) {
return compressedReverseMap.get(usualIndex);
}
@Override
public int getUsualIndex(int bekIndex) {
return compressedBekMap.get(bekIndex);
}
};
}
use of com.intellij.vcs.log.graph.utils.IntList in project intellij-community by JetBrains.
the class CompressedIntList method newInstance.
@NotNull
public static IntList newInstance(final IntList delegateList, final int blockSize) {
if (blockSize < 1)
throw new IllegalArgumentException("Unsupported blockSize:" + blockSize);
if (delegateList.size() == 0)
return new FullIntList(new int[0]);
IntList intDeltaCompressor = SmartDeltaCompressor.newInstance(new IntList() {
@Override
public int size() {
return delegateList.size();
}
@Override
public int get(int index) {
return delegateList.get(index) - delegateList.get(index - (index % blockSize));
}
});
int[] strongValues = new int[(delegateList.size() - 1) / blockSize + 1];
for (int i = 0; i < strongValues.length; i++) {
strongValues[i] = delegateList.get(i * blockSize);
}
return new CompressedIntList(blockSize, strongValues, intDeltaCompressor);
}
Aggregations