• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java BitSet类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: vertexSample

import com.carrotsearch.hppc.BitSet; //导入依赖的package包/类
/**
 * This method computes the pagerank for each vertex and keeps a sample of 
 * the vertices for each colour
 * @param graph
 * @return sample graph
 */
public ObjectObjectOpenHashMap<Integer, BitSet> vertexSample(ColouredGraph graph){

ColouredVerticesMetric colouredVertices = new ColouredVerticesMetric();
ObjectObjectOpenHashMap<BitSet,IntSet> vertices = colouredVertices.getVerticesForEachColour(graph);
PageRank pageRank = graph.getGraph().getPageRanking(random);
ObjectObjectOpenHashMap<Integer, BitSet> sampleVertices = new ObjectObjectOpenHashMap<Integer,BitSet>();

    for (ObjectCursor<BitSet> colour : vertices.keys()) {
        if(!colour.value.isEmpty()){  //change this based on the colour we have for rdf:type ...
            Map<Integer, Double> verticesPageRank = new HashMap<Integer, Double>();

            for (int i = 0; i < vertices.get(colour.value).size(); i++) {
                verticesPageRank.put(vertices.get(colour.value).toArray()[i], pageRank.getRank(vertices.get(colour.value).toArray()[i]));
            }
            //sort vertices based on pagerank and keep only a part of them
            Map<Integer, Double> sortedVerticesPageRank = sortByValues(verticesPageRank,graph,colour.value);   
                
            for(Map.Entry entry: sortedVerticesPageRank.entrySet()){ 
                sampleVertices.put((Integer) entry.getKey(), colour.value);
            }
        }
    }
    return sampleVertices;
}
 
开发者ID:dice-group,项目名称:Lemming,代码行数:31,代码来源:Sampling.java


示例2: sortByValues

import com.carrotsearch.hppc.BitSet; //导入依赖的package包/类
public <K extends Comparable,V extends Comparable> Map<K,V> sortByValues(Map<K,V> map,ColouredGraph graph, BitSet colour){
    List<Map.Entry<K,V>> entries = new LinkedList<Map.Entry<K,V>>(map.entrySet());
    Collections.sort(entries, new Comparator<Map.Entry<K,V>>() {
        @Override
        public int compare(Entry<K, V> o1, Entry<K, V> o2) {
            return o2.getValue().compareTo(o1.getValue()); //descending order
        }
    });

    //keeps only the topK vertices ! 
    int size = numOfSampleVertices(graph, colour);
    if(size > entries.size()) size = entries.size();
    
    Map<K,V> sortedMap = new LinkedHashMap<K,V>();  
    for(Map.Entry<K,V> entry: entries.subList(0, size)){
        sortedMap.put(entry.getKey(), entry.getValue());
    }
    return sortedMap;
}
 
开发者ID:dice-group,项目名称:Lemming,代码行数:20,代码来源:Sampling.java


示例3: apply

import com.carrotsearch.hppc.BitSet; //导入依赖的package包/类
@Override
public ObjectDistribution<BitSet> apply(ColouredGraph graph) {
    ObjectArrayList<BitSet> colours = graph.getVertexColours();

    ObjectIntOpenHashMap<BitSet> counts = new ObjectIntOpenHashMap<BitSet>();
    for (int i = 0; i < colours.elementsCount; ++i) {
        counts.putOrAdd((BitSet) ((Object[]) colours.buffer)[i], 1, 1);
    }

    BitSet sampleSpace[] = new BitSet[counts.assigned];
    double distribution[] = new double[counts.assigned];
    int pos = 0;
    for (int i = 0; i < counts.allocated.length; ++i) {
        if (counts.allocated[i]) {
            sampleSpace[pos] = (BitSet) ((Object[]) counts.keys)[i];
            distribution[pos] = counts.values[i];
            ++pos;
        }
    }
    return new ObjectDistribution<BitSet>(sampleSpace, distribution);
}
 
开发者ID:dice-group,项目名称:Lemming,代码行数:22,代码来源:VertexColourDistributionMetric.java


示例4: apply

import com.carrotsearch.hppc.BitSet; //导入依赖的package包/类
@Override
public ObjectDistribution<BitSet> apply(ColouredGraph graph) {
    ObjectArrayList<BitSet> colours = graph.getEdgeColours();

    ObjectIntOpenHashMap<BitSet> counts = new ObjectIntOpenHashMap<BitSet>();
    for (int i = 0; i < colours.elementsCount; ++i) {
        counts.putOrAdd((BitSet) ((Object[]) colours.buffer)[i], 1, 1);
    }

    BitSet sampleSpace[] = new BitSet[counts.assigned];
    double distribution[] = new double[counts.assigned];
    int pos = 0;
    for (int i = 0; i < counts.allocated.length; ++i) {
        if (counts.allocated[i]) {
            sampleSpace[pos] = (BitSet) ((Object[]) counts.keys)[i];
            distribution[pos] = counts.values[i];
            ++pos;
        }
    }
    return new ObjectDistribution<BitSet>(sampleSpace, distribution);
}
 
开发者ID:dice-group,项目名称:Lemming,代码行数:22,代码来源:EdgeColourDistributionMetric.java


示例5: sampleEdgeEndColour

import com.carrotsearch.hppc.BitSet; //导入依赖的package包/类
private BitSet sampleEdgeEndColour(Random random, ObjectIntOpenHashMap<BitSet> headDistribution,
        int numberOfDistSamples) {
    int colourId = random.nextInt(numberOfDistSamples);
    // find the first colour
    while (!headDistribution.allocated[colourId]) {
        ++colourId;
    }
    int temp = colourId;
    while (temp > 0) {
        temp -= headDistribution.values[colourId];
        while ((colourId < headDistribution.allocated.length) && (!headDistribution.allocated[colourId])) {
            ++colourId;
        }
        if (colourId >= headDistribution.allocated.length) {
            String msg = "Got a sample (" + colourId + ") that seems to be larger than the probability sum ("
                    + numberOfDistSamples + "). Aborting.";
            LOGGER.error(msg);
            throw new IllegalStateException(msg);
        }
    }
    return (BitSet) ((Object[]) headDistribution.keys)[colourId];
}
 
开发者ID:dice-group,项目名称:Lemming,代码行数:23,代码来源:GenModelBasedAlgo.java


示例6: test

import com.carrotsearch.hppc.BitSet; //导入依赖的package包/类
@Test
public void test() {
    Model model = ModelFactory.createDefaultModel();
    InputStream is = this.getClass().getClassLoader().getResourceAsStream(GRAPH_FILE);
    model.read(is, null, "N3");
    IOUtils.closeQuietly(is);

    GraphCreator creator = new GraphCreator();
    ColouredGraph graph = creator.processModel(model);

    EdgeColourDistributionMetric metric = new EdgeColourDistributionMetric();
    ObjectDistribution<BitSet> distribution = metric.apply(graph);

    ObjectDoubleOpenHashMap<BitSet> expectedCounts = new ObjectDoubleOpenHashMap<BitSet>();
    ColourPalette palette = graph.getEdgePalette();
    for (int i = 0; i < EXPECTED_PROPERTY_URIS.length; ++i) {
        expectedCounts.put(palette.getColour(EXPECTED_PROPERTY_URIS[i]), EXPECTED_PROPERTY_COUNTS[i]);
    }

    for (int i = 0; i < distribution.sampleSpace.length; ++i) {
        Assert.assertTrue(expectedCounts.containsKey(distribution.sampleSpace[i]));
        Assert.assertEquals(expectedCounts.get(distribution.sampleSpace[i]), distribution.values[i]);
    }
    Assert.assertEquals(expectedCounts.size(), distribution.sampleSpace.length);
}
 
开发者ID:dice-group,项目名称:Lemming,代码行数:26,代码来源:EdgeColourDistributionMetricTest.java


示例7: findMatchings

import com.carrotsearch.hppc.BitSet; //导入依赖的package包/类
@Override
public BitSet findMatchings(T expectedElement, List<T> annotatorResult, BitSet alreadyUsedResults) {
    BitSet matchings = new BitSet(annotatorResult.size());
    if (expectedElement == null) {
        for (int i = 0; i < annotatorResult.size(); ++i) {
            if (annotatorResult.get(i) == null) {
                matchings.set(i);
            }
        }
    } else {
        for (int i = 0; i < annotatorResult.size(); ++i) {
            if (expectedElement.equals(annotatorResult.get(i))) {
                matchings.set(i);
            }
        }
    }
    return matchings;
}
 
开发者ID:dice-group,项目名称:gerbil,代码行数:19,代码来源:EqualsBasedMatchingsSearcher.java


示例8: findMatchings

import com.carrotsearch.hppc.BitSet; //导入依赖的package包/类
@Override
public BitSet findMatchings(T expectedElement, List<T> annotatorResult, BitSet alreadyUsedResults) {
    int eStart = expectedElement.getStartPosition();
    int eEnd = eStart + expectedElement.getLength();
    int rStart, rEnd;
    T result;
    BitSet matching = new BitSet(alreadyUsedResults.size());
    for (int i = 0; i < annotatorResult.size(); ++i) {
        if (!alreadyUsedResults.get(i)) {
            result = annotatorResult.get(i);
            rStart = result.getStartPosition();
            rEnd = rStart + result.getLength();
            if (rStart >= eStart) {
                if (rStart < eEnd) {
                    matching.set(i);
                    // yes, we have found a matching position, but note,
                    // that we have to find all matching positions!
                }
            } else if (eStart < rEnd) {
                matching.set(i);
            }
        }
    }
    return matching;
}
 
开发者ID:dice-group,项目名称:gerbil,代码行数:26,代码来源:WeakSpanMatchingsSearcher.java


示例9: classifyAnnotatorList

import com.carrotsearch.hppc.BitSet; //导入依赖的package包/类
private void classifyAnnotatorList(List<T> annotatorResults, List<T> goldStandard) {
    BitSet matchingElements;
    BitSet alreadyUsedResults = new BitSet(goldStandard.size());
    int matchingElementId;
    boolean elementInKb;
    for (T marking : annotatorResults) {
        matchingElements = searcher.findMatchings(marking, goldStandard, alreadyUsedResults);
        // search for matching elements that have the InKB class
        matchingElementId = matchingElements.nextSetBit(0);
        if (matchingElementId >= 0) {
            elementInKb = false;
            while ((matchingElementId >= 0) && (!elementInKb)) {
                elementInKb = goldStandard.get(matchingElementId).hasClass(MarkingClasses.IN_KB);
                matchingElementId = matchingElements.nextSetBit(matchingElementId + 1);
            }
            if (elementInKb) {
                marking.setClass(MarkingClasses.GS_IN_KB);
            }
        }
    }
}
 
开发者ID:dice-group,项目名称:gerbil,代码行数:22,代码来源:GSInKBClassifyingEvaluatorDecorator.java


示例10: filterMarkings

import com.carrotsearch.hppc.BitSet; //导入依赖的package包/类
protected List<T> filterMarkings(List<T> markings, List<T> goldStandard) {
    BitSet matchingElements;
    BitSet alreadyUsedResults = new BitSet(goldStandard.size());
    List<T> filteredMarkings = new ArrayList<T>(markings.size());
    for (T marking : markings) {
        matchingElements = searcher.findMatchings(marking, goldStandard, alreadyUsedResults);
        if (!matchingElements.isEmpty()) {
            filteredMarkings.add(marking);
            // if a multiple matching is not allowed, we have to mark the
            // Marking of the gold standard
            if (!multiMatchingAllowed) {
                alreadyUsedResults.set(matchingElements.nextSetBit(0));
            }
        }
    }
    return filteredMarkings;
}
 
开发者ID:dice-group,项目名称:gerbil,代码行数:18,代码来源:SearcherBasedNotMatchingMarkingFilter.java


示例11: getSubsetDefinition

import com.carrotsearch.hppc.BitSet; //导入依赖的package包/类
public SegmentationDefinition getSubsetDefinition(int wordsetSize) {
/*
 * Code the combinations of elements not with ids but with bits. 01 is
 * only the first element, 10 is the second and 11 is the combination of
 * both.
 */
int conditions[][] = new int[wordsetSize][1];
int segments[] = new int[wordsetSize];
int bit = 1, pos = 0;
int mask = (1 << wordsetSize) - 1;
BitSet neededCounts = new BitSet(1 << wordsetSize);
while (bit < mask) {
    segments[pos] = bit;
    neededCounts.set(bit);
    conditions[pos] = new int[] { mask - bit };
    bit = bit << 1;
    ++pos;
}
neededCounts.set(mask);
return new SegmentationDefinition(segments, conditions, neededCounts);
   }
 
开发者ID:dice-group,项目名称:Palmetto,代码行数:22,代码来源:OneAll.java


示例12: getSubsetDefinitionWithoutRestrictions

import com.carrotsearch.hppc.BitSet; //导入依赖的package包/类
@Override
protected SegmentationDefinition getSubsetDefinitionWithoutRestrictions(int wordsetSize) {
    /*
     * Code the combinations of elements not with ids but with bits. 01 is
     * only the first element, 10 is the second and 11 is the combination of
     * both.
     */
    int mask = (1 << wordsetSize) - 1;
    int posInResult = 0;
    int segments[] = new int[mask - 1];
    int conditions[][] = new int[segments.length][];
    // Go through all possible probabilities
    for (int i = 1; i < mask; ++i) {
        segments[posInResult] = i;
        // invert the probability elements to get the possible conditions
        conditions[posInResult] = createConditions(mask - i);
        ++posInResult;
    }
    BitSet neededCounts = new BitSet(1 << wordsetSize);
    neededCounts.set(1, 1 << wordsetSize);
    return new SegmentationDefinition(segments, conditions, neededCounts);
}
 
开发者ID:dice-group,项目名称:Palmetto,代码行数:23,代码来源:AnyAny.java


示例13: getSubsetDefinitionWithRestrictions

import com.carrotsearch.hppc.BitSet; //导入依赖的package包/类
@Override
protected SegmentationDefinition getSubsetDefinitionWithRestrictions(int wordsetSize, int maxSingleSubSetSize,
        int maxSubSetUnionSize) {
    int maxSegmentSize = maxSubSetUnionSize > maxSingleSubSetSize ? maxSingleSubSetSize
            : (maxSubSetUnionSize - 1);
    int mask = (1 << wordsetSize) - 1;
    int posInResult = 0, segmentBitCount;
    int segments[] = new int[getNumberOfCombinations(wordsetSize, maxSegmentSize)];
    int conditions[][] = new int[segments.length][];
    // Go through all possible probabilities
    for (int i = 1; i < mask; ++i) {
        segmentBitCount = Integer.bitCount(i);
        if (segmentBitCount <= maxSegmentSize) {
            segments[posInResult] = i;
            // invert the probability elements to get the possible conditions
            conditions[posInResult] = createRestrictedConditions(mask - i,
                    Math.min(maxSingleSubSetSize, maxSubSetUnionSize - segmentBitCount));
            ++posInResult;
        }
    }
    BitSet neededCounts = new BitSet(1 << wordsetSize);
    neededCounts.set(1, 1 << wordsetSize);
    return new SegmentationDefinition(segments, conditions, neededCounts);
}
 
开发者ID:dice-group,项目名称:Palmetto,代码行数:25,代码来源:AnyAny.java


示例14: getSubsetDefinition

import com.carrotsearch.hppc.BitSet; //导入依赖的package包/类
public SegmentationDefinition getSubsetDefinition(int wordsetSize) {
    /*
     * Code the combinations of elements not with ids but with bits. 01 is
     * only the first element, 10 is the second and 11 is the combination of
     * both.
     */
    int conditions[][] = new int[wordsetSize][];
    int segments[] = new int[wordsetSize];
    int bit = 1, pos = 0;
    int mask = (1 << wordsetSize) - 1;
    BitSet neededCounts = new BitSet(1 << wordsetSize);
    while (bit < mask) {
        segments[pos] = bit;
        neededCounts.set(bit);
        conditions[pos] = new int[wordsetSize - (pos + 1)];
        for (int i = pos + 1; i < wordsetSize; ++i) {
            neededCounts.set(bit + (1 << i));
            conditions[pos][i - (pos + 1)] = 1 << i;
        }
        bit = bit << 1;
        ++pos;
    }
    return new SegmentationDefinition(segments, conditions, neededCounts);
}
 
开发者ID:dice-group,项目名称:Palmetto,代码行数:25,代码来源:OneSucceeding.java


示例15: getSubsetDefinition

import com.carrotsearch.hppc.BitSet; //导入依赖的package包/类
public SegmentationDefinition getSubsetDefinition(int wordsetSize) {
    /*
     * Code the combinations of elements not with ids but with bits. 01 is
     * only the first element, 10 is the second and 11 is the combination of
     * both.
     */
    int conditions[][] = new int[wordsetSize][1];
    int segments[] = new int[wordsetSize];
    int bit = 1, pos = 0;
    int mask = (1 << wordsetSize) - 1;
    BitSet neededCounts = new BitSet(1 << wordsetSize);
    while (bit < mask) {
        segments[pos] = mask - bit;
        neededCounts.set(segments[pos]);
        conditions[pos] = new int[] { bit };
        bit = bit << 1;
        ++pos;
    }
    neededCounts.set(mask);
    return new SegmentationDefinition(segments, conditions, neededCounts);
}
 
开发者ID:dice-group,项目名称:Palmetto,代码行数:22,代码来源:AllOne.java


示例16: getSubsetDefinition

import com.carrotsearch.hppc.BitSet; //导入依赖的package包/类
public SegmentationDefinition getSubsetDefinition(int wordsetSize) {
/*
 * Code the combinations of elements not with ids but with bits. 01 is
 * only the first element, 10 is the second and 11 is the combination of
 * both.
 */
int conditions[][] = new int[wordsetSize][1];
int segments[] = new int[wordsetSize];
int bit = 1, pos = 0;
int mask = (1 << wordsetSize) - 1;
BitSet neededCounts = new BitSet(1 << wordsetSize);
while (bit < mask) {
    segments[pos] = bit;
    neededCounts.set(bit);
    conditions[pos] = new int[] { mask };
    bit = bit << 1;
    ++pos;
}
neededCounts.set(mask);
return new SegmentationDefinition(segments, conditions, neededCounts);
   }
 
开发者ID:dice-group,项目名称:Palmetto,代码行数:22,代码来源:OneSet.java


示例17: getSubsetDefinitionWithoutRestrictions

import com.carrotsearch.hppc.BitSet; //导入依赖的package包/类
@Override
protected SegmentationDefinition getSubsetDefinitionWithoutRestrictions(int wordsetSize) {
    /*
     * Code the combinations of elements not with ids but with bits. 01 is
     * only the first element, 10 is the second and 11 is the combination of
     * both.
     */
    int mask = (1 << wordsetSize) - 1;
    int posInResult = 0;
    int segments[] = new int[wordsetSize];
    int conditions[][] = new int[segments.length][];
    int bit = 1;
    // Go through all possible probabilities
    while (bit < mask) {
        segments[posInResult] = bit;
        // invert the probability elements to get the possible conditions
        conditions[posInResult] = createConditions(mask - bit);
        bit = bit << 1;
        ++posInResult;
    }

    BitSet neededCounts = new BitSet(1 << wordsetSize);
    neededCounts.set(1, 1 << wordsetSize);
    return new SegmentationDefinition(segments, conditions, neededCounts);
}
 
开发者ID:dice-group,项目名称:Palmetto,代码行数:26,代码来源:OneAny.java


示例18: getSubsetDefinition

import com.carrotsearch.hppc.BitSet; //导入依赖的package包/类
public SegmentationDefinition getSubsetDefinition(int wordsetSize) {
    /*
     * Code the combinations of elements not with ids but with bits. 01 is
     * only the first element, 10 is the second and 11 is the combination of
     * both.
     */
    int conditions[][] = new int[wordsetSize][];
    int segments[] = new int[wordsetSize];
    int bit = 1, pos = 0;
    int mask = (1 << wordsetSize) - 1;
    BitSet neededCounts = new BitSet(1 << wordsetSize);
    while (bit < mask) {
        segments[pos] = bit;
        neededCounts.set(bit);
        conditions[pos] = new int[pos];
        for (int i = 0; i < pos; ++i) {
            neededCounts.set(bit + (1 << i));
            conditions[pos][i] = 1 << i;
        }
        bit = bit << 1;
        ++pos;
    }
    return new SegmentationDefinition(segments, conditions, neededCounts);
}
 
开发者ID:dice-group,项目名称:Palmetto,代码行数:25,代码来源:OnePreceding.java


示例19: createBitSets

import com.carrotsearch.hppc.BitSet; //导入依赖的package包/类
private BitSet[] createBitSets(IntOpenHashSet hashSets[],
        IntOpenHashSet mergedHashSet) {
    BitSet bitSets[] = new BitSet[hashSets.length];
    for (int i = 0; i < bitSets.length; ++i) {
        bitSets[i] = new BitSet(mergedHashSet.size());
    }

    int pos = 0;
    for (int i = 0; i < mergedHashSet.keys.length; i++) {
        if (mergedHashSet.allocated[i]) {
            for (int j = 0; j < bitSets.length; ++j) {
                if (hashSets[j].contains(mergedHashSet.keys[i])) {
                    bitSets[j].set(pos);
                }
            }
            ++pos;
        }
    }

    return bitSets;
}
 
开发者ID:dice-group,项目名称:Palmetto,代码行数:22,代码来源:BitSetBasedBooleanDocumentFrequencyDeterminer.java


示例20: createCounts

import com.carrotsearch.hppc.BitSet; //导入依赖的package包/类
private int[] createCounts(BitSet bitsets[], BitSet neededCounts) {
    // TODO use the neededCounts bit set to avoid the creation of bit sets which are not needed
    // TODO Check the minimum frequency at this stage --> all BitSets with a lower cardinality can be set to null
    // and all following don't have to be created.
    BitSet[] combinations = new BitSet[(1 << bitsets.length)];
    int pos, pos2;
    for (int i = 0; i < bitsets.length; ++i) {
        pos = (1 << i);
        combinations[pos] = bitsets[i];
        pos2 = pos + 1;
        for (int j = 1; j < pos; ++j) {
            combinations[pos2] = ((BitSet) bitsets[i].clone());
            combinations[pos2].intersect(combinations[j]);
            ++pos2;
        }
    }
    int cardinalities[] = new int[combinations.length];
    for (int i = 1; i < combinations.length; ++i) {
        cardinalities[i] = (int) combinations[i].cardinality();
    }
    return cardinalities;
}
 
开发者ID:dice-group,项目名称:Palmetto,代码行数:23,代码来源:BitSetBasedBooleanDocumentFrequencyDeterminer.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java BranchState类代码示例发布时间:2022-05-22
下一篇:
Java WSDLParseException类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap