本文整理汇总了Java中gnu.trove.iterator.TIntIntIterator.value方法的典型用法代码示例。如果您正苦于以下问题:Java TIntIntIterator.value方法的具体用法?Java TIntIntIterator.value怎么用?Java TIntIntIterator.value使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类gnu.trove.iterator.TIntIntIterator
的用法示例。
在下文中一共展示了TIntIntIterator.value方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: cleanup
import gnu.trove.iterator.TIntIntIterator; //导入方法依赖的package包/类
@Override
protected void cleanup(Context context) throws java.io.IOException, InterruptedException {
final Configuration conf = context.getConfiguration();
final int minSupport = conf.getInt(TopPIoverHadoop.KEY_MINSUP, 10);
final IntWritable keyW = new IntWritable();
final IntWritable valueW = new IntWritable();
final TreeSet<ItemAndBigSupport> heap = new TreeSet<ItemAndBigSupport>();
TIntIntIterator it = this.itemSupports.iterator();
while(it.hasNext()) {
it.advance();
final int support = it.value();
if (support >= minSupport) {
heap.add(new ItemAndBigSupport(it.key(), support));
}
}
this.itemSupports = null;
int rebased = 0;
for (ItemAndBigSupport entry : heap) {
keyW.set(entry.item);
valueW.set(rebased++);
context.write(keyW, valueW);
}
rebased -= 1;
context.getCounter(COUNTERS_GROUP, COUNTER_REBASING_MAX_ID).setValue(rebased);
}
示例2: duplicate
import gnu.trove.iterator.TIntIntIterator; //导入方法依赖的package包/类
public void duplicate(ArrayList<String> docs) throws Exception {
this.docs = docs;
dsMap = new TreeSet<DocSim>();
feature();
similarity();
System.out.println("去重复");
boolean[] dup = new boolean[docs.size()];
for(int id1=0;id1<docs.size();id1++){
if(dup[id1]||similarityMap[id1]==null)
continue;
ArrayList<Integer> ids = new ArrayList<Integer>();
ids.add(id1);
TIntIntIterator it = similarityMap[id1].iterator();
for ( int i = similarityMap[id1].size(); i-- > 0; ) {
it.advance();
int id2 = it.key();
double sim = ((double)(it.value()* 2)) / (featureLen[id1] + featureLen[id2]);
if(sim > thres ){
dup[id2]= true;
ids.add(id2);
}
}
DocSim docSim = new DocSim(ids);
dsMap.add(docSim);
}
}
示例3: countFrequency
import gnu.trove.iterator.TIntIntIterator; //导入方法依赖的package包/类
/**
*
* @param freqmap
* @return
*/
public static TreeMap<Integer, Integer> countFrequency(TIntIntHashMap freqmap) {
TreeMap<Integer, Integer> map = new TreeMap<Integer,Integer>();
TIntIntIterator it = freqmap.iterator();
while(it.hasNext()){
it.advance();
int freq = it.value();
if(map.containsKey(freq)){
map.put(freq, map.get(freq)+1);
}else
map.put(freq, 1);
}
return map;
}
示例4: compressSortRenaming
import gnu.trove.iterator.TIntIntIterator; //导入方法依赖的package包/类
/**
* Will compress an older renaming, by removing infrequent items. Contained
* arrays (except closure) will refer new item IDs
*
* @param olderReverseRenaming
* reverseRenaming from the dataset that fed this Counter
* @param items
* below this parameter will be renamed by decreasing frequency
* @return the translation from the old renaming to the compressed one
* (gives -1 for removed items)
*/
public int[] compressSortRenaming(int[] olderReverseRenaming) {
if (olderReverseRenaming == null) {
olderReverseRenaming = this.reverseRenaming;
}
this.rebasedDistinctTransactionsCounts = new int[this.nbFrequents];
this.rebasedSupportCounts = new int[this.nbFrequents];
this.reverseRenaming = new int[this.nbFrequents];
// first, compact
// we will always have newItemID <= item
int newItemIDBelowCandidate = 0;
int newItemIDAboveCandidate = this.nbFrequents - 1;
TIntIntIterator supportIterator = this.supportCounts.iterator();
// after this loop we have
// reverseRenaming: NewBase (index) -> PreviousDatasetBase (value)
// supportCounts: NewBase (index) -> Support (value)
// distinctTransactionCount: NewBase (index) -> Count (value)
while (supportIterator.hasNext()) {
supportIterator.advance();
if (supportIterator.key() < this.maxCandidate) {
this.reverseRenaming[newItemIDBelowCandidate] = supportIterator.key();
this.rebasedSupportCounts[newItemIDBelowCandidate] = supportIterator.value();
this.rebasedDistinctTransactionsCounts[newItemIDBelowCandidate] = this.distinctTransactionsCounts
.get(supportIterator.key());
newItemIDBelowCandidate++;
} else {
this.reverseRenaming[newItemIDAboveCandidate] = supportIterator.key();
this.rebasedSupportCounts[newItemIDAboveCandidate] = supportIterator.value();
this.rebasedDistinctTransactionsCounts[newItemIDAboveCandidate] = this.distinctTransactionsCounts
.get(supportIterator.key());
newItemIDAboveCandidate--;
}
}
this.supportCounts = null;
this.distinctTransactionsCounts = null;
this.maxCandidate = newItemIDBelowCandidate;
this.maxFrequent = this.nbFrequents - 1;
// now, sort up to the pivot
this.quickSortOnSup(0, this.maxCandidate);
int[] renaming = new int[Math.max(olderReverseRenaming.length, this.rebasingSize)];
Arrays.fill(renaming, -1);
// after this loop we have
// reverseRenaming: NewBase (index) -> OriginalBase (value)
// renaming: PreviousDatasetBase (index) -> NewBase (value)
for (int i = 0; i <= this.maxFrequent; i++) {
renaming[this.reverseRenaming[i]] = i;
this.reverseRenaming[i] = olderReverseRenaming[this.reverseRenaming[i]];
}
this.compactedArrays = true;
return renaming;
}
示例5: start
import gnu.trove.iterator.TIntIntIterator; //导入方法依赖的package包/类
/**
* start path extraction considering all the pairs main_item-items
*/
private void start(){
TIntIntHashMap paths = null;
String item_pair_paths = "";
for(int j = 0; j < items.size(); j++){
ItemTree b = items.get(j);
int b_id = b.getItemId();
paths = computePaths(main_item, b);
if(paths.size() > 0){
item_pair_paths = main_item_id + "-" + b_id + "\t";
TIntIntIterator it = paths.iterator();
while(it.hasNext()){
it.advance();
item_pair_paths += it.key() + "=" + it.value() + ",";
}
item_pair_paths = item_pair_paths.substring(0, item_pair_paths.length()-1);
// text file writing
if(textWriter != null)
textWriter.write(item_pair_paths);
// binary file writing
if(pathWriter != null)
pathWriter.write(item_pair_paths);
if(computeInversePaths){
item_pair_paths = b_id + "-" + main_item_id + "\t";
it = paths.iterator();
while(it.hasNext()){
it.advance();
item_pair_paths += reverse(it.key()) + "=" + it.value() + ",";
}
item_pair_paths = item_pair_paths.substring(0, item_pair_paths.length()-1);
// text file writing
if(textWriter != null)
textWriter.write(item_pair_paths);
// binary file writing
if(pathWriter != null){
pathWriter.write(item_pair_paths);
}
}
}
}
}