当前位置: 首页>>代码示例>>Java>>正文


Java TObjectFunction类代码示例

本文整理汇总了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] ) );
    }
}
 
开发者ID:palantir,项目名称:trove-3.0.3,代码行数:27,代码来源:TPrimitiveObjectHashMapTest.java

示例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" ) );
}
 
开发者ID:palantir,项目名称:trove-3.0.3,代码行数:25,代码来源:THashMapTest.java

示例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] ) );
    }
}
 
开发者ID:leventov,项目名称:trove-over-koloboke-compile,代码行数:26,代码来源:TPrimitiveObjectHashMapTest.java

示例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" ) );
}
 
开发者ID:leventov,项目名称:trove-over-koloboke-compile,代码行数:24,代码来源:THashMapTest.java

示例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] );
        }
    }
}
 
开发者ID:JianpingZeng,项目名称:xcc,代码行数:11,代码来源:TLongObjectHashMap.java

示例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] );
        }
    }
}
 
开发者ID:JianpingZeng,项目名称:xcc,代码行数:15,代码来源:TCustomHashMap.java

示例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]);
        }
    }
}
 
开发者ID:JianpingZeng,项目名称:xcc,代码行数:15,代码来源:THashMap.java

示例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] );
        }
    }
}
 
开发者ID:funkemunky,项目名称:HCFCore,代码行数:10,代码来源:TLongObjectHashMap.java

示例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] );
        }
    }
}
 
开发者ID:palantir,项目名称:trove-3.0.3,代码行数:16,代码来源:TCustomHashMap.java

示例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]);
        }
    }
}
 
开发者ID:palantir,项目名称:trove-3.0.3,代码行数:16,代码来源:THashMap.java

示例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] );
        }
    }
}
 
开发者ID:palantir,项目名称:trove-3.0.3,代码行数:12,代码来源:TLongObjectHashMap.java


注:本文中的gnu.trove.function.TObjectFunction类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。