本文整理汇总了Java中gnu.trove.map.TIntIntMap.get方法的典型用法代码示例。如果您正苦于以下问题:Java TIntIntMap.get方法的具体用法?Java TIntIntMap.get怎么用?Java TIntIntMap.get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gnu.trove.map.TIntIntMap
的用法示例。
在下文中一共展示了TIntIntMap.get方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: cleanInput
import gnu.trove.map.TIntIntMap; //导入方法依赖的package包/类
private void cleanInput()
{
final TIntIntMap patternMap = new TIntIntHashMap(this.patternMap);
for (int i = 0; i < 81 && !patternMap.isEmpty(); i++) {
final ItemStack itemStack = itemStacks[i];
final int key = MetaItem.get(itemStack);
if (patternMap.containsKey(key)) {
final int total = patternMap.get(key);
final int dif = MathHelper.clamp_int(total, 1, itemStack.stackSize);
if (!itemStack.getItem().hasContainerItem(itemStack))
itemStack.stackSize -= dif;
if (dif - total == 0)
patternMap.remove(key);
else
patternMap.put(key, total - dif);
if (itemStack.stackSize == 0)
itemStacks[i] = null;
}
}
}
示例2: findFirstSlotIdForObject
import gnu.trove.map.TIntIntMap; //导入方法依赖的package包/类
public int findFirstSlotIdForObject(final SlottedContainer container, final GameObject item) {
final ContainerResult containerResult = new ContainerResult();
final int position = containerService.find(container, item, containerResult);
if (position >= 0) {
final TIntIntMap slotMap = ReflectionUtil.getFieldValue(slotMapField, container);
final int[] keys = slotMap.keys();
for (int i = 0, size = keys.length; i < size; ++i) {
final int objPosition = slotMap.get(keys[i]);
if (objPosition == position)
return keys[i];
}
}
return SlotId.INVALID;
}
示例3: internalRemove
import gnu.trove.map.TIntIntMap; //导入方法依赖的package包/类
private boolean internalRemove(final SlottedContainer container, final GameObject item, final int overrideArrangement) {
final ContainerResult containerResult = new ContainerResult();
final int position = containerService.find(container, item, containerResult);
if (position == -1) {
LOGGER.warn("called with an invalid item: container owner id={}, template={}; item id={}, template={}",
container.getOwner().getNetworkId(),
container.getOwner().getObjectTemplateName(),
item.getNetworkId(),
item.getObjectTemplateName());
return false;
}
final TIntIntMap slotMap = ReflectionUtil.getFieldValue(slotMapField, container);
final int[] keys = slotMap.keys();
for (int i = 0, size = keys.length; i < size; ++i) {
final int pos = slotMap.get(keys[i]);
if (pos == position)
slotMap.put(i, -1); //Pretty sure we should be able to do this more efficiently.
}
return true;
}
示例4: equals
import gnu.trove.map.TIntIntMap; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
public boolean equals( Object other ) {
if ( ! ( other instanceof TIntIntMap ) ) {
return false;
}
TIntIntMap that = ( TIntIntMap ) other;
if ( that.size() != this.size() ) {
return false;
}
int[] values = _values;
byte[] states = _states;
int this_no_entry_value = getNoEntryValue();
int that_no_entry_value = that.getNoEntryValue();
for ( int i = values.length; i-- > 0; ) {
if ( states[i] == FULL ) {
int key = _set[i];
int that_value = that.get( key );
int this_value = values[i];
if ( ( this_value != that_value ) &&
( this_value != this_no_entry_value ) &&
( that_value != that_no_entry_value ) ) {
return false;
}
}
}
return true;
}
示例5: equals
import gnu.trove.map.TIntIntMap; //导入方法依赖的package包/类
/** {@inheritDoc} */
@Override
public boolean equals( Object other ) {
if ( ! ( other instanceof TIntIntMap ) ) {
return false;
}
TIntIntMap that = ( TIntIntMap ) other;
if ( that.size() != this.size() ) {
return false;
}
TIntOffheapArray values = _values;
TByteOffheapArray states = _states;
int this_no_entry_value = getNoEntryValue();
int that_no_entry_value = that.getNoEntryValue();
for ( int i = capacity(); i-- > 0; ) {
if ( states.get( i ) == FULL ) {
int key = _set.get( i );
int that_value = that.get( key );
int this_value = values.get( i );
if ( ( this_value != that_value ) &&
( this_value != this_no_entry_value ) &&
( that_value != that_no_entry_value ) ) {
return false;
}
}
}
return true;
}
示例6: encode32Bit
import gnu.trove.map.TIntIntMap; //导入方法依赖的package包/类
private static mt_32bit encode32Bit(TIntIntMap t_32bit, int timestampsSize) {
LOG.log(Level.FINEST, "encoding {0}", TDecorators.wrap(t_32bit));
int[] values = new int[timestampsSize];
int values_len = 0;
for (int i = 0; i < values.length; ++i) {
if (t_32bit.containsKey(i))
values[values_len++] = t_32bit.get(i);
}
mt_32bit result = new mt_32bit();
result.presence = createPresenceBitset(t_32bit.keySet(), timestampsSize);
result.values = Arrays.copyOf(values, values_len);
return result;
}
示例7: encodeStr
import gnu.trove.map.TIntIntMap; //导入方法依赖的package包/类
private static mt_str encodeStr(TIntIntMap t_str, int timestampsSize) {
LOG.log(Level.FINEST, "encoding {0}", TDecorators.wrap(t_str));
int[] values = new int[timestampsSize];
int values_len = 0;
for (int i = 0; i < values.length; ++i) {
if (t_str.containsKey(i))
values[values_len++] = t_str.get(i);
}
mt_str result = new mt_str();
result.presence = createPresenceBitset(t_str.keySet(), timestampsSize);
result.values = Arrays.copyOf(values, values_len);
return result;
}
示例8: matches
import gnu.trove.map.TIntIntMap; //导入方法依赖的package包/类
private boolean matches(@Nonnull final TIntIntMap inputMap, @Nonnull final TIntIntMap patternMap)
{
if (inputMap.size() >= patternMap.size() && inputMap.keySet().containsAll(patternMap.keySet())) {
for (final int key : patternMap.keys())
if (inputMap.get(key) < patternMap.get(key))
return false;
return true;
} else
return false;
}
示例9: get
import gnu.trove.map.TIntIntMap; //导入方法依赖的package包/类
/**
* Gets the value at row i, column j; not yet set values are 0
* @param i
* @param j
* @return
*/
public Integer get(int i, int j){
TIntIntMap row = matrix.get(i);
if (row != null){
int value = row.get(j);
return value;
}
// System.out.println("get not ex");
return 0;
}
示例10: getBool
import gnu.trove.map.TIntIntMap; //导入方法依赖的package包/类
/**
* Gets the value at row i, column j as boolean
* @param i
* @param j
* @return
*/
public boolean getBool(int i, int j){
TIntIntMap row = matrix.get(i);
if (row != null){
int value = row.get(j);
return value!=0;
}
// System.out.println("get not ex");
return false;
}
示例11: sampleU
import gnu.trove.map.TIntIntMap; //导入方法依赖的package包/类
/**
* finds an i that has a value != null for at least one item but not all items at the same value
* this is the generalized version of the method above
*
* @return u Number - the mapped userID
*/
public int sampleU(SparseIntMatrix matrix) {
while (true) {
// choose a random user
int i = random.nextInt(matrix.getM());
// System.out.println(" - Sampled user "+i);
// choose again if he has not interacted with items
if (matrix.getRow(i) == null)
continue;
TIntIntMap ithRow = matrix.getRow(i);
// these two conditions need to be checked for the users list of items
boolean oneIsNotZero = false;
boolean oneIsDifferent = false;
int temp = ithRow.get(0);
// the check is done in this loop
for (int j = 0; j < matrix.getN(); j++){
int ij = ithRow.get(j);
if(ij != 0) {
oneIsNotZero = true;
// System.out.println(" - - Item "+j+" was not zero");
}
if(ij != temp) {
oneIsDifferent = true;
// System.out.println(" - - Item "+j+" was different from j-1");
}
temp = ij;
}
// choose the user, if both conditions apply
if (oneIsDifferent && oneIsNotZero)
return i;
continue;
}
}
示例12: sampleIJ
import gnu.trove.map.TIntIntMap; //导入方法依赖的package包/类
/**
* finds an interacted and a less interacted item
*
* @return sampleTriple Array - an array containing the mapped userID, the
* mapped view itemId and the mapped unviewed itemID
*/
public int[] sampleIJ(int[] triple, SparseIntMatrix matrix, boolean justUnseen) {
int i = triple[0];
int j1; //I
int j2; //J
// System.out.println(" - Looking for items for user "+i);
// System.out.println(" - N is "+matrix.getN());
TIntIntMap ithRow = matrix.getRow(i);
do{
j1 = random.nextInt(matrix.getN());
//System.out.println(" - - rand: " + randomnumber);
//j1 = ithRow.get(random.nextInt(matrix.getN()));
// System.out.println(" - - guessing item 1 as "+j1+ " with value "+ithRow.get(j1));
}
while (ithRow.get(j1) == 0);
// System.out.println(" - Chose item 1 as "+j1+ " with value "+ithRow.get(j1));
do{
j2 = random.nextInt(matrix.getN());
//j2 = ithRow.get((random.nextInt(matrix.getN())));
// System.out.println(" - - guessing item 2 as"+j2+ " with value "+ithRow.get(j2));
}
while ((justUnseen?1:ithRow.get(j1)) <= ithRow.get(j2));
// System.out.println(" - Chose item 2 as "+j2+ " with value "+ithRow.get(j2));
triple[1] = j1;
triple[2] = j2;
// System.out.println(" - Triple is "+i+ " "+j1+" "+j2);
// Set xscale
if (useXscale)
triple[3] = justUnseen?1:(ithRow.get(j1) - ithRow.get(j2));
return triple;
}
示例13: find
import gnu.trove.map.TIntIntMap; //导入方法依赖的package包/类
private int find(final SlottedContainer container, final int slotId) {
final TIntIntMap slotMap = ReflectionUtil.getFieldValue(slotMapField, container);
if (slotMap.containsKey(slotId))
return slotMap.get(slotId);
LOGGER.warn("Tried to find from an invalid slot on this container {}. Check the container's slot descriptor file to make sure it has slot {}.",
container.getOwner().getNetworkId(),
slotIdManager.getSlotName(slotId));
return -1;
}