本文整理汇总了Java中it.unimi.dsi.fastutil.ints.IntIterator类的典型用法代码示例。如果您正苦于以下问题:Java IntIterator类的具体用法?Java IntIterator怎么用?Java IntIterator使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IntIterator类属于it.unimi.dsi.fastutil.ints包,在下文中一共展示了IntIterator类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getMinClock
import it.unimi.dsi.fastutil.ints.IntIterator; //导入依赖的package包/类
/**
* Get min clock of this row, remove clocks of tasks which would never update this row.
*
* @return min clock value
*/
public int getMinClock() {
if (clocks.size() == 0) {
return 0;
}
IntIterator iter = clocks.values().iterator();
int min = Integer.MAX_VALUE;
while (iter.hasNext()) {
int clock = iter.nextInt();
if (clock < min) {
min = clock;
}
}
return min;
}
示例2: listRowIds
import it.unimi.dsi.fastutil.ints.IntIterator; //导入依赖的package包/类
public String listRowIds() {
int[] idList = new int[rowIdSet.size()];
IntIterator iter = rowIdSet.iterator();
int i = 0;
while (iter.hasNext()) {
idList[i++] = iter.nextInt();
}
Arrays.sort(idList);
StringBuilder sb = new StringBuilder();
for (i = 0; i < idList.length; i++) {
sb.append(idList[i]);
sb.append(",");
}
return sb.toString();
}
示例3: createLocalsChange
import it.unimi.dsi.fastutil.ints.IntIterator; //导入依赖的package包/类
private DebugLocalsChange createLocalsChange(
Int2ReferenceMap<DebugLocalInfo> ending, Int2ReferenceMap<DebugLocalInfo> starting) {
if (ending.isEmpty() && starting.isEmpty()) {
return null;
}
if (ending.isEmpty() || starting.isEmpty()) {
return new DebugLocalsChange(ending, starting);
}
IntSet unneeded = new IntArraySet(Math.min(ending.size(), starting.size()));
for (Entry<DebugLocalInfo> entry : ending.int2ReferenceEntrySet()) {
if (starting.get(entry.getIntKey()) == entry.getValue()) {
unneeded.add(entry.getIntKey());
}
}
if (unneeded.size() == ending.size() && unneeded.size() == starting.size()) {
return null;
}
IntIterator iterator = unneeded.iterator();
while (iterator.hasNext()) {
int key = iterator.nextInt();
ending.remove(key);
starting.remove(key);
}
return new DebugLocalsChange(ending, starting);
}
示例4: intersectionPE
import it.unimi.dsi.fastutil.ints.IntIterator; //导入依赖的package包/类
public boolean intersectionPE(CustomHashMap other){
boolean modified = false;
IntIterator itr = this.keySet().iterator();
while(itr.hasNext()){
int key = itr.nextInt();
int keyInv = 0 - key;
if(!other.containsKey(key) && !other.containsKey(keyInv)){
itr.remove();
modified = true;
}
}
for(int otherKey : other.keySet()){
int otherKeyInv = 0-otherKey;
boolean intst = this.containsKey(otherKey); //does this contain otherKey?
boolean intstPrime = this.containsKey(otherKeyInv); //does this contain -(otherkey)?
if(!intst && intstPrime){
this.put(otherKey, other.get(otherKey));
modified = true;
}
}
return modified;
}
示例5: createNewAttribute
import it.unimi.dsi.fastutil.ints.IntIterator; //导入依赖的package包/类
public Attribute createNewAttribute(HashMap<String, Attribute> attributes,
String attribute, int noMonths) {
Attribute a = attributes.get(attribute);
int ct = 0;
IntSet keys = a.data.keySet();
IntIterator it = keys.iterator();
ArrayList<SpatioTemporalVal> arr = new ArrayList<SpatioTemporalVal>();
while(ct < noMonths) {
if(!it.hasNext()) {
Utilities.er("no. of months is greater than what is present");
}
int month = it.nextInt();
arr.addAll(a.data.get(month));
ct++;
}
Collections.sort(arr);
Attribute na = new Attribute();
na.data.put(0, arr);
na.nodeSet = a.nodeSet;
return na;
}
示例6: iterator
import it.unimi.dsi.fastutil.ints.IntIterator; //导入依赖的package包/类
/**
* Returns an iterator over elements of type {@code T}.
*
* @return an Iterator.
*/
@Override
public Iterator<LocalTime> iterator() {
return new Iterator<LocalTime>() {
IntIterator intIterator = intIterator();
@Override
public boolean hasNext() {
return intIterator.hasNext();
}
@Override
public LocalTime next() {
return PackedLocalTime.asLocalTime(intIterator.nextInt());
}
};
}
示例7: iterator
import it.unimi.dsi.fastutil.ints.IntIterator; //导入依赖的package包/类
/**
* Returns an iterator over elements of type {@code T}.
*
* @return an Iterator.
*/
@Override
public Iterator<LocalDate> iterator() {
return new Iterator<LocalDate>() {
IntIterator intIterator = intIterator();
@Override
public boolean hasNext() {
return intIterator.hasNext();
}
@Override
public LocalDate next() {
return PackedLocalDate.asLocalDate(intIterator.nextInt());
}
};
}
示例8: testInternalIdToLongIterator
import it.unimi.dsi.fastutil.ints.IntIterator; //导入依赖的package包/类
@Test
public void testInternalIdToLongIterator() {
LongToInternalIntBiMap nodesToIndexBiMap =
new ArrayBasedLongToInternalIntBiMap(10, 0.5, -1, -1L, nullStatsReceiver);
int n = 7;
int[] expectedIndices = new int[n];
long[] expectedEntries = new long[n];
for (int i = 0; i < n; i++) {
expectedIndices[i] = nodesToIndexBiMap.put(i);
expectedEntries[i] = (long) i;
}
IntIterator intIterator = new IntArrayList(expectedIndices).iterator();
InternalIdToLongIterator internalIdToLongIterator =
new InternalIdToLongIterator(nodesToIndexBiMap, new IdentityEdgeTypeMask());
internalIdToLongIterator.resetWithIntIterator(new WithEdgeMetadataIntIteratorImpl(intIterator));
assertEquals(new LongArrayList(expectedEntries), new LongArrayList(internalIdToLongIterator));
}
示例9: getFasterIntersectionMap
import it.unimi.dsi.fastutil.ints.IntIterator; //导入依赖的package包/类
private Int2IntMap getFasterIntersectionMap(int uidx) {
Int2IntOpenHashMap intersectionMap = new Int2IntOpenHashMap();
intersectionMap.defaultReturnValue(0);
IntIterator iidxs = data.getUidxIidxs(uidx);
while (iidxs.hasNext()) {
IntIterator vidxs = data.getIidxUidxs(iidxs.nextInt());
while (vidxs.hasNext()) {
intersectionMap.addTo(vidxs.nextInt(), 1);
}
}
intersectionMap.remove(uidx);
return intersectionMap;
}
示例10: getProductMap
import it.unimi.dsi.fastutil.ints.IntIterator; //导入依赖的package包/类
private Int2DoubleMap getProductMap(int uidx) {
Int2DoubleOpenHashMap productMap = new Int2DoubleOpenHashMap();
productMap.defaultReturnValue(0.0);
if (data.useIteratorsPreferentially()) {
IntIterator iidxs = data.getUidxIidxs(uidx);
DoubleIterator ivs = data.getUidxVs(uidx);
while (iidxs.hasNext()) {
int iidx = iidxs.nextInt();
double iv = ivs.nextDouble();
IntIterator vidxs = data.getIidxUidxs(iidx);
DoubleIterator vvs = data.getIidxVs(iidx);
while (vidxs.hasNext()) {
productMap.addTo(vidxs.nextInt(), iv * vvs.nextDouble());
}
}
} else {
data.getUidxPreferences(uidx)
.forEach(ip -> data.getIidxPreferences(ip.v1)
.forEach(up -> productMap.addTo(up.v1, ip.v2 * up.v2)));
}
productMap.remove(uidx);
return productMap;
}
示例11: getProductArray
import it.unimi.dsi.fastutil.ints.IntIterator; //导入依赖的package包/类
private double[] getProductArray(int uidx) {
double[] productArray = new double[data.numUsers()];
if (data.useIteratorsPreferentially()) {
IntIterator iidxs = data.getUidxIidxs(uidx);
DoubleIterator ivs = data.getUidxVs(uidx);
while (iidxs.hasNext()) {
int iidx = iidxs.nextInt();
double iv = ivs.nextDouble();
IntIterator vidxs = data.getIidxUidxs(iidx);
DoubleIterator vvs = data.getIidxVs(iidx);
while (vidxs.hasNext()) {
productArray[vidxs.nextInt()] += iv * vvs.nextDouble();
}
}
} else {
data.getUidxPreferences(uidx)
.forEach(ip -> data.getIidxPreferences(ip.v1)
.forEach(up -> productArray[up.v1] += ip.v2 * up.v2));
}
productArray[uidx] = 0.0;
return productArray;
}
示例12: getWriteDeltaOffset
import it.unimi.dsi.fastutil.ints.IntIterator; //导入依赖的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;
}
示例13: getWeightedRandomReversed
import it.unimi.dsi.fastutil.ints.IntIterator; //导入依赖的package包/类
@Nullable
public static <T> T getWeightedRandomReversed(Random random, Int2ObjectMap<T> choices)
{
long i = 0;
IntSet ints = choices.keySet();
for (IntIterator iterator = ints.iterator(); iterator.hasNext(); )
{
int x = iterator.nextInt();
i += x;
}
i = getRandomLong(random, 0, i);
for (Int2ObjectMap.Entry<T> entry : choices.int2ObjectEntrySet())
{
i -= entry.getIntKey();
if (i < 0)
{
return entry.getValue();
}
}
return null;
}
示例14: getWeightedRandom
import it.unimi.dsi.fastutil.ints.IntIterator; //导入依赖的package包/类
@Nullable
public static <T> T getWeightedRandom(Random random, Object2IntMap<T> choices)
{
long i = 0;
IntCollection ints = choices.values();
for (IntIterator iterator = ints.iterator(); iterator.hasNext(); )
{
int x = iterator.nextInt();
i += x;
}
i = getRandomLong(random, 0, i);
for (Object2IntMap.Entry<T> entry : choices.object2IntEntrySet())
{
i -= entry.getIntValue();
if (i < 0)
{
return entry.getKey();
}
}
return null;
}
示例15: acquire0
import it.unimi.dsi.fastutil.ints.IntIterator; //导入依赖的package包/类
private int acquire0() {
final int id;
final IntIterator it = allocatorReusableIds.iterator();
if (it.hasNext()) {
try {
id = it.nextInt();
} finally {
it.remove();
}
} else {
id = allocatorIdCounter++;
}
if (this.entityProtocol != null) {
this.entityProtocol.entityProtocolManager.idToEntityProtocolMap.put(id, this.entityProtocol);
}
return id;
}