本文整理汇总了Java中gnu.trove.iterator.TObjectIntIterator.key方法的典型用法代码示例。如果您正苦于以下问题:Java TObjectIntIterator.key方法的具体用法?Java TObjectIntIterator.key怎么用?Java TObjectIntIterator.key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gnu.trove.iterator.TObjectIntIterator
的用法示例。
在下文中一共展示了TObjectIntIterator.key方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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;
}
}
示例2: 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();
}
示例3: 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);
}
}
示例4: writeMDNodes
import gnu.trove.iterator.TObjectIntIterator; //导入方法依赖的package包/类
public static void writeMDNodes(FormattedOutputStream os,
TypePrinting printer,
SlotTracker slotTable)
{
MDNode[] nodes = new MDNode[slotTable.getMdnMap().size()];
TObjectIntIterator<Value> itr = slotTable.getMdnMap().iterator();
while (itr.hasNext())
{
nodes[itr.value()] = (MDNode) itr.key();
}
for (int i = 0; i < nodes.length; i++)
{
os.printf("!%d = metadata ", i);
MDNode node = nodes[i];
os.printf("!{");
for (int j = 0, e = node.getNumOfNode(); j < e; j++)
{
Value val = node.getNode(j);
if (val == null) os.printf("null");
else if (val instanceof MDNode)
{
MDNode n = (MDNode)val;
os.printf("metadata !%d", slotTable.getMetadataSlot(n));
}
else
{
printer.print(val.getType(), os);
os.print(' ');
writeAsOperandInternal(os, val, printer, slotTable);
}
if (j < e-1)
os.print(", ");
}
os.println("}");
}
}
示例5: 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;
}
示例6: 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;
}
示例7: 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;
}
示例8: 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 ) );
}
示例9: 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 ) );
}