本文整理汇总了Java中gnu.trove.function.TIntFunction类的典型用法代码示例。如果您正苦于以下问题:Java TIntFunction类的具体用法?Java TIntFunction怎么用?Java TIntFunction使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
TIntFunction类属于gnu.trove.function包,在下文中一共展示了TIntFunction类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testTransformValues
import gnu.trove.function.TIntFunction; //导入依赖的package包/类
public void testTransformValues() {
int element_count = 20;
String[] keys = new String[element_count];
int[] vals = new int[element_count];
TObjectIntMap<String> map =
new TObjectIntHashMap<String>( element_count, 0.5f, Integer.MIN_VALUE );
for ( int i = 0; i < element_count; i++ ) {
keys[i] = Integer.toString( i + 1 );
vals[i] = i + 1;
map.put( keys[i], vals[i] );
}
assertEquals( element_count, map.size() );
map.transformValues( new TIntFunction() {
@Override
public int execute( int value ) {
return value * value;
}
} );
for ( int i = 0; i < element_count; i++ ) {
int expected = vals[i] * vals[i];
assertEquals( expected, map.get( keys[i] ) );
}
}
示例2: testTransform
import gnu.trove.function.TIntFunction; //导入依赖的package包/类
public void testTransform() {
int element_count = 20;
TIntList a = new TIntOffheapArrayList();
for ( int i = 1; i < element_count; i++ ) {
a.add( i );
}
a.transformValues( new TIntFunction() {
@Override
public int execute( int value ) {
return value * value;
}
} );
for ( int i = 0; i < a.size(); i++ ) {
int result = a.get( i );
int expected = ( i + 1 ) * ( i + 1 );
assertEquals( expected, result );
}
}
示例3: testTransform
import gnu.trove.function.TIntFunction; //导入依赖的package包/类
public void testTransform() {
int element_count = 20;
TIntList a = new TIntArrayList();
for ( int i = 1; i < element_count; i++ ) {
a.add( i );
}
a.transformValues( new TIntFunction() {
@Override
public int execute( int value ) {
return value * value;
}
} );
for ( int i = 0; i < a.size(); i++ ) {
int result = a.get( i );
int expected = ( i + 1 ) * ( i + 1 );
assertEquals( expected, result );
}
}
示例4: testTransform
import gnu.trove.function.TIntFunction; //导入依赖的package包/类
public void testTransform() {
int element_count = 20;
TIntList a = new TIntLinkedList();
for ( int i = 1; i < element_count; i++ ) {
a.add( i );
}
a.transformValues( new TIntFunction() {
@Override
public int execute( int value ) {
return value * value;
}
} );
for ( int i = 0; i < a.size(); i++ ) {
int result = a.get( i );
int expected = ( i + 1 ) * ( i + 1 );
assertEquals( expected, result );
}
}
示例5: testTransform
import gnu.trove.function.TIntFunction; //导入依赖的package包/类
public void testTransform() {
int element_count = 20;
TIntList a = new TIntLinkedList();
for ( int i = 1; i < element_count; i++ ) {
a.add( i );
}
a.transformValues( new TIntFunction() {
public int execute( int value ) {
return value * value;
}
} );
for ( int i = 0; i < a.size(); i++ ) {
int result = a.get( i );
int expected = ( i + 1 ) * ( i + 1 );
assertEquals( expected, result );
}
}
示例6: testTransformValues
import gnu.trove.function.TIntFunction; //导入依赖的package包/类
public void testTransformValues() {
int element_count = 20;
String[] keys = new String[element_count];
int[] vals = new int[element_count];
TObjectIntMap<String> map = withExpectedSizeAndNoEntryValue( element_count, Integer.MIN_VALUE );
for ( int i = 0; i < element_count; i++ ) {
keys[i] = Integer.toString( i + 1 );
vals[i] = i + 1;
map.put( keys[i], vals[i] );
}
assertEquals( element_count, map.size() );
map.transformValues( new TIntFunction() {
public int execute( int value ) {
return value * value;
}
} );
for ( int i = 0; i < element_count; i++ ) {
int expected = vals[i] * vals[i];
assertEquals( expected, map.get( keys[i] ) );
}
}
示例7: testTransform
import gnu.trove.function.TIntFunction; //导入依赖的package包/类
public void testTransform() {
int element_count = 20;
TIntList a = new TIntArrayList();
for ( int i = 1; i < element_count; i++ ) {
a.add( i );
}
a.transformValues( new TIntFunction() {
public int execute( int value ) {
return value * value;
}
} );
for ( int i = 0; i < a.size(); i++ ) {
int result = a.get( i );
int expected = ( i + 1 ) * ( i + 1 );
assertEquals( expected, result );
}
}
示例8: testTransformValues
import gnu.trove.function.TIntFunction; //导入依赖的package包/类
public void testTransformValues() {
int element_count = 20;
String[] keys = new String[element_count];
int[] vals = new int[element_count];
TObjectIntMap<String> map =
new TObjectIntHashMap<String>( element_count, 0.5f, Integer.MIN_VALUE );
for ( int i = 0; i < element_count; i++ ) {
keys[i] = Integer.toString( i + 1 );
vals[i] = i + 1;
map.put( keys[i], vals[i] );
}
assertEquals( element_count, map.size() );
map.transformValues( new TIntFunction() {
public int execute( int value ) {
return value * value;
}
} );
for ( int i = 0; i < element_count; i++ ) {
int expected = vals[i] * vals[i];
assertEquals( expected, map.get( keys[i] ) );
}
}
示例9: transformValues
import gnu.trove.function.TIntFunction; //导入依赖的package包/类
/** {@inheritDoc} */
public void transformValues( TIntFunction function ) {
byte[] states = _states;
int[] values = _values;
for ( int i = values.length; i-- > 0; ) {
if ( states[i] == FULL ) {
values[i] = function.execute( values[i] );
}
}
}
示例10: transformValues
import gnu.trove.function.TIntFunction; //导入依赖的package包/类
/**
* Transform the values in this map using <tt>function</tt>.
*
* @param function a <code>TIntFunction</code> value
*/
public void transformValues( TIntFunction function ) {
Object[] keys = _set;
int[] values = _values;
for ( int i = values.length; i-- > 0; ) {
if ( keys[i] != null && keys[i] != REMOVED ) {
values[i] = function.execute( values[i] );
}
}
}
示例11: transformValues
import gnu.trove.function.TIntFunction; //导入依赖的package包/类
/** {@inheritDoc} */
public void transformValues(TIntFunction function) {
for (TIntLink l = head; got(l);) {
//
l.setValue(function.execute(l.getValue()));
//
l = l.getNext();
}
}