本文整理汇总了Java中it.unimi.dsi.fastutil.BigArrays.SEGMENT_SHIFT属性的典型用法代码示例。如果您正苦于以下问题:Java BigArrays.SEGMENT_SHIFT属性的具体用法?Java BigArrays.SEGMENT_SHIFT怎么用?Java BigArrays.SEGMENT_SHIFT使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类it.unimi.dsi.fastutil.BigArrays
的用法示例。
在下文中一共展示了BigArrays.SEGMENT_SHIFT属性的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: put
public int put( final long k, final int v ) {
final long h = it.unimi.dsi.fastutil.HashCommon.murmurHash3( k );
// The starting point.
int displ = (int)( h & segmentMask );
int base = (int)( ( h & mask ) >>> BigArrays.SEGMENT_SHIFT );
// There's always an unused entry.
while ( used[ base ][ displ ] ) {
if ( k == key[ base ][ displ ] ) {
final int oldValue = value[ base ][ displ ];
value[ base ][ displ ] = v;
return oldValue;
}
base = ( base + ( ( displ = ( displ + 1 ) & segmentMask ) == 0 ? 1 : 0 ) ) & baseMask;
}
used[ base ][ displ ] = true;
key[ base ][ displ ] = k;
value[ base ][ displ ] = v;
if ( ++size >= maxFill ) rehash( 2 * n );
return -1;
}
示例2: get
public int get( final long k ) {
final long h = it.unimi.dsi.fastutil.HashCommon.murmurHash3( k );
// The starting point.
int displ = (int)( h & segmentMask );
int base = (int)( ( h & mask ) >>> BigArrays.SEGMENT_SHIFT );
// There's always an unused entry.
while ( used[ base ][ displ ] ) {
if ( k == key[ base ][ displ ] ) return value[ base ][ displ ];
base = ( base + ( ( displ = ( displ + 1 ) & segmentMask ) == 0 ? 1 : 0 ) ) & baseMask;
}
return -1;
}
示例3: rehash
protected void rehash( final long newN ) {
final boolean used[][] = this.used;
final long key[][] = this.key;
final int[][] value = this.value;
final boolean newUsed[][] = BooleanBigArrays.newBigArray( newN );
final long newKey[][] = LongBigArrays.newBigArray( newN );
final int newValue[][] = IntBigArrays.newBigArray( newN );
final long newMask = newN - 1;
final int newSegmentMask = newKey[ 0 ].length - 1;
final int newBaseMask = newKey.length - 1;
int base = 0, displ = 0;
long h;
long k;
for ( long i = size; i-- != 0; ) {
while ( !used[ base ][ displ ] )
base = ( base + ( ( displ = ( displ + 1 ) & segmentMask ) == 0 ? 1 : 0 ) );
k = key[ base ][ displ ];
h = it.unimi.dsi.fastutil.HashCommon.murmurHash3( k );
// The starting point.
int d = (int)( h & newSegmentMask );
int b = (int)( ( h & newMask ) >>> BigArrays.SEGMENT_SHIFT );
while ( newUsed[ b ][ d ] )
b = ( b + ( ( d = ( d + 1 ) & newSegmentMask ) == 0 ? 1 : 0 ) ) & newBaseMask;
newUsed[ b ][ d ] = true;
newKey[ b ][ d ] = k;
newValue[ b ][ d ] = value[ base ][ displ ];
base = ( base + ( ( displ = ( displ + 1 ) & segmentMask ) == 0 ? 1 : 0 ) );
}
this.n = newN;
this.key = newKey;
this.value = newValue;
this.used = newUsed;
initMasks();
maxFill = maxFill( n, f );
}