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


Java IntAVLTreeSet类代码示例

本文整理汇总了Java中it.unimi.dsi.fastutil.ints.IntAVLTreeSet的典型用法代码示例。如果您正苦于以下问题:Java IntAVLTreeSet类的具体用法?Java IntAVLTreeSet怎么用?Java IntAVLTreeSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


IntAVLTreeSet类属于it.unimi.dsi.fastutil.ints包,在下文中一共展示了IntAVLTreeSet类的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getFirstReachableMessageId

import it.unimi.dsi.fastutil.ints.IntAVLTreeSet; //导入依赖的package包/类
/**
 * Will crawl the weak hash maps and make sure we always have the latest
 * information on the availability of messages.
 *
 * This method is only intended to be used from within
 * {@link LogWatchStorageSweeper}.
 *
 * @return ID of the very first message that is reachable by any follower in
 *         this logWatch. -1 when there are no reachable messages.
 */
protected synchronized int getFirstReachableMessageId() {
    final boolean followersRunning = !this.runningFollowerStartMarks.isEmpty();
    if (!followersRunning && this.terminatedFollowerRanges.isEmpty()) {
        // no followers present; no reachable messages
        return -1;
    }
    final IntSortedSet set = new IntAVLTreeSet(this.runningFollowerStartMarks.values());
    if (!set.isEmpty()) {
        final int first = this.messages.getFirstPosition();
        if (set.firstInt() <= first) {
            /*
             * cannot go below first position; any other calculation
             * unnecessary
             */
            return first;
        }
    }
    set.addAll(this.terminatedFollowerRanges.values().stream().map(pair -> pair[0]).collect(Collectors.toList()));
    return set.firstInt();
}
 
开发者ID:triceo,项目名称:splitlog,代码行数:31,代码来源:LogWatchStorageManager.java

示例2: testMerge

import it.unimi.dsi.fastutil.ints.IntAVLTreeSet; //导入依赖的package包/类
public void testMerge( int n0, int n1 ) {
	Random r = new Random();
	int x0[] = new int[ n0 ];
	int x1[] = new int[ n1 ];
	int i, p = 0;

	// Generate
	for ( i = 0; i < n0; i++ ) p = x0[ i ] = p + r.nextInt( 10 );
	p = 0;
	for ( i = 0; i < n1; i++ ) p = x1[ i ] = p + (int)( Math.random() * 10 );
	
	IntAVLTreeSet s0 = new IntAVLTreeSet( x0 );
	IntAVLTreeSet s1 = new IntAVLTreeSet( x1 );
	IntAVLTreeSet res = new IntAVLTreeSet( s0 );
	res.addAll( s1 );

	MergedIntIterator m = new MergedIntIterator( LazyIntIterators.lazy( s0.iterator() ), LazyIntIterators.lazy( s1.iterator() ) );
	IntIterator it = res.iterator();

	int x;
	while ( ( x = m.nextInt() ) != -1 ) assertEquals( it.nextInt(), x );
	assertEquals( Boolean.valueOf( it.hasNext() ), Boolean.valueOf( m.nextInt() != -1 ) );
}
 
开发者ID:lhelwerd,项目名称:WebGraph,代码行数:24,代码来源:MergedIntIteratorTest.java

示例3: buildInputDataPartitionSchema

import it.unimi.dsi.fastutil.ints.IntAVLTreeSet; //导入依赖的package包/类
private String buildInputDataPartitionSchema(List<JCL_result> r, int numOfJCLThreads){
	
	IntSet sorted = new IntAVLTreeSet();
	long totalF=0;
	Int2LongMap map = new Int2LongOpenHashMap();
	
	for(JCL_result oneR:r){
		
		try{
			@SuppressWarnings("unchecked")
			List<String> l = (List<String>) oneR.getCorrectResult();
			
			for(String s : l){
				String[] args = s.split(":");
				int key = Integer.parseInt(args[0]); long freq = Long.parseLong(args[1]);
				sorted.add(key);
		
				if(map.containsKey(key)){
					freq+=map.get(key);	
					totalF+=map.get(key);
				} else totalF+=freq;
				
				map.put(key, freq);
			}
			
		}catch(Exception e){}
	}
	
	long load=0; int b; String result = "";
	for(int ac:sorted){
		load += map.get(ac);
		if(load > (totalF/(numOfJCLThreads))){					
			b=ac;
			result += b + ":";				
			load=0;
		}	
	}		
	
	return result;
}
 
开发者ID:AndreJCL,项目名称:JCL,代码行数:41,代码来源:Main.java

示例4: phase1

import it.unimi.dsi.fastutil.ints.IntAVLTreeSet; //导入依赖的package包/类
public List<String> phase1(int id, String name, int numJCLThreads) {
    Int2LongMap values = new Int2LongOpenHashMap(1000000);
    long totalF = 0;
    System.err.println("file: " + name);
    try {
        File f = new File("../" + name + "/" + name + ".bin");
        InputStream in = new BufferedInputStream(new FileInputStream(f));
        FastBufferedInputStream fb = new FastBufferedInputStream(in);
        byte[] i = new byte[4];
        while (fb.read(i) == 4) {
            int k = java.nio.ByteBuffer.wrap(i).getInt();
            if (!values.containsKey(k))
                values.put(k, 1);
            else {
                long aux = values.get(k);
                aux++;
                values.put(k, aux);
            }
            totalF++;
        }
        fb.close();
        in.close();
        
        // primeira modificacao
        //for (long v : values.values())
        //    totalF += v;
        
        IntSet sorted = new IntAVLTreeSet(values.keySet());
        long acumula = 0;
        int b = 0;
        List<String> result = new LinkedList<>();
        long blinha = 0; 
        int last = 0;
        for (int ac : sorted) {
            blinha = values.get(ac);
            acumula += blinha;
            if (acumula > (totalF / (numJCLThreads))) {
                b = ac;
                result.add(b + ":" + acumula);
                acumula = 0;
            }
            last = ac;
        }
        
        // segunda modificacao
        if(acumula != 0) result.add(last + ":" + acumula);
        
        JCL_facade jcl = JCL_FacadeImpl.getInstanceLambari();
        jcl.instantiateGlobalVar(id, values);
        sorted.clear();
        sorted = null;
        return result;

    } catch (Exception e) {
        e.printStackTrace();
        return null;
    }
}
 
开发者ID:AndreJCL,项目名称:JCL,代码行数:59,代码来源:Sorting.java


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