本文整理汇总了Java中gnu.trove.map.TLongLongMap类的典型用法代码示例。如果您正苦于以下问题:Java TLongLongMap类的具体用法?Java TLongLongMap怎么用?Java TLongLongMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TLongLongMap类属于gnu.trove.map包,在下文中一共展示了TLongLongMap类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: TLongLongHashMap
import gnu.trove.map.TLongLongMap; //导入依赖的package包/类
/**
* Creates a new <code>TLongLongHashMap</code> instance containing
* all of the entries in the map passed in.
*
* @param map a <tt>TLongLongMap</tt> that will be duplicated.
*/
public TLongLongHashMap( TLongLongMap map ) {
super( map.size() );
if ( map instanceof TLongLongHashMap ) {
TLongLongHashMap hashmap = ( TLongLongHashMap ) 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 != ( long ) 0 ) {
Arrays.fill( _set, this.no_entry_key );
}
//noinspection RedundantCast
if ( this.no_entry_value != ( long ) 0 ) {
Arrays.fill( _values, this.no_entry_value );
}
setUp( (int) Math.ceil( DEFAULT_CAPACITY / _loadFactor ) );
}
putAll( map );
}
示例2: UnsafeTLongLongHashMap
import gnu.trove.map.TLongLongMap; //导入依赖的package包/类
/**
* Creates a new <code>UnsafeTLongLongHashMap</code> instance containing
* all of the entries in the map passed in.
*
* @param map a <tt>TLongLongMap</tt> that will be duplicated.
*/
public UnsafeTLongLongHashMap( TLongLongMap map ) {
super( map.size() );
if ( map instanceof UnsafeTLongLongHashMap ) {
UnsafeTLongLongHashMap hashmap = ( UnsafeTLongLongHashMap ) 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 != ( long ) 0 ) {
// Arrays.fill( _set, this.no_entry_key );
Arraysfill( keyAddresses[0][0], this.no_entry_key );
}
//noinspection RedundantCast
if ( this.no_entry_value != ( long ) 0 ) {
// Arrays.fill( _values, this.no_entry_value );
Arraysfill( addresses[0][0], this.no_entry_key );
}
setUp( (int) Math.ceil( DEFAULT_CAPACITY / _loadFactor ) );
}
putAll( map );
}
示例3: putAll
import gnu.trove.map.TLongLongMap; //导入依赖的package包/类
/** {@inheritDoc} */
public void putAll( TLongLongMap map ) {
ensureCapacity( map.size() );
TLongLongIterator iter = map.iterator();
while ( iter.hasNext() ) {
iter.advance();
this.put( iter.key(), iter.value() );
}
}
示例4: equals
import gnu.trove.map.TLongLongMap; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public boolean equals( Object other ) {
if ( ! ( other instanceof TLongLongMap ) ) {
return false;
}
TLongLongMap that = ( TLongLongMap ) other;
if ( that.size() != this.size() ) {
return false;
}
long[] values = _values;
byte[] states = _states;
long this_no_entry_value = getNoEntryValue();
long that_no_entry_value = that.getNoEntryValue();
for ( int i = values.length; i-- > 0; ) {
if ( states[i] == FULL ) {
long key = _set[i];
long that_value = that.get( key );
long 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: readExternal
import gnu.trove.map.TLongLongMap; //导入依赖的package包/类
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = ( TLongLongMap ) in.readObject();
}
示例6: putAll
import gnu.trove.map.TLongLongMap; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public void putAll( TLongLongMap map ) {
ensureCapacity( map.size() );
TLongLongIterator iter = map.iterator();
while ( iter.hasNext() ) {
iter.advance();
this.put( iter.key(), iter.value() );
}
}
示例7: equals
import gnu.trove.map.TLongLongMap; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public boolean equals( Object other ) {
if ( ! ( other instanceof TLongLongMap ) ) {
return false;
}
TLongLongMap that = ( TLongLongMap ) other;
if ( that.size() != this.size() ) {
return false;
}
TLongOffheapArray values = _values;
TByteOffheapArray states = _states;
long this_no_entry_value = getNoEntryValue();
long that_no_entry_value = that.getNoEntryValue();
for ( int i = capacity(); i-- > 0; ) {
if ( states.get( i ) == FULL ) {
long key = _set.get( i );
long that_value = that.get( key );
long 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;
}
示例8: readExternal
import gnu.trove.map.TLongLongMap; //导入依赖的package包/类
@Override
public void readExternal( ObjectInput in )
throws IOException, ClassNotFoundException {
// VERSION
in.readByte();
// MAP
_map = ( TLongLongMap ) in.readObject();
}
示例9: equals
import gnu.trove.map.TLongLongMap; //导入依赖的package包/类
/** {@inheritDoc} */
@Override
public boolean equals( Object other ) {
if ( ! ( other instanceof TLongLongMap ) ) {
return false;
}
TLongLongMap that = ( TLongLongMap ) other;
if ( that.size() != this.size() ) {
return false;
}
// long[] values = _values;
// byte[] states = _states;
long this_no_entry_value = getNoEntryValue();
long that_no_entry_value = that.getNoEntryValue();
final int len = unsafe.getInt(addresses[0][0]);
for ( int i = len; i-- > 0; ) {
if ( stateAt(i) == FULL ) {
long key = keyAt(i);
long that_value = that.get( key );
long this_value = valueAt(i);
if ( ( this_value != that_value ) &&
( this_value != this_no_entry_value ) &&
( that_value != that_no_entry_value ) ) {
return false;
}
}
}
return true;
}
示例10: testHeavyHitters
import gnu.trove.map.TLongLongMap; //导入依赖的package包/类
@Test
public void testHeavyHitters() {
double epsOfTotalCount = 0.0001;
double confidence = 0.99;
int seed = 7364181;
CountMinSketch sketch = new CountMinSketch(epsOfTotalCount, confidence, seed);
int maxItems = 1000;
Random random = new Random();
TLongLongMap actualItemCount = new TLongLongHashMap(maxItems);
random.setSeed(12102);
for (int i = 0; i < maxItems; i++) {
int itemCount = random.nextInt(20000);
sketch.add(i, itemCount);
actualItemCount.put(i, itemCount);
}
List<Item> itemsBagFromSketch = new ArrayList<Item>();
List<Item> itemsBagActual = new ArrayList<Item>();
for (int i = 0; i < maxItems; i++) {
itemsBagFromSketch.add(new Item(i, sketch.estimateCount(i)));
itemsBagActual.add(new Item(i, actualItemCount.get(i)));
}
Ordering<Item> ordering = new Ordering<Item>() {
@Override
public int compare(Item me, Item other) {
return Long.compare(me.count, other.count);
}
};
List<Item> topKItemsEstimated = ordering.greatestOf(itemsBagFromSketch, 5);
List<Item> topKItemsActual = ordering.greatestOf(itemsBagActual, 5);
/*
System.out.println("Top 5 estimated items");
for (Item item : topKItemsEstimated) {
System.out.println(item);
}
*/
/*
System.out.println("Top 5 actual");*/
for (int i = 0; i < topKItemsActual.size(); i++) {
assertEquals(true, topKItemsActual.get(i).checkForEquality(topKItemsEstimated.get(i)));
}
}
示例11: getMap
import gnu.trove.map.TLongLongMap; //导入依赖的package包/类
public TLongLongMap getMap() {
return container;
}
示例12: TLongLongMapDecorator
import gnu.trove.map.TLongLongMap; //导入依赖的package包/类
/**
* Creates a wrapper that decorates the specified primitive map.
*
* @param map the <tt>TLongLongMap</tt> to wrap.
*/
public TLongLongMapDecorator( TLongLongMap map ) {
super();
this._map = map;
}