本文整理汇总了Java中gnu.trove.map.hash.TLongIntHashMap.put方法的典型用法代码示例。如果您正苦于以下问题:Java TLongIntHashMap.put方法的具体用法?Java TLongIntHashMap.put怎么用?Java TLongIntHashMap.put使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gnu.trove.map.hash.TLongIntHashMap
的用法示例。
在下文中一共展示了TLongIntHashMap.put方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testChangeNoEntryValues
import gnu.trove.map.hash.TLongIntHashMap; //导入方法依赖的package包/类
@Test
public void testChangeNoEntryValues() {
//@formatter:off
TLongIntHashMap map = new TLongIntHashMap(
Constants.DEFAULT_CAPACITY,
Constants.DEFAULT_LOAD_FACTOR,
-1L, // no-key value
-1 // no entry value
);
//@formatter:on
map.put(4, 2);
Assert.assertEquals(-1L, map.getNoEntryKey());
Assert.assertEquals(-1, map.getNoEntryValue());
Assert.assertEquals(-1, map.get(5L));
Assert.assertEquals(2, map.get(4L));
Assert.assertTrue(map.contains(4));
Assert.assertFalse(map.contains(5));
}
示例2: addResultToMap
import gnu.trove.map.hash.TLongIntHashMap; //导入方法依赖的package包/类
public static void addResultToMap(TLongIntHashMap results, TLongIntHashMap resultsToAdd) {
long[] resultsToAddKeys = resultsToAdd.keys();
int[] resultsToAddValues = resultsToAdd.values();
for (int i = 0; i < resultsToAddKeys.length; i++) {
int count = 0;
if (results.contains(resultsToAddKeys[i])) {
count = results.get(resultsToAddKeys[i]);
}
count += resultsToAddValues[i];
results.put(resultsToAddKeys[i], count);
}
}
示例3: Alphabet
import gnu.trove.map.hash.TLongIntHashMap; //导入方法依赖的package包/类
public Alphabet(Alphabet a)
{
numEntries = a.numEntries;
map = new TLongIntHashMap(numEntries);
for (TLongIntIterator iter = a.map.iterator(); iter.hasNext();) {
iter.advance();
map.put(iter.key(), iter.value());
}
}
示例4: L_HammingLongs
import gnu.trove.map.hash.TLongIntHashMap; //导入方法依赖的package包/类
public L_HammingLongs(File file) throws Exception {
DataInputStream in = new DataInputStream(new BufferedInputStream(
new FileInputStream(file)));
File bFile = new File(file.getAbsolutePath() + ".b");
bucketsRAF = new RandomAccessFile(bFile, "r");
fileChannel = bucketsRAF.getChannel();
h = in.readInt();
nh = 1 << h;
g = new G_HammingLongs(in);
int nNotNulls = in.readInt();
//bSize = new int[nh];
//bucketOffset = new long[nh];
bSize = new TLongIntHashMap();;
bucketOffset = new TLongLongHashMap();
long offsetAcc = 0;
for ( int i=0; i<nNotNulls; i++ ) {
int ib = in.readInt();
int csize = in.readInt();
//bSize[ib] = csize;
//bucketOffset[ib] = offsetAcc;
bSize.put(ib, csize);
bucketOffset.put(ib, offsetAcc);
if (csize != 0) {
offsetAcc += csize * Integer.BYTES;
}
}
in.close();
}
示例5: loadArrayLevel0
import gnu.trove.map.hash.TLongIntHashMap; //导入方法依赖的package包/类
@Override
public VolatileLabelMultisetArray loadArrayLevel0(
final int[] dimensions,
final long[] min ) throws InterruptedException
{
int[] data = null;
final MDIntArray block = reader.readMDArrayBlockWithOffset(
dataset,
new int[]{ dimensions[ 2 ], dimensions[ 1 ], dimensions[ 0 ] },
new long[]{ min[ 2 ], min[ 1 ], min[ 0 ] } );
data = block.getAsFlatArray();
if ( data == null )
{
System.out.println(
"H5 short label multiset array loader failed loading min = " +
Arrays.toString( min ) +
", dimensions = " +
Arrays.toString( dimensions ) );
data = new int[ dimensions[ 0 ] * dimensions[ 1 ] * dimensions[ 2 ] ];
}
final int[] offsets = new int[ dimensions[ 2 ] * dimensions[ 1 ] * dimensions[ 0 ] ];
final LongMappedAccessData listData = LongMappedAccessData.factory.createStorage( 32 );
final LabelMultisetEntryList list = new LabelMultisetEntryList( listData, 0 );
final LabelMultisetEntry entry = new LabelMultisetEntry( 0, 1 );
int nextListOffset = 0;
final TLongIntHashMap idOffsetHash = new TLongIntHashMap(
Constants.DEFAULT_CAPACITY,
Constants.DEFAULT_LOAD_FACTOR,
-1,
-1);
A: for ( int i = 0; i < data.length; ++i )
{
final long id = data[ i ] & 0xffffffffL;
final int offset = idOffsetHash.get( id );
if ( offset == idOffsetHash.getNoEntryValue() )
{
list.createListAt( listData, nextListOffset );
entry.setId( id );
list.add( entry );
offsets[ i ] = nextListOffset;
idOffsetHash.put( id, nextListOffset );
nextListOffset += list.getSizeInBytes();
}
else
{
offsets[ i ] = offset;
continue A;
}
}
// System.out.println( listData.size() );
return new VolatileLabelMultisetArray( offsets, listData, true );
}
示例6: loadArrayLevel0
import gnu.trove.map.hash.TLongIntHashMap; //导入方法依赖的package包/类
@Override
public VolatileLabelMultisetArray loadArrayLevel0(
final int[] dimensions,
final long[] min ) throws InterruptedException
{
short[] data = null;
final MDShortArray block = reader.readMDArrayBlockWithOffset(
dataset,
new int[]{ dimensions[ 2 ], dimensions[ 1 ], dimensions[ 0 ] },
new long[]{ min[ 2 ], min[ 1 ], min[ 0 ] } );
data = block.getAsFlatArray();
if ( data == null )
{
System.out.println(
"H5 short label multiset array loader failed loading min = " +
Arrays.toString( min ) +
", dimensions = " +
Arrays.toString( dimensions ) );
data = new short[ dimensions[ 0 ] * dimensions[ 1 ] * dimensions[ 2 ] ];
}
final int[] offsets = new int[ dimensions[ 2 ] * dimensions[ 1 ] * dimensions[ 0 ] ];
final LongMappedAccessData listData = LongMappedAccessData.factory.createStorage( 32 );
final LabelMultisetEntryList list = new LabelMultisetEntryList( listData, 0 );
final LabelMultisetEntry entry = new LabelMultisetEntry( 0, 1 );
int nextListOffset = 0;
final TLongIntHashMap idOffsetHash = new TLongIntHashMap(
Constants.DEFAULT_CAPACITY,
Constants.DEFAULT_LOAD_FACTOR,
-1,
-1);
A: for ( int i = 0; i < data.length; ++i )
{
final long id = data[ i ] & 0xffffL;
// does the list [id x 1] already exist?
final int offset = idOffsetHash.get( id );
if ( offset == idOffsetHash.getNoEntryValue() )
{
list.createListAt( listData, nextListOffset );
entry.setId( id );
list.add( entry );
offsets[ i ] = nextListOffset;
idOffsetHash.put( id, nextListOffset );
nextListOffset += list.getSizeInBytes();
}
else
{
offsets[ i ] = offset;
continue A;
}
}
// System.out.println( listData.size() );
return new VolatileLabelMultisetArray( offsets, listData, true );
}
示例7: loadArrayLevel0
import gnu.trove.map.hash.TLongIntHashMap; //导入方法依赖的package包/类
@Override
public VolatileLabelMultisetArray loadArrayLevel0(
final int[] dimensions,
final long[] min ) throws InterruptedException
{
float[] data = null;
final MDFloatArray block = reader.readMDArrayBlockWithOffset(
dataset,
new int[]{ dimensions[ 2 ], dimensions[ 1 ], dimensions[ 0 ] },
new long[]{ min[ 2 ], min[ 1 ], min[ 0 ] } );
data = block.getAsFlatArray();
if ( data == null )
{
System.out.println(
"H5 short label multiset array loader failed loading min = " +
Arrays.toString( min ) +
", dimensions = " +
Arrays.toString( dimensions ) );
data = new float[ dimensions[ 0 ] * dimensions[ 1 ] * dimensions[ 2 ] ];
}
final int[] offsets = new int[ dimensions[ 2 ] * dimensions[ 1 ] * dimensions[ 0 ] ];
final LongMappedAccessData listData = LongMappedAccessData.factory.createStorage( 32 );
final LabelMultisetEntryList list = new LabelMultisetEntryList( listData, 0 );
final LabelMultisetEntry entry = new LabelMultisetEntry( 0, 1 );
int nextListOffset = 0;
final TLongIntHashMap idOffsetHash = new TLongIntHashMap(
Constants.DEFAULT_CAPACITY,
Constants.DEFAULT_LOAD_FACTOR,
-1,
-1);
A: for ( int i = 0; i < data.length; ++i )
{
final long id = Float.floatToIntBits( data[ i ] ) & 0xffffffffL;
final int offset = idOffsetHash.get( id );
if ( offset == idOffsetHash.getNoEntryValue() )
{
list.createListAt( listData, nextListOffset );
entry.setId( id );
list.add( entry );
offsets[ i ] = nextListOffset;
idOffsetHash.put( id, nextListOffset );
nextListOffset += list.getSizeInBytes();
}
else
{
offsets[ i ] = offset;
continue A;
}
}
// System.out.println( listData.size() );
return new VolatileLabelMultisetArray( offsets, listData, true );
}
示例8: loadArrayLevel0
import gnu.trove.map.hash.TLongIntHashMap; //导入方法依赖的package包/类
@Override
public VolatileLabelMultisetArray loadArrayLevel0(
final int[] dimensions,
final long[] min ) throws InterruptedException
{
long[] data = null;
final MDLongArray block = reader.readMDArrayBlockWithOffset(
dataset,
new int[]{ dimensions[ 2 ], dimensions[ 1 ], dimensions[ 0 ] },
new long[]{ min[ 2 ], min[ 1 ], min[ 0 ] } );
data = block.getAsFlatArray();
if ( data == null )
{
System.out.println(
"H5 long label multiset array loader failed loading min = " +
Arrays.toString( min ) +
", dimensions = " +
Arrays.toString( dimensions ) );
data = new long[ dimensions[ 0 ] * dimensions[ 1 ] * dimensions[ 2 ] ];
}
final int[] offsets = new int[ dimensions[ 2 ] * dimensions[ 1 ] * dimensions[ 0 ] ];
final LongMappedAccessData listData = LongMappedAccessData.factory.createStorage( 32 );
final LabelMultisetEntryList list = new LabelMultisetEntryList( listData, 0 );
final LabelMultisetEntry entry = new LabelMultisetEntry( 0, 1 );
int nextListOffset = 0;
final TLongIntHashMap idOffsetHash = new TLongIntHashMap(
Constants.DEFAULT_CAPACITY,
Constants.DEFAULT_LOAD_FACTOR,
-1,
-1 );
A: for ( int i = 0; i < data.length; ++i )
{
final long id = data[ i ];
// does the list [id x 1] already exist?
final int offset = idOffsetHash.get( id );
if ( offset == idOffsetHash.getNoEntryValue() )
{
list.createListAt( listData, nextListOffset );
entry.setId( id );
list.add( entry );
offsets[ i ] = nextListOffset;
idOffsetHash.put( id, nextListOffset );
nextListOffset += list.getSizeInBytes();
}
else
{
offsets[ i ] = offset;
continue A;
}
}
// System.out.println( listData.size() );
return new VolatileLabelMultisetArray( offsets, listData, nextListOffset, true );
}