本文整理汇总了Java中gnu.trove.map.TIntIntMap.put方法的典型用法代码示例。如果您正苦于以下问题:Java TIntIntMap.put方法的具体用法?Java TIntIntMap.put怎么用?Java TIntIntMap.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gnu.trove.map.TIntIntMap
的用法示例。
在下文中一共展示了TIntIntMap.put方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testEquals
import gnu.trove.map.TIntIntMap; //导入方法依赖的package包/类
public void testEquals() {
int[] keys = {1138, 42, 86, 99, 101, 727, 117};
long[] vals = new long[keys.length];
TIntLongMap map = new TIntLongOffheapHashMap();
for ( int i = 0; i < keys.length; i++ ) {
vals[i] = keys[i] * 2;
map.put( keys[i], vals[i] );
}
assertEquals( map, map );
TIntIntMap int_map = new TIntIntOffheapHashMap();
for ( int i = 0; i < keys.length; i++ ) {
int_map.put( keys[i], (int) vals[i] );
}
assertFalse( map.equals( int_map ) );
}
示例2: 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;
}
}
}
示例3: readIntIntMap
import gnu.trove.map.TIntIntMap; //导入方法依赖的package包/类
private static TIntIntMap readIntIntMap(URI[] files, Configuration conf, String token, int size) throws IOException {
TIntIntMap map = new TIntIntHashMap(size, Constants.DEFAULT_LOAD_FACTOR, -1, -1);
for (URI file : files) {
if (file.getPath().contains(token)) {
SequenceFile.Reader reader = new SequenceFile.Reader(conf, Reader.file(new Path(file)));
IntWritable key = new IntWritable();
IntWritable value = new IntWritable();
while (reader.next(key, value)) {
map.put(key.get(), value.get());
}
reader.close();
}
}
return map;
}
示例4: internalDoSlottedAdd
import gnu.trove.map.TIntIntMap; //导入方法依赖的package包/类
private boolean internalDoSlottedAdd(final SlottedContainer container,
final GameObject item,
final int position,
final int arrangementIndex) {
if (arrangementIndex < 0)
return false;
final SlottedContainmentProperty slottedProperty = item.getProperty(SlottedContainmentProperty.getClassPropertyId());
final int numSlots = slottedProperty.getNumberOfSlots(arrangementIndex);
final TIntIntMap slotMap = ReflectionUtil.getFieldValue(slotMapField, container);
for (int i = 0; i < numSlots; ++i) {
final int slotId = slottedProperty.getSlotId(arrangementIndex, i);
if (!slotMap.containsKey(slotId)) {
LOGGER.error("We're trying to add an item to a slotted container that does not have a slot that this item {} with this arrangement {} can go into or has something in it already.",
item.getNetworkId(),
arrangementIndex);
} else {
slotMap.put(slotId, position);
}
}
return true;
}
示例5: 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;
}
示例6: testEquals
import gnu.trove.map.TIntIntMap; //导入方法依赖的package包/类
public void testEquals() {
int[] keys = {1138, 42, 86, 99, 101, 727, 117};
long[] vals = new long[keys.length];
TIntLongMap map = new TIntLongHashMap();
for ( int i = 0; i < keys.length; i++ ) {
vals[i] = keys[i] * 2;
map.put( keys[i], vals[i] );
}
assertEquals( map, map );
TIntIntMap int_map = new TIntIntHashMap();
for ( int i = 0; i < keys.length; i++ ) {
int_map.put( keys[i], (int) vals[i] );
}
assertFalse( map.equals( int_map ) );
// Change a value..
TIntLongMap unequal = new TIntLongHashMap( map );
map.put( keys[3], vals[3] + 1 );
assertFalse( map.equals( unequal ) );
// Change length
unequal = new TIntLongHashMap( map );
map.put( 13, 26 );
assertFalse( map.equals( unequal ) );
}
示例7: testFilteredReader
import gnu.trove.map.TIntIntMap; //导入方法依赖的package包/类
@Test
public void testFilteredReader() {
int groupsCount = 2;
int maxItem = 4;
int singleGroupID = 1;
SingleGroup filter = new SingleGroup(groupsCount, maxItem, singleGroupID);
TIntIntMap renaming = new TIntIntHashMap();
renaming.put(1, 3);
renaming.put(2, -1);
renaming.put(3, 2);
renaming.put(5, 1);
renaming.put(6, 4);
renaming.put(7, 0);
FileFilteredReader reader = null;
reader = new FileFilteredReader(new File(PATH_MICRO).toURI(), renaming, filter);
assertTrue(reader.hasNext());
readLine(reader.next(), 1, 2, 3, 4, 0);
readLine(reader.next(), 1, 2, 3, 4);
readLine(reader.next(), 1, 0);
// readLine(reader.next(), 0,2); filtered !
readLine(reader.next(), 1, 2, 3, 4, 0);
assertFalse(reader.hasNext());
reader.close(new int[] { -1, 0, -1, -1, -1 });
assertTrue(reader.hasNext());
readLine(reader.next(), 0);
readLine(reader.next(), 0);
readLine(reader.next(), 0);
readLine(reader.next(), 0);
assertFalse(reader.hasNext());
}
示例8: testEquals
import gnu.trove.map.TIntIntMap; //导入方法依赖的package包/类
public void testEquals() {
int[] keys = {1138, 42, 86, 99, 101, 727, 117};
long[] vals = new long[keys.length];
TIntLongMap map = new TIntLongHashMap();
for ( int i = 0; i < keys.length; i++ ) {
vals[i] = keys[i] * 2;
map.put( keys[i], vals[i] );
}
assertEquals( map, map );
TIntIntMap int_map = new TIntIntHashMap();
for ( int i = 0; i < keys.length; i++ ) {
int_map.put( keys[i], (int) vals[i] );
}
assertFalse( map.equals( int_map ) );
// Change a value..
TIntLongMap unequal = new TIntLongHashMap( map );
map.put( keys[3], vals[3] + 1 );
assertFalse( map.equals( unequal ) );
// Change length
unequal = new TIntLongHashMap( map );
map.put( 13, 26 );
assertFalse( map.equals( unequal ) );
}
示例9: test
import gnu.trove.map.TIntIntMap; //导入方法依赖的package包/类
@Override
public int test() {
final TIntIntMap m_map = new TIntIntHashMap( m_keys.length, m_fillFactor );
for ( int i = 0; i < m_keys.length; ++i )
m_map.put( m_keys[ i ], m_keys[ i ] );
for ( int i = 0; i < m_keys.length; ++i )
m_map.put( m_keys[ i ], m_keys[ i ] );
return m_map.size();
}