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


Java LongArraySet类代码示例

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


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

示例1: doTruncateInvalidTxBefore

import it.unimi.dsi.fastutil.longs.LongArraySet; //导入依赖的package包/类
private boolean doTruncateInvalidTxBefore(long time) throws InvalidTruncateTimeException {
  LOG.info("Removing tx ids before {} from invalid list", time);
  long truncateWp = time * TxConstants.MAX_TX_PER_MS;
  // Check if there any in-progress transactions started earlier than truncate time
  if (inProgress.lowerKey(truncateWp) != null) {
    throw new InvalidTruncateTimeException("Transactions started earlier than " + time + " are in-progress");
  }
  
  // Find all invalid transactions earlier than truncateWp
  LongSet toTruncate = new LongArraySet();
  LongIterator it = invalidTxList.toRawList().iterator();
  while (it.hasNext()) {
    long wp = it.nextLong();
    if (wp < truncateWp) {
      toTruncate.add(wp);
    }
  }
  LOG.info("Removing tx ids {} from invalid list", toTruncate);
  return invalidTxList.removeAll(toTruncate);
}
 
开发者ID:apache,项目名称:incubator-tephra,代码行数:21,代码来源:TransactionManager.java

示例2: serializeNBT

import it.unimi.dsi.fastutil.longs.LongArraySet; //导入依赖的package包/类
@Override
public NBTBase serializeNBT() {
	NBTTagList nbtl = new NBTTagList();
	LongSet poss = new LongArraySet();
	poss.addAll(eChunks.keySet());
	for (long l : poss) {
		NBTTagCompound nbt = new NBTTagCompound();
		nbt.setLong("cp", l);
		Battery e = eChunks.get(l);
		if (e != null)
			nbt.setTag("e", e.serializeNBT());
		nbtl.appendTag(nbt);
	}
	return nbtl;
}
 
开发者ID:Szewek,项目名称:Minecraft-Flux,代码行数:16,代码来源:WorldChunkEnergy.java

示例3: countUnique

import it.unimi.dsi.fastutil.longs.LongArraySet; //导入依赖的package包/类
@Override
public int countUnique() {
    LongSet longSet = new LongArraySet();
    for (long i : data) {
        longSet.add(i);
    }
    return longSet.size();
}
 
开发者ID:jtablesaw,项目名称:tablesaw,代码行数:9,代码来源:LongColumn.java

示例4: testEmptyAuthor

import it.unimi.dsi.fastutil.longs.LongArraySet; //导入依赖的package包/类
@Test
public void testEmptyAuthor() {
  LeftIndexedMultiSegmentBipartiteGraph leftIndexedBipartiteGraph = null;
  LongSet tweetAuthors = new LongArraySet();
  TweetAuthorFilter authorFilter = new TweetAuthorFilter(leftIndexedBipartiteGraph, tweetAuthors, new NullStatsReceiver());
  assertEquals(false, authorFilter.filterResult(0L, new SmallArrayBasedLongToDoubleMap[] {}));
}
 
开发者ID:twitter,项目名称:GraphJet,代码行数:8,代码来源:TweetAuthorFilterTest.java

示例5: testOneAuthor

import it.unimi.dsi.fastutil.longs.LongArraySet; //导入依赖的package包/类
@Test
public void testOneAuthor() {
  NodeMetadataLeftIndexedMultiSegmentBipartiteGraph leftIndexedBipartiteGraph =
    new NodeMetadataLeftIndexedPowerLawMultiSegmentBipartiteGraph(
      3,
      10,
      10,
      10,
      2.0,
      100,
      2,
      new MockEdgeTypeMask((byte)RecommendationRequest.AUTHOR_SOCIAL_PROOF_TYPE),
      new NullStatsReceiver());
  int[][] dummyNodeMetadata = new int[][]{};

  leftIndexedBipartiteGraph.addEdge(1, 10, (byte)RecommendationRequest.AUTHOR_SOCIAL_PROOF_TYPE,
    0L, dummyNodeMetadata, dummyNodeMetadata);
  leftIndexedBipartiteGraph.addEdge(2, 20, (byte)RecommendationRequest.AUTHOR_SOCIAL_PROOF_TYPE,
    0L, dummyNodeMetadata, dummyNodeMetadata);

  SmallArrayBasedLongToDoubleMap[] socialProofs = {};
  LongSet tweetAuthors = new LongArraySet();

  // Only look for tweets from author 1
  tweetAuthors.add(1L);
  TweetAuthorFilter authorFilter = new TweetAuthorFilter(leftIndexedBipartiteGraph, tweetAuthors, new NullStatsReceiver());

  // Tweets authored by tweetAuthors should not be filtered. Node 10 is authored by 1.
  assertEquals(false, authorFilter.filterResult(10, socialProofs));
  // Tweets not authored by tweetAuthors should be filtered. Node 20 is not authored by 1
  assertEquals(true, authorFilter.filterResult(20, socialProofs));
}
 
开发者ID:twitter,项目名称:GraphJet,代码行数:33,代码来源:TweetAuthorFilterTest.java

示例6: unique

import it.unimi.dsi.fastutil.longs.LongArraySet; //导入依赖的package包/类
@Override
public LongColumn unique() {
    LongSet longSet = new LongArraySet();
    longSet.addAll(data);
    return new LongColumn(name() + " Unique values", new LongArrayList(longSet));
}
 
开发者ID:jtablesaw,项目名称:tablesaw,代码行数:7,代码来源:LongColumn.java

示例7: collectRecommendations

import it.unimi.dsi.fastutil.longs.LongArraySet; //导入依赖的package包/类
/**
 * Collect social proofs for a given {@link SocialProofRequest}.
 *
 * @param request contains a set of input ids and a set of seed users.
 */
private void collectRecommendations(SocialProofRequest request) {
  LongSet inputRightNodeIds = request.getRightNodeIds();
  ByteSet socialProofTypes = new ByteArraySet(request.getSocialProofTypes());

  // Iterate through the set of seed users with weights. For each seed user, we go through his edges.
  for (Long2DoubleMap.Entry entry: request.getLeftSeedNodesWithWeight().long2DoubleEntrySet()) {
    long leftNode = entry.getLongKey();
    double weight = entry.getDoubleValue();
    EdgeIterator edgeIterator = leftIndexedBipartiteGraph.getLeftNodeEdges(leftNode);

    int numEdgePerNode = 0;
    if (edgeIterator != null) {
      while (edgeIterator.hasNext() && numEdgePerNode++ < MAX_EDGES_PER_NODE) {
        long rightNode = idMask.restore(edgeIterator.nextLong());
        byte edgeType = edgeIterator.currentEdgeType();

        // If the current id is in the set of inputIds, we find and store its social proof.
        if (inputRightNodeIds.contains(rightNode) && socialProofTypes.contains(edgeType)) {
          if (!socialProofs.containsKey(rightNode)) {
            socialProofs.put(rightNode, new Byte2ObjectArrayMap<>());
            socialProofWeights.put(rightNode, 0);
          }
          Byte2ObjectMap<LongSet> socialProofMap = socialProofs.get(rightNode);

          // We sum the weights of incoming leftNodes as the weight of the rightNode.
          socialProofWeights.put(
            rightNode,
            weight + socialProofWeights.get(rightNode)
          );

          // Get the user set variable by the engagement type.
          if (!socialProofMap.containsKey(edgeType)) {
            socialProofMap.put(edgeType, new LongArraySet());
          }
          LongSet connectingUsers = socialProofMap.get(edgeType);

          // Add the connecting user to the user set.
          if (!connectingUsers.contains(leftNode)) {
            connectingUsers.add(leftNode);
          }
        }
      }
    }
  }
}
 
开发者ID:twitter,项目名称:GraphJet,代码行数:51,代码来源:SocialProofGenerator.java

示例8: testComputeRecommendations

import it.unimi.dsi.fastutil.longs.LongArraySet; //导入依赖的package包/类
@Test
public void testComputeRecommendations() throws Exception {
  LeftIndexedMultiSegmentBipartiteGraph bipartiteGraph = BipartiteGraphTestHelper.
    buildSmallTestLeftIndexedPowerLawMultiSegmentBipartiteGraphWithEdgeTypes();

  Long2DoubleMap seedsMap = new Long2DoubleArrayMap(new long[]{2, 3}, new double[]{1.0, 0.5});
  LongSet moments = new LongArraySet(new long[]{2, 3, 4, 5});

  byte[] validSocialProofs = new byte[]{0, 1, 2};
  long randomSeed = 918324701982347L;
  Random random = new Random(randomSeed);

  SocialProofRequest socialProofRequest = new SocialProofRequest(
    moments,
    seedsMap,
    validSocialProofs
  );

  SocialProofResponse socialProofResponse = new MomentSocialProofGenerator(
    bipartiteGraph
  ).computeRecommendations(socialProofRequest, random);

  List<RecommendationInfo> socialProofResults =
      Lists.newArrayList(socialProofResponse.getRankedRecommendations());

  for (RecommendationInfo recommendationInfo: socialProofResults) {
    SocialProofResult socialProofResult = (SocialProofResult) recommendationInfo;
    Long momentId = socialProofResult.getNode();
    Byte2ObjectMap<LongSet> socialProofs = socialProofResult.getSocialProof();

    if (momentId == 2 || momentId == 4) {
      assertEquals(socialProofs.isEmpty(), true);
    } else if (momentId == 3) {
      assertEquals(socialProofs.get((byte) 1).size(), 2);
      assertEquals(socialProofs.get((byte) 1).contains(2), true);
      assertEquals(socialProofs.get((byte) 1).contains(3), true);
    } else if (momentId == 5) {
      assertEquals(socialProofs.get((byte) 0).size(), 1);
      assertEquals(socialProofs.get((byte) 0).contains(2), true);
    }
  }
}
 
开发者ID:twitter,项目名称:GraphJet,代码行数:43,代码来源:MomentSocialProofTest.java

示例9: testComputeRecommendations

import it.unimi.dsi.fastutil.longs.LongArraySet; //导入依赖的package包/类
@Test
public void testComputeRecommendations() throws Exception {
  NodeMetadataLeftIndexedMultiSegmentBipartiteGraph bipartiteGraph =
    BipartiteGraphTestHelper.
      buildSmallTestNodeMetadataLeftIndexedMultiSegmentBipartiteGraph();

  Long2DoubleMap seedsMap = new Long2DoubleArrayMap(new long[]{2, 3}, new double[]{1.0, 0.5});
  LongSet tweets = new LongArraySet(new long[]{2, 3, 4, 5});

  byte[] validSocialProofs = new byte[]{0, 1, 2, 3, 4};
  long randomSeed = 918324701982347L;
  Random random = new Random(randomSeed);

  SocialProofRequest socialProofRequest = new SocialProofRequest(
    tweets,
    seedsMap,
    validSocialProofs
  );

  SocialProofResponse socialProofResponse = new TweetSocialProofGenerator(
    bipartiteGraph
  ).computeRecommendations(socialProofRequest, random);

  List<RecommendationInfo> socialProofResults =
    Lists.newArrayList(socialProofResponse.getRankedRecommendations());

  for (RecommendationInfo recommendationInfo : socialProofResults) {
    SocialProofResult socialProofResult = (SocialProofResult) recommendationInfo;
    Long tweetId = socialProofResult.getNode();
    Byte2ObjectMap<LongSet> socialProofs = socialProofResult.getSocialProof();

    // Test case for tweet 3 and 4
    if (tweetId == 3 || tweetId == 4) {
      assertEquals(socialProofs.isEmpty(), true);
    }

    // Test case for tweet 2 and 5
    if (tweetId == 2) {
      assertEquals(socialProofs.get((byte) 0).size(), 1);
      assertEquals(socialProofs.get((byte) 0).contains(3), true);
    } else if (tweetId == 5) {
      assertEquals(socialProofs.get((byte) 0).size(), 2);
      assertEquals(socialProofs.get((byte) 0).contains(2), true);
      assertEquals(socialProofs.get((byte) 0).contains(3), true);
    }
  }
}
 
开发者ID:twitter,项目名称:GraphJet,代码行数:48,代码来源:TweetSocialProofTest.java

示例10: simpleOperation

import it.unimi.dsi.fastutil.longs.LongArraySet; //导入依赖的package包/类
@Test
public void simpleOperation() {
  final AtomicBoolean shouldFail = new AtomicBoolean(false);
  
  final ValueSpecification[] valueSpec = new ValueSpecification[6];
  final Map<ValueSpecification, Long> realIdentifiers = new HashMap<ValueSpecification, Long> ();
  for (int i = 0; i < valueSpec.length; i++) {
    valueSpec[i] = new ValueSpecification("value" + i, ComputationTargetSpecification.of(UniqueId.of("scheme", "fibble")),
        ValueProperties.with(ValuePropertyNames.FUNCTION, "mockFunctionId").get());
    realIdentifiers.put (valueSpec[i], (long)i);
  }
  
  IdentifierMap underlying = new AbstractIdentifierMap() {
    
    @Override
    public long getIdentifier(ValueSpecification spec) {
      if (shouldFail.get()) {
        AssertJUnit.fail("Should not have called underlying.");
      }
      return realIdentifiers.get (spec);
    }

    @Override
    public ValueSpecification getValueSpecification(long identifier) {
      if (shouldFail.get ()) {
        AssertJUnit.fail ("Should not have called underlying.");
      }
      return valueSpec[(int)identifier];
    }

  };
  
  CachingIdentifierMap cachingSource = new CachingIdentifierMap(underlying);
  
  assertEquals(0L, cachingSource.getIdentifier(valueSpec[0]));
  final Map<ValueSpecification, Long> identifiers1 = new HashMap<ValueSpecification, Long> ();
  identifiers1.put (valueSpec[1], 1L);
  identifiers1.put (valueSpec[2], 2L);
  final Map<ValueSpecification, Long> identifiers2 = new HashMap<ValueSpecification, Long> ();
  identifiers2.put (valueSpec[3], 3L);
  identifiers2.put (valueSpec[4], 4L);
  assertEquals (identifiers1, cachingSource.getIdentifiers (Arrays.asList(valueSpec[1], valueSpec[2])));    
  assertEquals (valueSpec[3], cachingSource.getValueSpecification (3));
  final Map<Long, ValueSpecification> valueSpecs1 = new HashMap<Long, ValueSpecification> ();
  valueSpecs1.put (1L, valueSpec[1]);
  valueSpecs1.put (2L, valueSpec[2]);
  final Map<Long, ValueSpecification> valueSpecs2 = new HashMap<Long, ValueSpecification> ();
  valueSpecs2.put (4L, valueSpec[4]);
  valueSpecs2.put (5L, valueSpec[5]);
  assertEquals(valueSpecs2, cachingSource.getValueSpecifications(new LongArraySet(new long[] {4L, 5L })));
  shouldFail.set(true);
  for (int i = 0; i < valueSpec.length; i++) {
    assertEquals((long)i, cachingSource.getIdentifier(valueSpec[i]));
    assertEquals((long)i, cachingSource.getIdentifier(valueSpec[i]));
    assertEquals (valueSpec[i], cachingSource.getValueSpecification (i));
    assertEquals (valueSpec[i], cachingSource.getValueSpecification (i));
  }
  assertEquals (identifiers1, cachingSource.getIdentifiers (Arrays.asList(valueSpec[1], valueSpec[2])));
  assertEquals (identifiers1, cachingSource.getIdentifiers (Arrays.asList(valueSpec[1], valueSpec[2])));
  assertEquals(valueSpecs1, cachingSource.getValueSpecifications(new LongArraySet(new long[] {1L, 2L })));
  assertEquals(valueSpecs1, cachingSource.getValueSpecifications(new LongArraySet(new long[] {1L, 2L })));
  assertEquals (identifiers2, cachingSource.getIdentifiers (Arrays.asList(valueSpec[3], valueSpec[4])));
  assertEquals (identifiers2, cachingSource.getIdentifiers (Arrays.asList(valueSpec[3], valueSpec[4])));
  assertEquals(valueSpecs2, cachingSource.getValueSpecifications(new LongArraySet(new long[] {4L, 5L })));
  assertEquals(valueSpecs2, cachingSource.getValueSpecifications(new LongArraySet(new long[] {4L, 5L })));
  
}
 
开发者ID:DevStreet,项目名称:FinanceAnalytics,代码行数:68,代码来源:CachingValueSpecificationIdentifierSourceTest.java

示例11: clearChildGroups

import it.unimi.dsi.fastutil.longs.LongArraySet; //导入依赖的package包/类
public void clearChildGroups() {
	this.childGroups.clear();
	this.childGroups = new LongArraySet();
}
 
开发者ID:uci-sdcl,项目名称:Calico,代码行数:5,代码来源:CGroup.java

示例12: clearChildStrokes

import it.unimi.dsi.fastutil.longs.LongArraySet; //导入依赖的package包/类
public void clearChildStrokes() {
	this.childStrokes.clear();
	this.childStrokes = new LongArraySet();
}
 
开发者ID:uci-sdcl,项目名称:Calico,代码行数:5,代码来源:CGroup.java

示例13: clearChildArrows

import it.unimi.dsi.fastutil.longs.LongArraySet; //导入依赖的package包/类
public void clearChildArrows() {
	this.childArrows.clear();
	this.childArrows = new LongArraySet();
}
 
开发者ID:uci-sdcl,项目名称:Calico,代码行数:5,代码来源:CGroup.java

示例14: clearChildConnectors

import it.unimi.dsi.fastutil.longs.LongArraySet; //导入依赖的package包/类
public void clearChildConnectors() {
	this.childConnectors.clear();
	this.childConnectors = new LongArraySet();
}
 
开发者ID:uci-sdcl,项目名称:Calico,代码行数:5,代码来源:CGroup.java

示例15: clear

import it.unimi.dsi.fastutil.longs.LongArraySet; //导入依赖的package包/类
/**
	 * This clears the canvas and all its contents.
	 */
	public void clear()
	{
		CGroupController.restoreOriginalStroke = false;
		
		if(this.groups.size()>0)
		{
			long guuids[] = this.groups.toLongArray();
			for(int i=guuids.length-1;i>=0;i--)
			{
				CGroupController.no_notify_delete(guuids[i]);
			}
		}
		
		if(this.strokes.size()>0)
		{
			long suuids[] = this.strokes.toLongArray();
			for(int i=suuids.length-1;i>=0;i--)
			{
				CStrokeController.no_notify_delete(suuids[i]);
			}
		}
		
		if(this.arrows.size()>0)
		{
			long auuids[] = this.arrows.toLongArray();
			for(int i=auuids.length-1;i>=0;i--)
			{
				CArrowController.no_notify_delete(auuids[i]);
			}
		}
		
		if(this.connectors.size()>0)
		{
			long cuuids[] = this.connectors.toLongArray();
			for(int i=cuuids.length-1;i>=0;i--)
			{
				CConnectorController.no_notify_delete(cuuids[i]);
			}
		}

		this.groups = new LongArraySet();
		this.strokes = new LongArraySet();
		this.arrows = new LongArraySet();
		this.connectors = new LongArraySet();
		this.lists = new LongArraySet();
		this.checkBoxes = new LongArraySet();
		
//		this.getLayer().removeAllChildren();
		
		//removing this line because it seems to incorrectly remove the borders and the repaint below seems to do the same thing.
		//clearEverythingExceptMenu();
		
		drawMenuBars();
		//this.getLayer(Layer.CONTENT).repaint();
		CalicoDraw.repaint(this.getLayer(Layer.CONTENT));
	}
 
开发者ID:uci-sdcl,项目名称:Calico,代码行数:60,代码来源:CCanvas.java


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