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


Java TObjectIntIterator.advance方法代码示例

本文整理汇总了Java中gnu.trove.iterator.TObjectIntIterator.advance方法的典型用法代码示例。如果您正苦于以下问题:Java TObjectIntIterator.advance方法的具体用法?Java TObjectIntIterator.advance怎么用?Java TObjectIntIterator.advance使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在gnu.trove.iterator.TObjectIntIterator的用法示例。


在下文中一共展示了TObjectIntIterator.advance方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testIteratorRemoval2

import gnu.trove.iterator.TObjectIntIterator; //导入方法依赖的package包/类
public void testIteratorRemoval2() {
    int element_count = 10000;
    int remaining = element_count / 2;

    TObjectIntHashMap<String> map =
            new TObjectIntHashMap<String>( element_count, 0.5f, Integer.MIN_VALUE );

    for ( int pass = 0; pass < 10; pass++ ) {
        Random r = new Random();
        for ( int i = 0; i <= element_count; i++ ) {
            map.put( String.valueOf( r.nextInt() ), i );
        }

        TObjectIntIterator iterator = map.iterator();
        while ( map.size() > remaining && iterator.hasNext() ) {
            iterator.advance();
            iterator.remove();
        }
    }
}
 
开发者ID:palantir,项目名称:trove-3.0.3,代码行数:21,代码来源:TObjectPrimitiveHashMapTest.java

示例2: diagnostics

import gnu.trove.iterator.TObjectIntIterator; //导入方法依赖的package包/类
@SubscribeEvent(priority = EventPriority.LOW)
public void diagnostics(final DiagnosticEvent.Gather event) {
	final TObjectIntHashMap<String> counts = new TObjectIntHashMap<String>();

	final Iterator<Entry<String, ISound>> iterator = this.playingSounds.entrySet().iterator();
	while (iterator.hasNext()) {
		Entry<String, ISound> entry = iterator.next();
		ISound isound = entry.getValue();
		counts.adjustOrPutValue(isound.getSound().getSoundLocation().toString(), 1, 1);
	}

	final ArrayList<String> results = new ArrayList<String>();
	final TObjectIntIterator<String> itr = counts.iterator();
	while (itr.hasNext()) {
		itr.advance();
		results.add(String.format(TextFormatting.GOLD + "%s: %d", itr.key(), itr.value()));
	}
	Collections.sort(results);
	event.output.addAll(results);

}
 
开发者ID:OreCruncher,项目名称:DynamicSurroundings,代码行数:22,代码来源:SoundManagerReplacement.java

示例3: getBiomeSounds

import gnu.trove.iterator.TObjectIntIterator; //导入方法依赖的package包/类
private static void getBiomeSounds(@Nonnull final TObjectFloatHashMap<SoundEffect> result) {
	// Need to collect sounds from all the applicable biomes
	// along with their weights.
	final TObjectIntIterator<BiomeInfo> info = AreaSurveyHandler.getBiomes().iterator();
	while (info.hasNext()) {
		info.advance();
		final List<SoundEffect> bs = new ArrayList<SoundEffect>();
		info.key().findSoundMatches(bs);
		for (final SoundEffect sound : bs) {
			final int w = info.value();
			result.adjustOrPutValue(sound, w, w);
		}
	}

	// Scale the volumes in the resulting list based on the weights
	final int area = AreaSurveyHandler.getBiomeArea();
	final TObjectFloatIterator<SoundEffect> itr = result.iterator();
	while (itr.hasNext()) {
		itr.advance();
		final float scale = 0.1F + 0.9F * ((float) itr.value() / (float) area);
		itr.setValue(scale);
	}
}
 
开发者ID:OreCruncher,项目名称:DynamicSurroundings,代码行数:24,代码来源:AreaSoundEffectHandler.java

示例4: testIteratorRemoval2

import gnu.trove.iterator.TObjectIntIterator; //导入方法依赖的package包/类
public void testIteratorRemoval2() {
    int element_count = 10000;
    int remaining = element_count / 2;

    TObjectIntMap<String> map = withExpectedSizeAndNoEntryValue( element_count, Integer.MIN_VALUE );

    for ( int pass = 0; pass < 10; pass++ ) {
        Random r = new Random();
        for ( int i = 0; i <= element_count; i++ ) {
            map.put( String.valueOf( r.nextInt() ), i );
        }

        TObjectIntIterator iterator = map.iterator();
        while ( map.size() > remaining && iterator.hasNext() ) {
            iterator.advance();
            iterator.remove();
        }
    }
}
 
开发者ID:leventov,项目名称:trove-over-koloboke-compile,代码行数:20,代码来源:TObjectPrimitiveHashMapTest.java

示例5: getPathFromIndex

import gnu.trove.iterator.TObjectIntIterator; //导入方法依赖的package包/类
/**
 * Get string path from index
 * @param     index  index of the string path
 * @return    string path
 */
public String getPathFromIndex(int index){
	
	synchronized(path_index){
		
		TObjectIntIterator<String> it = path_index.iterator();
		while(it.hasNext()){
			it.advance();
			if(it.value()==index)
				return (String) it.key();
		}
		
		return null;
	}
	
}
 
开发者ID:sisinflab,项目名称:lodreclib,代码行数:21,代码来源:TopItemPathExtractorWorker.java

示例6: getPreferredName

import gnu.trove.iterator.TObjectIntIterator; //导入方法依赖的package包/类
/**
 * PUBLIC: Returns the preferred variant of the term. This is a form
 * of the term which actually occurred in the classified content.
 */
public String getPreferredName() {
  if (variants.isEmpty())
    return getStem();
  Variant maxKey = null;
  int maxValue = -1;
  TObjectIntIterator<Variant> iter = variants.iterator();
  while (iter.hasNext()) {
    iter.advance();
    int thisValue = iter.value();
    Variant thisKey = iter.key();
    // select variant with most occurrences, or lowest lexical value if equal for predictability
    if ((thisValue > maxValue) ||
        ((thisValue == maxValue) && (thisKey.getValue().compareTo(maxKey.getValue()) < 0))) {
      maxValue = thisValue;
      maxKey = thisKey;
    }
  }
  return maxKey.getValue();
}
 
开发者ID:ontopia,项目名称:ontopia,代码行数:24,代码来源:Term.java

示例7: merge

import gnu.trove.iterator.TObjectIntIterator; //导入方法依赖的package包/类
protected void merge(Term other) {
  if (other == this) return;
  
  this.score = this.score + other.score;    
  this.totalOccurrences = this.totalOccurrences + other.totalOccurrences;

  TObjectIntIterator<Variant> iter = other.variants.iterator();
  while (iter.hasNext()) {
    iter.advance();
    Variant key = iter.key();
    int value = iter.value();
    if (this.variants.containsKey(key))
      this.variants.adjustValue(key, value);
    else
      this.variants.put(key, value);
    key.replaceTerm(this);
  }
}
 
开发者ID:ontopia,项目名称:ontopia,代码行数:19,代码来源:Term.java

示例8: equals

import gnu.trove.iterator.TObjectIntIterator; //导入方法依赖的package包/类
/**
 * Compares this map with another map for equality of their stored
 * entries.
 *
 * @param other an <code>Object</code> value
 * @return a <code>boolean</code> value
 */
public boolean equals( Object other ) {
    if ( ! ( other instanceof TObjectIntMap ) ) {
        return false;
    }
    TObjectIntMap that = ( TObjectIntMap ) other;
    if ( that.size() != this.size() ) {
        return false;
    }
    try {
        TObjectIntIterator iter = this.iterator();
        while ( iter.hasNext() ) {
            iter.advance();
            Object key = iter.key();
            int value = iter.value();
            if ( value == no_entry_value ) {
                if ( !( that.get( key ) == that.getNoEntryValue() &&
                 that.containsKey( key ) ) ) {

                    return false;
                }
            } else {
                if ( value != that.get( key ) ) {
                    return false;
                }
            }
        }
    } catch ( ClassCastException ex ) {
        // unused.
    }
    return true;
}
 
开发者ID:JianpingZeng,项目名称:xcc,代码行数:39,代码来源:TObjectIntHashMap.java

示例9: equals

import gnu.trove.iterator.TObjectIntIterator; //导入方法依赖的package包/类
/**
 * Compares this map with another map for equality of their stored
 * entries.
 *
 * @param other an <code>Object</code> value
 * @return a <code>boolean</code> value
 */
@Override
@SuppressWarnings("rawtypes")
public boolean equals( Object other ) {
    if ( ! ( other instanceof TObjectIntMap ) ) {
        return false;
    }
    TObjectIntMap that = ( TObjectIntMap ) other;
    if ( that.size() != this.size() ) {
        return false;
    }
    try {
        TObjectIntIterator iter = this.iterator();
        while ( iter.hasNext() ) {
            iter.advance();
            Object key = iter.key();
            int value = iter.value();
            if ( value == no_entry_value ) {
                if ( !( that.get( key ) == that.getNoEntryValue() &&
                 that.containsKey( key ) ) ) {

                    return false;
                }
            } else {
                if ( value != that.get( key ) ) {
                    return false;
                }
            }
        }
    } catch ( ClassCastException ex ) {
        // unused.
    }
    return true;
}
 
开发者ID:palantir,项目名称:trove-3.0.3,代码行数:41,代码来源:TObjectIntHashMap.java

示例10: equals

import gnu.trove.iterator.TObjectIntIterator; //导入方法依赖的package包/类
/**
 * Compares this map with another map for equality of their stored
 * entries.
 *
 * @param other an <code>Object</code> value
 * @return a <code>boolean</code> value
 */
public boolean equals( Object other ) {
    if ( ! ( other instanceof TObjectIntMap ) ) {
        return false;
    }
    TObjectIntMap that = ( TObjectIntMap ) other;
    if ( that.size() != this.size() ) {
        return false;
    }
    try {
        TObjectIntIterator iter = this.iterator();
        while ( iter.hasNext() ) {
            iter.advance();
            Object key = iter.key();
            int value = iter.value();
            if ( value == no_entry_value ) {
                if ( !( that.get( key ) == that.getNoEntryValue() && that.containsKey( key ) ) ) {
                    return false;
                }
            } else {
                if ( value != that.get( key ) ) {
                    return false;
                }
            }
        }
    } catch ( ClassCastException ex ) {
        // unused.
    }
    return true;
}
 
开发者ID:major2015,项目名称:easyrec_major,代码行数:37,代码来源:TObjectIntHashMap.java

示例11: testString_TPrimitiveHashMap

import gnu.trove.iterator.TObjectIntIterator; //导入方法依赖的package包/类
@Override
public void testString_TPrimitiveHashMap() {
	int total = 0;

	for( int i = 0; i < ITERATIONS_STRING; i++ ) {
		TObjectIntIterator<String> iterator = string_t_primitive_map.iterator();
		while( iterator.hasNext() ) {
			iterator.advance();
			total += iterator.key().length();
		}
	}

	int_slot.set( total );
}
 
开发者ID:leventov,项目名称:trove-over-koloboke-compile,代码行数:15,代码来源:IterationBenchmark.java

示例12: annotate

import gnu.trove.iterator.TObjectIntIterator; //导入方法依赖的package包/类
@Override
public List<ScoredAnnotation<ANNOTATION>> annotate(final OBJECT object) {
	if (this.nn == null)
		this.nn = new ObjectNearestNeighboursExact<FEATURE>(this.features, this.comparator);

	final TObjectIntHashMap<ANNOTATION> selected = new TObjectIntHashMap<ANNOTATION>();

	final List<FEATURE> queryfv = new ArrayList<FEATURE>(1);
	queryfv.add(this.extractor.extractFeature(object));

	final int[][] indices = new int[1][this.k];
	final float[][] distances = new float[1][this.k];

	this.nn.searchKNN(queryfv, this.k, indices, distances);

	int count = 0;
	for (int i = 0; i < this.k; i++) {
		// Distance check
		if (distances[0][i] > this.threshold) {
			continue;
		}

		final Collection<ANNOTATION> anns = this.annotations.get(indices[0][i]);

		for (final ANNOTATION ann : anns) {
			selected.adjustOrPutValue(ann, 1, 1);
			count++;
		}
	}

	final TObjectIntIterator<ANNOTATION> iterator = selected.iterator();
	final List<ScoredAnnotation<ANNOTATION>> result = new ArrayList<ScoredAnnotation<ANNOTATION>>(selected.size());
	while (iterator.hasNext()) {
		iterator.advance();

		result.add(new ScoredAnnotation<ANNOTATION>(iterator.key(), (float) iterator.value() / (float) count));
	}

	return result;
}
 
开发者ID:openimaj,项目名称:openimaj,代码行数:41,代码来源:KNNAnnotator.java

示例13: testIterator

import gnu.trove.iterator.TObjectIntIterator; //导入方法依赖的package包/类
public void testIterator() {
    TObjectIntHashMap<String> map = new TObjectIntHashMap<String>();

    TObjectIntIterator<String> iterator = map.iterator();
    assertFalse( iterator.hasNext() );

    map.put( "one", 1 );
    map.put( "two", 2 );

    iterator = map.iterator();
    assertTrue( iterator.hasNext() );
    iterator.advance();

    String first_key = iterator.key();
    assertNotNull( "key was null", first_key );
    assertTrue( "invalid key: " + first_key,
            first_key.equals( "one" ) || first_key.equals( "two" ) );
    if ( first_key.equals( "one" ) ) {
        assertEquals( 1, iterator.value() );
    } else {
        assertEquals( 2, iterator.value() );
    }

    assertTrue( iterator.hasNext() );
    iterator.advance();
    String second_key = iterator.key();
    assertNotNull( "key was null", second_key );
    assertTrue( "invalid key: " + second_key,
            second_key.equals( "one" ) || second_key.equals( "two" ) );
    if ( second_key.equals( "one" ) ) {
        assertEquals( 1, iterator.value() );
    } else {
        assertEquals( 2, iterator.value() );
    }
    assertFalse( first_key + ", " + second_key, first_key.equals( second_key ) );

    assertFalse( iterator.hasNext() );

    // New Iterator
    iterator = map.iterator();
    iterator.advance();
    first_key = iterator.key();
    iterator.setValue( 1138 );
    assertEquals( 1138, iterator.value() );
    assertEquals( 1138, map.get( first_key ) );
}
 
开发者ID:palantir,项目名称:trove-3.0.3,代码行数:47,代码来源:TObjectPrimitiveHashMapTest.java

示例14: testIterator

import gnu.trove.iterator.TObjectIntIterator; //导入方法依赖的package包/类
public void testIterator() {
    TObjectIntMap<String> map = withExpectedSize(10);

    TObjectIntIterator<String> iterator = map.iterator();
    assertFalse( iterator.hasNext() );

    map.put( "one", 1 );
    map.put( "two", 2 );

    iterator = map.iterator();
    assertTrue( iterator.hasNext() );
    iterator.advance();

    String first_key = iterator.key();
    assertNotNull( "key was null", first_key );
    assertTrue( "invalid key: " + first_key,
            first_key.equals( "one" ) || first_key.equals( "two" ) );
    if ( first_key.equals( "one" ) ) {
        assertEquals( 1, iterator.value() );
    } else {
        assertEquals( 2, iterator.value() );
    }

    assertTrue( iterator.hasNext() );
    iterator.advance();
    String second_key = iterator.key();
    assertNotNull( "key was null", second_key );
    assertTrue( "invalid key: " + second_key,
            second_key.equals( "one" ) || second_key.equals( "two" ) );
    if ( second_key.equals( "one" ) ) {
        assertEquals( 1, iterator.value() );
    } else {
        assertEquals( 2, iterator.value() );
    }
    assertFalse( first_key + ", " + second_key, first_key.equals( second_key ) );

    assertFalse( iterator.hasNext() );

    // New Iterator
    iterator = map.iterator();
    iterator.advance();
    first_key = iterator.key();
    iterator.setValue( 1138 );
    assertEquals( 1138, iterator.value() );
    assertEquals( 1138, map.get( first_key ) );
}
 
开发者ID:leventov,项目名称:trove-over-koloboke-compile,代码行数:47,代码来源:TObjectPrimitiveHashMapTest.java


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