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


Java Long2IntMap类代码示例

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


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

示例1: testSeedIteration

import it.unimi.dsi.fastutil.longs.Long2IntMap; //导入依赖的package包/类
@Test
public void testSeedIteration() throws Exception {
  SalsaIterations<BipartiteGraph> salsaIterations = new SalsaIterations<BipartiteGraph>(
      salsaInternalState,
      new LeftSalsaIteration(salsaInternalState),
      new RightSalsaIteration(salsaInternalState),
      new FinalSalsaIteration(salsaInternalState)
  );
  salsaIterations.resetWithRequest(salsaRequest, random);

  salsaIterations.seedLeftSideForFirstIteration();

  Long2IntMap expectedCurrentLeftNodes = new Long2IntOpenHashMap(3);
  expectedCurrentLeftNodes.put(1, 900);
  expectedCurrentLeftNodes.put(2, 91);
  expectedCurrentLeftNodes.put(3, 10);

  assertEquals(expectedCurrentLeftNodes, salsaInternalState.getCurrentLeftNodes());
}
 
开发者ID:twitter,项目名称:GraphJet,代码行数:20,代码来源:SalsaIterationsTest.java

示例2: testNonZeroDegreeSeedIteration

import it.unimi.dsi.fastutil.longs.Long2IntMap; //导入依赖的package包/类
@Test
public void testNonZeroDegreeSeedIteration() throws Exception {
  SalsaIterations<BipartiteGraph> salsaIterations = new SalsaIterations<BipartiteGraph>(
      salsaInternalStateSmallSeed,
      new LeftSalsaIteration(salsaInternalStateSmallSeed),
      new RightSalsaIteration(salsaInternalStateSmallSeed),
      new FinalSalsaIteration(salsaInternalStateSmallSeed)
  );
  salsaIterations.resetWithRequest(salsaRequestSmallSeed, random);

  salsaIterations.seedLeftSideForFirstIteration();

  Long2IntMap expectedCurrentLeftNodes = new Long2IntOpenHashMap(1);
  expectedCurrentLeftNodes.put(1, 1000);

  assertEquals(expectedCurrentLeftNodes, salsaInternalStateSmallSeed.getCurrentLeftNodes());
}
 
开发者ID:twitter,项目名称:GraphJet,代码行数:18,代码来源:SalsaIterationsTest.java

示例3: testSingleRightIteration

import it.unimi.dsi.fastutil.longs.Long2IntMap; //导入依赖的package包/类
@Test
public void testSingleRightIteration() throws Exception {
  SalsaIterations<BipartiteGraph> salsaIterations = new SalsaIterations<BipartiteGraph>(
      salsaInternalState,
      new LeftSalsaIteration(salsaInternalState),
      new RightSalsaIteration(salsaInternalState),
      new FinalSalsaIteration(salsaInternalState)
  );
  salsaIterations.resetWithRequest(salsaRequest, random);
  SingleSalsaIteration leftSalsaIteration =
      new LeftSalsaIteration(salsaInternalState);
  leftSalsaIteration.resetWithRequest(salsaRequest, random);
  SingleSalsaIteration rightSalsaIteration =
      new RightSalsaIteration(salsaInternalState);
  rightSalsaIteration.resetWithRequest(salsaRequest, random);

  salsaIterations.seedLeftSideForFirstIteration();
  leftSalsaIteration.runSingleIteration();
  rightSalsaIteration.runSingleIteration();

  Long2IntMap expectedCurrentLeftNodes = new Long2IntOpenHashMap(3);
  expectedCurrentLeftNodes.put(1, 728);
  expectedCurrentLeftNodes.put(2, 86);
  expectedCurrentLeftNodes.put(3, 187);

  assertTrue(salsaInternalState.getCurrentRightNodes().isEmpty());
  assertEquals(expectedCurrentLeftNodes, salsaInternalState.getCurrentLeftNodes());
}
 
开发者ID:twitter,项目名称:GraphJet,代码行数:29,代码来源:SalsaIterationsTest.java

示例4: iterator

import it.unimi.dsi.fastutil.longs.Long2IntMap; //导入依赖的package包/类
@Nonnull
@Override
public Iterator<GroupKey> iterator() {
  return new Iterator<GroupKey>() {
    private final ObjectIterator<Long2IntMap.Entry> _iterator =
        _rawKeyToGroupIdMap.long2IntEntrySet().fastIterator();
    private final GroupKey _groupKey = new GroupKey();

    @Override
    public boolean hasNext() {
      return _iterator.hasNext();
    }

    @Override
    public GroupKey next() {
      Long2IntMap.Entry entry = _iterator.next();
      _groupKey._groupId = entry.getIntValue();
      _groupKey._stringKey = getGroupKey(entry.getLongKey());
      return _groupKey;
    }

    @Override
    public void remove() {
      throw new UnsupportedOperationException();
    }
  };
}
 
开发者ID:linkedin,项目名称:pinot,代码行数:28,代码来源:DictionaryBasedGroupKeyGenerator.java

示例5: getKeyForValue

import it.unimi.dsi.fastutil.longs.Long2IntMap; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private int getKeyForValue(long value) {
  Long2IntMap map = (Long2IntMap) _groupKeyMap;
  int groupId = map.get(value);
  if (groupId == INVALID_ID) {
    groupId = _numGroupKeys;
    map.put(value, _numGroupKeys++);
  }
  return groupId;
}
 
开发者ID:linkedin,项目名称:pinot,代码行数:11,代码来源:NoDictionarySingleColumnGroupKeyGenerator.java

示例6: processExplicitBasionymRels

import it.unimi.dsi.fastutil.longs.Long2IntMap; //导入依赖的package包/类
private void processExplicitBasionymRels() {
  try (Transaction tx = db.beginTx()) {
    LOG.info("Processing {} explicit basionym relations from {}", basionymRels.size(), currSrc.name);
    for (Long2IntMap.Entry entry : basionymRels.long2IntEntrySet()) {
      // is the basionym excluded from the backbone? e.g. unincluded rank
      if (!src2NubKey.containsKey(entry.getIntValue())) {
        LOG.warn("Ignore explicit basionym with source ID={} cause its ignored in the Backbone", entry.getIntValue());
        continue;
      }

      // find basionym node by sourceKey
      Node bas = db.getNode(src2NubKey.get(entry.getIntValue()));
      Node n = db.getNode(entry.getLongKey());
      // basionym has not been verified yet, make sure its of rank <= genus and its name type is no placeholder
      NubUsage basUsage = read(bas);
      if (!basUsage.rank.isSpeciesOrBelow()) {
        LOG.warn("Ignore explicit basionym {} of rank {}", basUsage.parsedName.getScientificName(), basUsage.rank);
        continue;
      }
      if (!basUsage.parsedName.getType().isBackboneType()) {
        LOG.warn("Ignore explicit basionym {} with name type {}", basUsage.parsedName.getScientificName(), basUsage.parsedName.getType());
        continue;
      }
      if (!createBasionymRelationIfNotExisting(bas, n)) {
        LOG.warn("Nub usage {} already contains a contradicting basionym relation. Ignore basionym {} from source {}", n.getProperty(NeoProperties.SCIENTIFIC_NAME, n.getId()), bas.getProperty(NeoProperties.SCIENTIFIC_NAME, bas.getId()), currSrc.name);
      }
    }
    tx.success();
  }
}
 
开发者ID:gbif,项目名称:checklistbank,代码行数:31,代码来源:NubBuilder.java

示例7: getCurrentLeftNodes

import it.unimi.dsi.fastutil.longs.Long2IntMap; //导入依赖的package包/类
public Long2IntMap getCurrentLeftNodes() {
  return currentLeftNodes;
}
 
开发者ID:twitter,项目名称:GraphJet,代码行数:4,代码来源:CommonInternalState.java

示例8: getCurrentRightNodes

import it.unimi.dsi.fastutil.longs.Long2IntMap; //导入依赖的package包/类
public Long2IntMap getCurrentRightNodes() {
  return currentRightNodes;
}
 
开发者ID:twitter,项目名称:GraphJet,代码行数:4,代码来源:CommonInternalState.java

示例9: testPowerLawDegreeEdgeIterator

import it.unimi.dsi.fastutil.longs.Long2IntMap; //导入依赖的package包/类
@Test
public void testPowerLawDegreeEdgeIterator() throws Exception {
  int maxNumNodes = 4;
  int maxDegree = 6;
  PowerLawDegreeEdgePool powerLawDegreeEdgePool =
      new PowerLawDegreeEdgePool(maxNumNodes, maxDegree, 2.0, new NullStatsReceiver());

  addEdgesToPool(powerLawDegreeEdgePool);

  PowerLawDegreeEdgeRandomIterator powerLawDegreeEdgeRandomIterator =
      new PowerLawDegreeEdgeRandomIterator(powerLawDegreeEdgePool);

  Random random = new Random(90238490238409L);
  int numSamples = 5;

  powerLawDegreeEdgeRandomIterator.resetForNode(1, numSamples, random);
  assertEquals(new IntArrayList(new int[]{13, 13, 11, 15, 14}),
      new IntArrayList(powerLawDegreeEdgeRandomIterator));
  powerLawDegreeEdgeRandomIterator.resetForNode(2, numSamples, random);
  assertEquals(new IntArrayList(new int[]{22, 22, 21, 23, 22}),
      new IntArrayList(powerLawDegreeEdgeRandomIterator));
  powerLawDegreeEdgeRandomIterator.resetForNode(3, numSamples, random);
  assertEquals(new IntArrayList(new int[]{31, 31, 31, 31, 31}),
      new IntArrayList(powerLawDegreeEdgeRandomIterator));
  powerLawDegreeEdgeRandomIterator.resetForNode(4, numSamples, random);
  assertEquals(new IntArrayList(new int[]{43, 41, 43, 41, 42}),
      new IntArrayList(powerLawDegreeEdgeRandomIterator));
  powerLawDegreeEdgeRandomIterator.resetForNode(5, numSamples, random);
  assertEquals(new IntArrayList(new int[]{51, 51, 51, 51, 51}),
      new IntArrayList(powerLawDegreeEdgeRandomIterator));

  // Test a larger sample
  powerLawDegreeEdgeRandomIterator.resetForNode(4, 900, random);
  Long2IntMap occurrenceCounts = new Long2IntOpenHashMap(3);
  for (int sample : new IntArrayList(powerLawDegreeEdgeRandomIterator)) {
    occurrenceCounts.put(sample, occurrenceCounts.get(sample) + 1);
  }
  assertEquals(301, occurrenceCounts.get(41));
  assertEquals(296, occurrenceCounts.get(42));
  assertEquals(303, occurrenceCounts.get(43));
}
 
开发者ID:twitter,项目名称:GraphJet,代码行数:42,代码来源:PowerLawDegreeEdgeRandomIteratorTest.java

示例10: buildFrequentTwoItemsets

import it.unimi.dsi.fastutil.longs.Long2IntMap; //导入依赖的package包/类
/**
 * Build the 2-itemsets.
 *
 * @param oneitems Frequent 1-itemsets
 * @param relation Data relation
 * @param dim Maximum dimensionality
 * @param needed Minimum support needed
 * @param ids Objects to process
 * @param survivors Output: objects that had at least two 1-frequent items.
 * @return Frequent 2-itemsets
 */
protected List<SparseItemset> buildFrequentTwoItemsets(List<OneItemset> oneitems, final Relation<BitVector> relation, final int dim, final int needed, DBIDs ids, ArrayModifiableDBIDs survivors) {
  int f1 = 0;
  long[] mask = BitsUtil.zero(dim);
  for(OneItemset supported : oneitems) {
    BitsUtil.setI(mask, supported.item);
    f1++;
  }
  if(LOG.isStatistics()) {
    LOG.statistics(new LongStatistic(STAT + "2-items.candidates", f1 * (long) (f1 - 1)));
  }
  // We quite aggressively size the map, assuming that almost each combination
  // is present somewhere. If this won't fit into memory, we're likely running
  // OOM somewhere later anyway!
  Long2IntOpenHashMap map = new Long2IntOpenHashMap((f1 * (f1 - 1)) >>> 1);
  final long[] scratch = BitsUtil.zero(dim);
  for(DBIDIter iditer = ids.iter(); iditer.valid(); iditer.advance()) {
    BitsUtil.setI(scratch, mask);
    relation.get(iditer).andOnto(scratch);
    int lives = 0;
    for(int i = BitsUtil.nextSetBit(scratch, 0); i >= 0; i = BitsUtil.nextSetBit(scratch, i + 1)) {
      for(int j = BitsUtil.nextSetBit(scratch, i + 1); j >= 0; j = BitsUtil.nextSetBit(scratch, j + 1)) {
        long key = (((long) i) << 32) | j;
        map.put(key, 1 + map.get(key));
        ++lives;
      }
    }
    if(lives > 2) {
      survivors.add(iditer);
    }
  }
  // Generate candidates of length 2.
  List<SparseItemset> frequent = new ArrayList<>(f1 * (int) FastMath.sqrt(f1));
  for(ObjectIterator<Long2IntMap.Entry> iter = map.long2IntEntrySet().fastIterator(); iter.hasNext();) {
    Long2IntMap.Entry entry = iter.next();
    if(entry.getIntValue() >= needed) {
      int ii = (int) (entry.getLongKey() >>> 32);
      int ij = (int) (entry.getLongKey() & -1L);
      frequent.add(new SparseItemset(new int[] { ii, ij }, entry.getIntValue()));
    }
  }
  // The hashmap may produce them out of order.
  Collections.sort(frequent);
  if(LOG.isStatistics()) {
    LOG.statistics(new LongStatistic(STAT + "2-items.frequent", frequent.size()));
  }
  return frequent;
}
 
开发者ID:elki-project,项目名称:elki,代码行数:59,代码来源:APRIORI.java

示例11: Coder

import it.unimi.dsi.fastutil.longs.Long2IntMap; //导入依赖的package包/类
public Coder(final long[] codeWord, final int[] codewordLength, final long[] symbol, final Long2IntMap symbol2Rank) {
	this.codeword = codeWord;
	this.codewordLength = codewordLength;
	this.symbol = symbol;
	this.symbol2Rank = symbol2Rank;
}
 
开发者ID:vigna,项目名称:Sux4J,代码行数:7,代码来源:Codec.java


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