本文整理汇总了Java中it.unimi.dsi.fastutil.ints.IntList.iterator方法的典型用法代码示例。如果您正苦于以下问题:Java IntList.iterator方法的具体用法?Java IntList.iterator怎么用?Java IntList.iterator使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类it.unimi.dsi.fastutil.ints.IntList
的用法示例。
在下文中一共展示了IntList.iterator方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getWriteDeltaOffset
import it.unimi.dsi.fastutil.ints.IntList; //导入方法依赖的package包/类
/**
* Estimates the number of bits required for the succinct delta representation from strictly incremental
* <code>list</code>. For details of the representation (see
* {@link org.pebble.core.encoding.OutputSuccinctStream#writeDelta(it.unimi.dsi.fastutil.ints.IntList, int) writeDelta}).
* @param list to encode. List must be strictly incremental with positives (including zero) values.
* @param valueBitSize fixed number of bits used to represent value in list to be encoded. It can be any value
* between 1bit and 31 bits.
* @return number of representation bits.
*/
public int getWriteDeltaOffset(final IntList list, final int valueBitSize) {
final IntIterator listIterator = list.iterator();
int offset = getWriteDeltaOffset(list.size());
if (listIterator.hasNext()) {
int value;
int deltaValue;
int lastValue = listIterator.nextInt();
offset += writeIntOffset(lastValue, valueBitSize);
while (listIterator.hasNext()) {
value = listIterator.nextInt();
deltaValue = value - lastValue - 1;
offset += getWriteDeltaOffset(deltaValue);
lastValue = value;
}
}
return offset;
}
示例2: setCandidates
import it.unimi.dsi.fastutil.ints.IntList; //导入方法依赖的package包/类
private void setCandidates(final LongList list) {
IntList listsIndexes;
IntIterator indexesIterator;
final LongIterator listIterator = list.iterator();
candidates.clear();
while (listIterator.hasNext()) {
listsIndexes = listsInvertedIndex.get(listIterator.nextLong());
if (listsIndexes != null) {
indexesIterator = listsIndexes.iterator();
while (indexesIterator.hasNext()) {
candidates.add(indexesIterator.nextInt());
}
}
}
}
示例3: addListIntoListsInvertedIndex
import it.unimi.dsi.fastutil.ints.IntList; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
public void addListIntoListsInvertedIndex(final int index, final IntList list) {
final IntIterator listIterator = list.iterator();
IntList listsIndexes;
int value;
while (listIterator.hasNext()) {
value = listIterator.nextInt();
listsIndexes = listsInvertedIndex.get(value);
if (listsIndexes == null) {
listsIndexes = new IntArrayList();
listsInvertedIndex.put(value, listsIndexes);
}
listsIndexes.add(index);
}
}
示例4: removeListFromListsInvertedIndex
import it.unimi.dsi.fastutil.ints.IntList; //导入方法依赖的package包/类
/**
* {@inheritDoc}
*/
public void removeListFromListsInvertedIndex(final int index, final IntList list) {
final IntIterator listIterator = list.iterator();
int value;
IntList listsIndexes;
while (listIterator.hasNext()) {
value = listIterator.nextInt();
listsIndexes = listsInvertedIndex.get(value);
listsIndexes.remove((Integer) index);
if (listsIndexes.isEmpty()) {
listsInvertedIndex.remove(value);
}
}
}
示例5: setCandidates
import it.unimi.dsi.fastutil.ints.IntList; //导入方法依赖的package包/类
private void setCandidates(final IntList list) {
IntList listsIndexes;
IntIterator indexesIterator;
final IntIterator listIterator = list.iterator();
candidates.clear();
while (listIterator.hasNext()) {
listsIndexes = listsInvertedIndex.get(listIterator.nextInt());
if (listsIndexes != null) {
indexesIterator = listsIndexes.iterator();
while (indexesIterator.hasNext()) {
candidates.add(indexesIterator.nextInt());
}
}
}
}
示例6: build
import it.unimi.dsi.fastutil.ints.IntList; //导入方法依赖的package包/类
private static TypeIntDecoder build(final IntList list) {
return new TypeIntDecoder(null) {
@Override
public Iterator read(int listIndex, int valueBitSize) throws IOException {
return new TypeIterator(list == null ? null : list.iterator()) {
@Override
public Object next() {
return iterator.next();
}
};
}
};
}
示例7: writeRepetitions
import it.unimi.dsi.fastutil.ints.IntList; //导入方法依赖的package包/类
/**
* Writes the succinct representation of the repetitions extracted from sorted <code>list</code>.
* <ul>
* <li>Number of repetitions intervals.</li>
* <li>
* For each interval:
* <ul>
* <li>
* Store the index of the repeated element minus the previous index minus 1, given that the
* difference between the indexes is at least one. The first index is stored raw given there is no
* previous index.
* </li>
* <li>
* Store the number of repetitions minus 2, given that repetitions must be at least two, to be an
* actual repetition.
* </li>
* </ul>
* </li>
* </ul>
*
* Each number is stored using delta encoding. Given than some values can be zero, is added one to each
* before apply delta encoding.
* For the example, <code>list</code>:
* <pre> {1, 1, 2, 3, 3, 3, 5, 6, 6, 7, 10, 11, 11, 12, 12, 12, 16, 19, 19}</pre>
* , it will generate the following encoding:
* <pre>
* 6 0 2 2 3 4 2 7 2 8 3 10 2 Repetitions Intervals.
* 6 0 0 1 1 1 0 2 0 0 1 1 0 Delta representation.
* 7 1 1 2 2 2 1 3 1 1 2 2 1 Add 1 to ensure non zeros.
* 111 1 1 01 01 01 1 11 1 1 01 01 1 Binary representation.
* 00111 1 1 010 010 010 1 011 1 1 010 010 1 Delta encoding.
* </pre>
*
* @param list from which extract the repetitions to encode. List must be incremental with positives
* (including zero) values.
* @return number of written bits.
* @throws IOException when there is an exception writing into <code>out</code>.
*/
protected int writeRepetitions(final IntList list) throws IOException {
int offset = 0;
int value = -1;
int lastValue;
int index = -1;
int repetitionStartIndex = -1;
int lastRepetitionStartIndex;
int numberOfRepetitions = 0;
final IntIterator listIterator = list.iterator();
repeatsBuffer.clear();
while (listIterator.hasNext()) {
lastValue = value;
value = listIterator.nextInt();
if (lastValue == value) {
if (numberOfRepetitions == 0) {
repetitionStartIndex = index;
}
numberOfRepetitions++;
listIterator.remove();
} else {
if (numberOfRepetitions > 0) {
repeatsBuffer.add(repetitionStartIndex);
repeatsBuffer.add(numberOfRepetitions);
numberOfRepetitions = 0;
}
index++;
}
}
if (numberOfRepetitions > 0) {
repeatsBuffer.add(repetitionStartIndex);
repeatsBuffer.add(numberOfRepetitions);
}
final IntIterator repeatsIterator = repeatsBuffer.iterator();
lastRepetitionStartIndex = -1;
offset += writeDelta(repeatsBuffer.size() / 2);
while (repeatsIterator.hasNext()) {
repetitionStartIndex = repeatsIterator.nextInt();
offset += writeDelta(repetitionStartIndex - lastRepetitionStartIndex - 1);
offset += writeDelta(repeatsIterator.nextInt() - 1);
lastRepetitionStartIndex = repetitionStartIndex;
}
return offset;
}
示例8: writeDelta
import it.unimi.dsi.fastutil.ints.IntList; //导入方法依赖的package包/类
/**
* Writes the succinct delta representation for an strictly incremental <code>list</code>.
* <ul>
* <li>List length.</li>
* <li>
* For each element in the list:
* <ul>
* <li>
* Store the element minus previous value minus one. The first element is stored in its binary
* representation given there is not previous value to subtract from.
* </li>
* </ul>
* </li>
* </ul>
*
* For the example <code>list</code>
* <pre> {1, 2, 3, 5, 7, 10}</pre>
* and <code>valueBitSize</code> = 1, it will generate the following encoding:
* <pre>
* 6 1 0 0 1 1 2 Delta list.
* 7 1 1 1 2 2 3 Add 1 to ensure non zeros.
* 111 1 1 1 01 01 11 Binary representation.
* 3-11 1 1 1 2-0 2-0 2-1 Decimal Gamma Prefix and Binary Gamma Suffix.
* 11-11 1 1 1 01-0 01-0 01-1 Binary Gamma Prefix and Binary Gamma Suffix.
* 01111 1 1 1 0100 0100 0101 Delta Encoding.
* </pre>
* @param list to encode. List must be strictly incremental with positives (including zero) values.
* @param valueBitSize fixed number of bits used to represent value in list to be encoded. It can be any value
* between 1bit and 31 bits.
* @return number of written bits.
* @throws IOException when there is an exception writing into <code>out</code>.
* @throws IllegalArgumentException when the list is not strictly incremental.
*/
protected int writeDelta(final IntList list, final int valueBitSize) throws IOException {
final IntIterator listIterator = list.iterator();
int offset = writeDelta(list.size());
if (listIterator.hasNext()) {
int value;
int deltaValue;
int lastValue = listIterator.nextInt();
offset += writeInt(lastValue, valueBitSize);
while (listIterator.hasNext()) {
value = listIterator.nextInt();
deltaValue = value - lastValue - 1;
if (deltaValue < 0) {
throw new NotStrictlyIncrementalListException(lastValue, value);
}
offset += writeDelta(deltaValue);
lastValue = value;
}
}
return offset;
}
示例9: getWriteIntervalsOffset
import it.unimi.dsi.fastutil.ints.IntList; //导入方法依赖的package包/类
/**
* Estimates the number of bits required for the succinct intervals representation from strictly incremental
* <code>list</code>. For details of the representation (see
* {@link org.pebble.core.encoding.OutputSuccinctStream#writeIntervals(it.unimi.dsi.fastutil.ints.IntList, int) writeIntervals}).
* @param list from which it will extracts the intervals to encode. List must be strictly incremental with
* positives (including zero) values.
* @param valueBitSize fixed number of bits used to represent value in list to be encoded. It can be any value
* between 1bit and 31 bits.
* @return number of representation bits.
*/
public int getWriteIntervalsOffset(final IntList list, final int valueBitSize) {
int offset = 0;
intervalsBuffer.clear();
if (list.size() >= minIntervalSize) {
IntIterator listIterator = list.iterator();
int intervalInitialIndex = 0;
int index = 1;
int lastValue = listIterator.nextInt();
int value;
int deltaValue;
intervalsBuffer.clear();
while (listIterator.hasNext()) {
value = listIterator.nextInt();
deltaValue = value - lastValue;
if (deltaValue > 1) {
if (index - intervalInitialIndex >= minIntervalSize) {
intervalsBuffer.add(intervalInitialIndex);
intervalsBuffer.add(index - intervalInitialIndex);
}
intervalInitialIndex = index;
}
lastValue = value;
index++;
}
if (index - intervalInitialIndex >= minIntervalSize) {
intervalsBuffer.add(intervalInitialIndex);
intervalsBuffer.add(index - intervalInitialIndex);
}
offset += getWriteDeltaOffset(intervalsBuffer.size() / 2);
if (!intervalsBuffer.isEmpty()) {
IntIterator intervalIterator = intervalsBuffer.iterator();
intervalInitialIndex = intervalIterator.nextInt();
index = 0;
listIterator = list.iterator();
boolean firstWrite = true;
while(true) {
value = listIterator.nextInt();
if (index == intervalInitialIndex) {
listIterator.remove();
if (firstWrite) {
offset += writeIntOffset(value, valueBitSize);
firstWrite = false;
} else {
deltaValue = value - lastValue - 2;
offset += getWriteDeltaOffset(deltaValue);
}
intervalInitialIndex = intervalIterator.nextInt();
offset += getWriteDeltaOffset(intervalInitialIndex - minIntervalSize);
while (--intervalInitialIndex > 0) {
value = listIterator.nextInt();
listIterator.remove();
index++;
}
lastValue = value;
if (!intervalIterator.hasNext()) {
break;
}
intervalInitialIndex = intervalIterator.nextInt();
}
index++;
}
}
} else {
offset += getWriteDeltaOffset(0);
}
return offset;
}
示例10: ReferenceIteratorBuilder
import it.unimi.dsi.fastutil.ints.IntList; //导入方法依赖的package包/类
public ReferenceIteratorBuilder(final Helper.Input input, final int listIndex, final IntList referenceList) {
this.listIndex = listIndex;
this.input = input;
this.iterator = referenceList.iterator();
}