本文整理汇总了Java中it.unimi.dsi.fastutil.ints.Int2IntMap.Entry方法的典型用法代码示例。如果您正苦于以下问题:Java Int2IntMap.Entry方法的具体用法?Java Int2IntMap.Entry怎么用?Java Int2IntMap.Entry使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类it.unimi.dsi.fastutil.ints.Int2IntMap
的用法示例。
在下文中一共展示了Int2IntMap.Entry方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: mergeTo
import it.unimi.dsi.fastutil.ints.Int2IntMap; //导入方法依赖的package包/类
/**
* Merge this sparse int vector split to a index/value array
* @param indexes index array
* @param values value array
* @param startPos write start position of the index/value array
* @param len write length
*/
public void mergeTo(int[] indexes, int[] values, int startPos, int len) {
try {
lock.readLock().lock();
int writeLen = len < hashMap.size() ? len : hashMap.size();
if (writeLen == 0) {
return;
}
int index = 0;
ObjectIterator<Int2IntMap.Entry> iter = hashMap.int2IntEntrySet().fastIterator();
Int2IntMap.Entry entry = null;
while (iter.hasNext()) {
entry = iter.next();
indexes[startPos + index] = entry.getIntKey();
values[startPos + index] = entry.getIntValue();
index++;
if (index == writeLen) {
return;
}
}
} finally {
lock.readLock().unlock();
}
}
示例2: dot
import it.unimi.dsi.fastutil.ints.Int2IntMap; //导入方法依赖的package包/类
private double dot(SparseIntVector other) {
double ret = 0;
SparseIntVector baseVector = null;
SparseIntVector streamVector = null;
if(this.size() >= other.size()) {
baseVector = new SparseIntVector(this);
streamVector = other;
} else {
baseVector = new SparseIntVector(other);
streamVector = this;
}
ObjectIterator<Int2IntMap.Entry> iter = streamVector.hashMap.int2IntEntrySet().fastIterator();
Int2IntMap.Entry entry = null;
while(iter.hasNext()) {
entry = iter.next();
if(baseVector.hashMap.containsKey(entry.getIntKey())) {
ret += baseVector.hashMap.get(entry.getIntKey()) * entry.getIntValue();
}
}
return ret;
}
示例3: serialize
import it.unimi.dsi.fastutil.ints.Int2IntMap; //导入方法依赖的package包/类
@Override
public void serialize(ByteBuf buf) {
super.serialize(buf);
part.serialize(buf);
if(taskIndexToClockMap != null) {
buf.writeInt(taskIndexToClockMap.size());
ObjectIterator<Int2IntMap.Entry>
iter = taskIndexToClockMap.int2IntEntrySet().fastIterator();
Int2IntMap.Entry item;
while(iter.hasNext()) {
item = iter.next();
buf.writeInt(item.getIntKey());
buf.writeInt(item.getIntValue());
}
} else {
buf.writeInt(0);
}
}
示例4: toString
import it.unimi.dsi.fastutil.ints.Int2IntMap; //导入方法依赖的package包/类
private String toString(Int2IntOpenHashMap clocVec) {
if(clocVec == null) {
return "NULL";
}
StringBuilder sb = new StringBuilder();
ObjectIterator<Int2IntMap.Entry> iter = clocVec.int2IntEntrySet().fastIterator();
Int2IntMap.Entry item ;
while(iter.hasNext()) {
item = iter.next();
sb.append(item.getIntKey());
sb.append(":");
sb.append(item.getIntValue());
sb.append(";");
}
return sb.toString();
}
示例5: refreshMinClock
import it.unimi.dsi.fastutil.ints.Int2IntMap; //导入方法依赖的package包/类
private void refreshMinClock() {
if (taskIndexToClockMap.size() < taskNum) {
minClock = 0;
return;
}
int min = Integer.MAX_VALUE;
for (Int2IntMap.Entry entry : taskIndexToClockMap.int2IntEntrySet()) {
if (entry.getIntValue() < min) {
min = entry.getIntValue();
}
}
if (minClock < min) {
minClock = min;
}
}
示例6: setClockVec
import it.unimi.dsi.fastutil.ints.Int2IntMap; //导入方法依赖的package包/类
/**
* Set clock vector
* @param clockVec clock vector
*/
public void setClockVec(Int2IntOpenHashMap clockVec) {
try {
lock.writeLock().lock();
ObjectIterator<Int2IntMap.Entry> iter = clockVec.int2IntEntrySet().fastIterator();
Int2IntMap.Entry item;
while(iter.hasNext()) {
item = iter.next();
if(!taskIndexToClockMap.containsKey(item.getIntKey())
|| (taskIndexToClockMap.containsKey(item.getIntKey())
&& taskIndexToClockMap.get(item.getIntKey()) < item.getIntValue())) {
taskIndexToClockMap.put(item.getIntKey(), item.getIntValue());
}
}
refreshMinClock();
} finally {
lock.writeLock().unlock();
}
}
示例7: adjustClocks
import it.unimi.dsi.fastutil.ints.Int2IntMap; //导入方法依赖的package包/类
/**
* Adjust clock values
* @param taskToMatrixClocks taskId->(matrixId->clock) map
*/
public void adjustClocks(Int2ObjectOpenHashMap<Int2IntOpenHashMap> taskToMatrixClocks) {
ObjectIterator<Int2ObjectMap.Entry<Int2IntOpenHashMap>> taskIter =
taskToMatrixClocks.int2ObjectEntrySet().fastIterator();
Int2ObjectMap.Entry<Int2IntOpenHashMap> taskEntry = null;
int taskId = 0;
Int2IntOpenHashMap matrixIdToClockMap = null;
ObjectIterator<Int2IntMap.Entry> matrixIter = null;
Int2IntMap.Entry matrixEntry = null;
while(taskIter.hasNext()) {
taskEntry = taskIter.next();
taskId = taskEntry.getIntKey();
matrixIdToClockMap = taskEntry.getValue();
matrixIter = matrixIdToClockMap.int2IntEntrySet().fastIterator();
while (matrixIter.hasNext()) {
matrixEntry = matrixIter.next();
updateClock(matrixEntry.getIntKey(), taskId, matrixEntry.getIntValue());
}
}
}
示例8: writeTo
import it.unimi.dsi.fastutil.ints.Int2IntMap; //导入方法依赖的package包/类
@Override
public void writeTo(DataOutputStream output) throws IOException {
try {
lock.readLock().lock();
super.writeTo(output);
output.writeInt(hashMap.size());
ObjectIterator<Int2IntMap.Entry> iter = hashMap.int2IntEntrySet().fastIterator();
Int2IntMap.Entry entry = null;
while (iter.hasNext()) {
entry = iter.next();
output.writeInt(entry.getIntKey());
output.writeInt(entry.getIntValue());
}
} finally {
lock.readLock().unlock();
}
}
示例9: findBestId
import it.unimi.dsi.fastutil.ints.Int2IntMap; //导入方法依赖的package包/类
@Override
public final int findBestId(Predicate<WorldObject> predicate, World world) {
int bestId = -1;
int bestRelationshipValue = Integer.MIN_VALUE;
for(Int2IntMap.Entry entry : idsToValue.int2IntEntrySet()) {
int id = entry.getIntKey();
int relationshipValue = entry.getIntValue();
// id may not exist in world because it's filtered out by
// WorldFacade, for example being invisible
if (world.exists(id)) {
WorldObject person = world.findWorldObjectById(id);
if (relationshipValue > bestRelationshipValue && predicate.test(person)) {
bestRelationshipValue = relationshipValue;
bestId = id;
}
}
}
return bestId;
}
示例10: findWorstId
import it.unimi.dsi.fastutil.ints.Int2IntMap; //导入方法依赖的package包/类
@Override
public final int findWorstId(World world) {
int worstId = -1;
int worstRelationshipValue = Integer.MAX_VALUE;
for(Int2IntMap.Entry entry : idsToValue.int2IntEntrySet()) {
int id = entry.getIntKey();
int relationshipValue = entry.getIntValue();
if (relationshipValue < worstRelationshipValue) {
worstRelationshipValue = relationshipValue;
worstId = id;
}
}
return worstId;
}
示例11: serializeNBT
import it.unimi.dsi.fastutil.ints.Int2IntMap; //导入方法依赖的package包/类
@Override
public void serializeNBT(NBTTagCompound nbt)
{
nbt.setString(ModNBTTag.DOMAIN_USER_NAME, this.userName);
nbt.setInteger(ModNBTTag.DOMAIN_USER_FLAGS, this.privilegeFlags);
if(!this.activeBuilds.isEmpty())
{
int[] buildData = new int[this.activeBuilds.size() * 2];
int i = 0;
for(Int2IntMap.Entry entry : this.activeBuilds.int2IntEntrySet())
{
buildData[i++] = entry.getIntKey();
buildData[i++] = entry.getIntValue();
}
nbt.setIntArray(ModNBTTag.BUILD_ID, buildData);
}
}
示例12: iterator
import it.unimi.dsi.fastutil.ints.Int2IntMap; //导入方法依赖的package包/类
@Nonnull
@Override
public Iterator<GroupKey> iterator() {
return new Iterator<GroupKey>() {
private final ObjectIterator<Int2IntMap.Entry> _iterator = _rawKeyToGroupIdMap.int2IntEntrySet().fastIterator();
private final GroupKey _groupKey = new GroupKey();
@Override
public boolean hasNext() {
return _iterator.hasNext();
}
@Override
public GroupKey next() {
Int2IntMap.Entry entry = _iterator.next();
_groupKey._groupId = entry.getIntValue();
_groupKey._stringKey = getGroupKey(entry.getIntKey());
return _groupKey;
}
@Override
public void remove() {
throw new UnsupportedOperationException();
}
};
}
示例13: filter
import it.unimi.dsi.fastutil.ints.Int2IntMap; //导入方法依赖的package包/类
@Override public TIntVector filter(int x) {
SparseIntVector vector = new SparseIntVector(dim);
vector.setMatrixId(matrixId).setRowId(rowId).setClock(clock);
ObjectIterator<Int2IntMap.Entry> iter = hashMap.int2IntEntrySet().fastIterator();
Int2IntMap.Entry entry = null;
while (iter.hasNext()) {
entry = iter.next();
int value = entry.getIntValue();
if (Math.abs(value) > x) {
vector.set(entry.getIntKey(), value);
}
}
return vector;
}
示例14: times
import it.unimi.dsi.fastutil.ints.Int2IntMap; //导入方法依赖的package包/类
@Override public TIntVector times(int x) {
SparseIntVector vector = new SparseIntVector(this);
ObjectIterator<Int2IntMap.Entry> iter = vector.hashMap.int2IntEntrySet().fastIterator();
Int2IntMap.Entry entry = null;
while(iter.hasNext()) {
entry.setValue(entry.getIntValue() * x);
}
return vector;
}
示例15: timesBy
import it.unimi.dsi.fastutil.ints.Int2IntMap; //导入方法依赖的package包/类
@Override public TIntVector timesBy(int x) {
ObjectIterator<Int2IntMap.Entry> iter = hashMap.int2IntEntrySet().fastIterator();
Int2IntMap.Entry entry = null;
while(iter.hasNext()) {
entry = iter.next();
entry.setValue(entry.getIntValue() * x);
}
return this;
}