本文整理汇总了Java中gnu.trove.map.TIntIntMap类的典型用法代码示例。如果您正苦于以下问题:Java TIntIntMap类的具体用法?Java TIntIntMap怎么用?Java TIntIntMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TIntIntMap类属于gnu.trove.map包,在下文中一共展示了TIntIntMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: TIntIntHashMap
import gnu.trove.map.TIntIntMap; //导入依赖的package包/类
/**
* Creates a new <code>TIntIntHashMap</code> instance containing
* all of the entries in the map passed in.
*
* @param map a <tt>TIntIntMap</tt> that will be duplicated.
*/
public TIntIntHashMap( TIntIntMap map ) {
super( map.size() );
if ( map instanceof TIntIntHashMap ) {
TIntIntHashMap hashmap = ( TIntIntHashMap ) map;
this._loadFactor = hashmap._loadFactor;
this.no_entry_key = hashmap.no_entry_key;
this.no_entry_value = hashmap.no_entry_value;
//noinspection RedundantCast
if ( this.no_entry_key != ( int ) 0 ) {
Arrays.fill( _set, this.no_entry_key );
}
//noinspection RedundantCast
if ( this.no_entry_value != ( int ) 0 ) {
Arrays.fill( _values, this.no_entry_value );
}
setUp( (int) Math.ceil( DEFAULT_CAPACITY / _loadFactor ) );
}
putAll( map );
}
示例2: 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 ) );
}
示例3: 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;
}
}
}
示例4: SparseCounters
import gnu.trove.map.TIntIntMap; //导入依赖的package包/类
private SparseCounters(int minSupport, int transactionsCount, int distinctTransactionsCount,
int distinctTransactionLengthSum, TIntIntMap supportCounts, TIntIntMap distinctTransactionsCounts,
int[] closure, int[] pattern, int nbFrequents, int maxFrequent, int[] reverseRenaming,
boolean compactedArrays, int maxCandidate, int rebasingSize) {
super();
this.minSupport = minSupport;
this.transactionsCount = transactionsCount;
this.distinctTransactionsCount = distinctTransactionsCount;
this.distinctTransactionLengthSum = distinctTransactionLengthSum;
this.supportCounts = supportCounts;
this.distinctTransactionsCounts = distinctTransactionsCounts;
this.closure = closure;
this.pattern = pattern;
this.nbFrequents = nbFrequents;
this.maxFrequent = maxFrequent;
this.reverseRenaming = reverseRenaming;
this.compactedArrays = compactedArrays;
this.maxCandidate = maxCandidate;
this.rebasingSize = rebasingSize;
}
示例5: 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;
}
示例6: getTopKBounds
import gnu.trove.map.TIntIntMap; //导入依赖的package包/类
public final TIntIntMap getTopKBounds() {
final TIntIntMap output = new TIntIntHashMap(this.topK.size());
this.topK.forEachEntry(new TIntObjectProcedure<PatternWithFreq[]>() {
@Override
public boolean execute(int k, PatternWithFreq[] v) {
int s;
PatternWithFreq p = v[v.length - 1];
if (p == null) {
s = -1;
} else if (p.isClosed()) {
s = p.getSupportCount() + 1;
} else {
s = p.getSupportCount();
}
output.put(k, s);
return true;
}
});
return output;
}
示例7: 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;
}
示例8: 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;
}
示例9: 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;
}
示例10: putAll
import gnu.trove.map.TIntIntMap; //导入依赖的package包/类
/** {@inheritDoc} */
public void putAll( TIntIntMap map ) {
ensureCapacity( map.size() );
TIntIntIterator iter = map.iterator();
while ( iter.hasNext() ) {
iter.advance();
this.put( iter.key(), iter.value() );
}
}
示例11: 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;
}
示例12: readExternal
import gnu.trove.map.TIntIntMap; //导入依赖的package包/类
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = ( TIntIntMap ) in.readObject();
}
示例13: 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 ) );
}
示例14: putAll
import gnu.trove.map.TIntIntMap; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public void putAll( TIntIntMap map ) {
ensureCapacity( map.size() );
TIntIntIterator iter = map.iterator();
while ( iter.hasNext() ) {
iter.advance();
this.put( iter.key(), iter.value() );
}
}
示例15: 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;
}