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