本文整理汇总了Java中it.unimi.dsi.fastutil.longs.LongOpenHashSet类的典型用法代码示例。如果您正苦于以下问题:Java LongOpenHashSet类的具体用法?Java LongOpenHashSet怎么用?Java LongOpenHashSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
LongOpenHashSet类属于it.unimi.dsi.fastutil.longs包,在下文中一共展示了LongOpenHashSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testRunReturningPositive
import it.unimi.dsi.fastutil.longs.LongOpenHashSet; //导入依赖的package包/类
@Test
public void testRunReturningPositive() {
HigherBitsEdgeTypeMask higherBitsEdgeTypeMask = new HigherBitsEdgeTypeMask();
OutIndexedPowerLawMultiSegmentDirectedGraph powerLawMultiSegmentDirectedGraph =
new OutIndexedPowerLawMultiSegmentDirectedGraph(1249,
1249,
1249,
1249,
1249,
higherBitsEdgeTypeMask,
new NullStatsReceiver());
LongOpenHashSet longOpenHashSet = new LongOpenHashSet();
powerLawMultiSegmentDirectedGraph.addEdge(0L, 1170L, (byte) (-126));
longOpenHashSet.add(0L);
PageRank pageRank =
new PageRank(powerLawMultiSegmentDirectedGraph, longOpenHashSet, 1249, 1249, 1249, 1249);
int resultInt = pageRank.run();
assertEquals(0.0, pageRank.getL1Norm(), 0.01);
assertEquals(3, resultInt);
}
示例2: checkAndStore
import it.unimi.dsi.fastutil.longs.LongOpenHashSet; //导入依赖的package包/类
protected <T> void checkAndStore(long entityId, Class<? super T> type) {
if (isTransaction) {
LongOpenHashSet entityAdded = added.get(type);
if (entityAdded.contains(entityId))
return;
T oldT = repository.get((Class<T>)type, entityId);
Long2ObjectOpenHashMap<Object> data = snapshotted.get(type);
if (oldT == null) {
entityAdded.add(entityId);
} else if (!data.containsKey(entityId)) {
data.put(entityId, oldT);
}
}
}
示例3: sameComponents
import it.unimi.dsi.fastutil.longs.LongOpenHashSet; //导入依赖的package包/类
public static void sameComponents( final int l, final StronglyConnectedComponentsTarjan componentsRecursive, final StronglyConnectedComponents componentsIterative ) {
final LongOpenHashSet[] recursiveComponentsSet = new LongOpenHashSet[ componentsRecursive.numberOfComponents ];
final LongOpenHashSet[] iterativeComponentsSet = new LongOpenHashSet[ componentsIterative.numberOfComponents ];
for( int i = recursiveComponentsSet.length; i-- != 0; ) {
recursiveComponentsSet[ i ] = new LongOpenHashSet();
iterativeComponentsSet[ i ] = new LongOpenHashSet();
}
for( int i = l; i-- != 0; ) {
recursiveComponentsSet[ componentsRecursive.component[ i ] ].add( i );
iterativeComponentsSet[ componentsIterative.component[ i ] ].add( i );
}
assertEquals( new ObjectOpenHashSet<LongOpenHashSet>( recursiveComponentsSet ), new ObjectOpenHashSet<LongOpenHashSet>( iterativeComponentsSet ) );
}
示例4: thresholdStrategy
import it.unimi.dsi.fastutil.longs.LongOpenHashSet; //导入依赖的package包/类
public static Deque<Sequence> thresholdStrategy(BigLong2ShortHashMap hm,
int availableProcessors,
int freqThreshold,
int lenThreshold,
int k) throws InterruptedException {
Deque<Sequence> ans = new ConcurrentLinkedDeque<Sequence>();
LongOpenHashSet used = new LongOpenHashSet();
BlockingThreadPoolExecutor executor = new BlockingThreadPoolExecutor(availableProcessors);
for (int i = 0; i < hm.maps.length; ++i) {
executor.blockingExecute(new
AddSequencesShiftingRightTask(hm, hm.maps[i], k, freqThreshold, lenThreshold, ans, used));
}
// System.out.println(executor.getTaskCount());
executor.shutdownAndAwaitTermination();
return ans;
}
示例5: initializeStorage
import it.unimi.dsi.fastutil.longs.LongOpenHashSet; //导入依赖的package包/类
/**
* Initializes storage for the specified {@link HLLType} and changes the
* instance's {@link #type}.
*
* @param type the {@link HLLType} to initialize storage for. This cannot be
* <code>null</code> and must be an instantiable type. (For instance,
* it cannot be {@link HLLType#UNDEFINED}.)
*/
private void initializeStorage(final HLLType type) {
this.type = type;
switch(type) {
case EMPTY:
// nothing to be done
break;
case EXPLICIT:
this.explicitStorage = new LongOpenHashSet();
break;
case SPARSE:
this.sparseProbabilisticStorage = new Int2ByteOpenHashMap();
break;
case FULL:
this.probabilisticStorage = new BitVector(regwidth, m);
break;
default:
throw new RuntimeException("Unsupported HLL type " + type);
}
}
示例6: verifyOplogs
import it.unimi.dsi.fastutil.longs.LongOpenHashSet; //导入依赖的package包/类
public void verifyOplogs(LongOpenHashSet foundCrfs, LongOpenHashSet foundDrfs,
LongOpenHashSet expectedCrfIds, LongOpenHashSet expectedDrfIds) {
LongOpenHashSet missingCrfs = calcMissing(foundCrfs, expectedCrfIds);
LongOpenHashSet missingDrfs = calcMissing(foundDrfs, expectedDrfIds);
// Note that finding extra ones is ok; it is possible we died just
// after creating one but before we could record it in the if file
// Or died just after deleting it but before we could record it in the if file.
boolean failed = false;
String msg = null;
if (!missingCrfs.isEmpty()) {
failed = true;
msg = "*.crf files with these ids: " + Arrays.toString(missingCrfs.toArray());
}
if (!missingDrfs.isEmpty()) {
failed = true;
if (msg == null) {
msg = "";
} else {
msg += ", ";
}
msg += "*.drf files with these ids: " + Arrays.toString(missingDrfs.toArray());
}
if (failed) {
msg = "The following required files could not be found: " + msg + ".";
throw new IllegalStateException(msg);
}
}
示例7: main
import it.unimi.dsi.fastutil.longs.LongOpenHashSet; //导入依赖的package包/类
public static void main(String[] arg) throws IOException {
if (arg.length == 0) {
System.err.println("Usage: " + BuildRepetitionSet.class.getSimpleName() + " REPETITIONSET");
System.exit(1);
}
final FastBufferedReader fastBufferedReader = new FastBufferedReader(new InputStreamReader(System.in, Charsets.US_ASCII));
final MutableString s = new MutableString();
final LongOpenHashSet repeatedSet = new LongOpenHashSet();
final String outputFilename = arg[0];
final ProgressLogger pl = new ProgressLogger();
MutableString lastUrl = new MutableString();
pl.itemsName = "lines";
pl.start("Reading... ");
while(fastBufferedReader.readLine(s) != null) {
final int firstTab = s.indexOf('\t');
final int secondTab = s.indexOf('\t', firstTab + 1);
MutableString url = s.substring(secondTab + 1);
if (url.equals(lastUrl)) {
final int storeIndex = Integer.parseInt(new String(s.array(), 0, firstTab));
final long storePosition = Long.parseLong(new String(s.array(), firstTab + 1, secondTab - firstTab - 1));
repeatedSet.add((long)storeIndex << 48 | storePosition);
System.out.print(storeIndex);
System.out.print('\t');
System.out.print(storePosition);
System.out.print('\t');
System.out.println(url);
}
lastUrl = url;
pl.lightUpdate();
}
pl.done();
fastBufferedReader.close();
BinIO.storeObject(repeatedSet, outputFilename);
}
示例8: countUnique
import it.unimi.dsi.fastutil.longs.LongOpenHashSet; //导入依赖的package包/类
@Override
public int countUnique() {
LongSet ints = new LongOpenHashSet(data.size());
for (long i : data) {
ints.add(i);
}
return ints.size();
}
示例9: unique
import it.unimi.dsi.fastutil.longs.LongOpenHashSet; //导入依赖的package包/类
@Override
public DateTimeColumn unique() {
LongSet ints = new LongOpenHashSet(data.size());
for (long i : data) {
ints.add(i);
}
return new DateTimeColumn(name() + " Unique values",
LongArrayList.wrap(ints.toLongArray()));
}
示例10: isLessThanMinUserSocialProofSizeCombined
import it.unimi.dsi.fastutil.longs.LongOpenHashSet; //导入依赖的package包/类
private static boolean isLessThanMinUserSocialProofSizeCombined(
SmallArrayBasedLongToDoubleMap[] socialProofs,
int minUserSocialProofSize,
Set<byte[]> socialProofTypeUnions) {
if (socialProofTypeUnions.isEmpty() ||
// check if the size of any social proof union is greater than minUserSocialProofSize before dedupping
isSocialProofUnionSizeLessThanMin(socialProofs, minUserSocialProofSize, socialProofTypeUnions)) {
return true;
}
LongSet uniqueNodes = new LongOpenHashSet(minUserSocialProofSize);
for (byte[] socialProofTypeUnion: socialProofTypeUnions) {
// Clear removes all elements, but does not change the size of the set.
// Thus, we only use one LongOpenHashSet with at most a size of 2*minUserSocialProofSize
uniqueNodes.clear();
for (byte socialProofType: socialProofTypeUnion) {
if (socialProofs[socialProofType] != null) {
for (int i = 0; i < socialProofs[socialProofType].size(); i++) {
uniqueNodes.add(socialProofs[socialProofType].keys()[i]);
if (uniqueNodes.size() >= minUserSocialProofSize) {
return false;
}
}
}
}
}
return true;
}
示例11: CommonInternalState
import it.unimi.dsi.fastutil.longs.LongOpenHashSet; //导入依赖的package包/类
/**
* Get a new instance of a fresh internal state.
*
* @param salsaStats is the stats object to use
* @param expectedNodesToHit is the number of nodes the random walk is expected to hit
*/
public CommonInternalState(
SalsaStats salsaStats,
int expectedNodesToHit) {
this.salsaStats = salsaStats;
this.currentLeftNodes = new Long2IntOpenHashMap(expectedNodesToHit);
this.currentRightNodes = new Long2IntOpenHashMap(expectedNodesToHit);
this.visitedRightNodes = new Long2ObjectOpenHashMap<NodeInfo>(expectedNodesToHit);
this.nonZeroSeedSet = new LongOpenHashSet(expectedNodesToHit);
}
示例12: PageRank
import it.unimi.dsi.fastutil.longs.LongOpenHashSet; //导入依赖的package包/类
/**
* Constructs this object for running PageRank over a directed graph.
*
* @param graph the directed graph
* @param nodes nodes in the graph
* @param maxNodeId maximum node id
* @param dampingFactor damping factor
* @param maxIterations maximum number of iterations to run
* @param tolerance L1 norm threshold for convergence
*/
public PageRank(OutIndexedDirectedGraph graph, LongOpenHashSet nodes, long maxNodeId,
double dampingFactor, int maxIterations, double tolerance) {
if (maxNodeId > Integer.MAX_VALUE) {
throw new UnsupportedOperationException("maxNodeId exceeds Integer.MAX_VALUE!");
}
this.graph = graph;
this.nodes = nodes;
this.maxNodeId = maxNodeId;
this.dampingFactor = dampingFactor;
this.nodeCount = nodes.size();
this.maxIterations = maxIterations;
this.tolerance = tolerance;
}
示例13: buildRandomLeftRegularBipartiteGraph
import it.unimi.dsi.fastutil.longs.LongOpenHashSet; //导入依赖的package包/类
/**
* Build a random left-regular bipartite graph of given left and right sizes.
*
* @param leftSize is the left hand size of the bipartite graph
* @param rightSize is the right hand size of the bipartite graph
* @param leftDegree is the degree of the left hand side
* @param random is the random number generator to use for constructing the graph
* @return a random bipartite graph
*/
public static LeftRegularBipartiteGraphSegment buildRandomLeftRegularBipartiteGraph(
int leftSize, int rightSize, int leftDegree, Random random) {
LeftRegularBipartiteGraphSegment leftRegularBipartiteGraphSegment =
new LeftRegularBipartiteGraphSegment(
leftSize / 2,
leftDegree,
rightSize / 2,
leftSize / 2,
2.0,
Integer.MAX_VALUE,
new IdentityEdgeTypeMask(),
new NullStatsReceiver());
LongSet addedIds = new LongOpenHashSet(leftDegree);
for (int i = 0; i < leftSize; i++) {
addedIds.clear();
for (int j = 0; j < leftDegree; j++) {
long idToAdd;
do {
idToAdd = random.nextInt(rightSize);
} while (addedIds.contains(idToAdd));
addedIds.add(idToAdd);
leftRegularBipartiteGraphSegment.addEdge(i, idToAdd, (byte) 0);
}
}
return leftRegularBipartiteGraphSegment;
}
示例14: setUp
import it.unimi.dsi.fastutil.longs.LongOpenHashSet; //导入依赖的package包/类
@Before
public void setUp() {
long queryNode = 1;
BipartiteGraph bipartiteGraph = BipartiteGraphTestHelper.buildSmallTestBipartiteGraph();
LongSet toBeFiltered = new LongOpenHashSet(8);
int numIterations = 5;
double resetProbability = 0.3;
int numResults = 3;
int numRandomWalks = 1000;
int maxSocialProofSize = 2;
int expectedNodesToHit = numRandomWalks * numIterations / 2;
SalsaStats salsaStats = new SalsaStats();
socialProofTypes = new byte[]{0, 1, 2, 3};
ResultFilterChain resultFilterChain = new ResultFilterChain(Lists.newArrayList(
new RequestedSetFilter(new NullStatsReceiver()),
new DirectInteractionsFilter(bipartiteGraph, new NullStatsReceiver())
));
salsaRequest = new SalsaRequestBuilder(queryNode)
.withLeftSeedNodes(null)
.withToBeFiltered(toBeFiltered)
.withMaxNumResults(numResults)
.withResetProbability(resetProbability)
.withMaxRandomWalkLength(numIterations)
.withNumRandomWalks(numRandomWalks)
.withMaxSocialProofSize(maxSocialProofSize)
.withValidSocialProofTypes(socialProofTypes)
.withResultFilterChain(resultFilterChain)
.build();
salsaInternalState = new SalsaInternalState(
bipartiteGraph, salsaStats, expectedNodesToHit);
salsaInternalState.resetWithRequest(salsaRequest);
}
示例15: saveEntityState
import it.unimi.dsi.fastutil.longs.LongOpenHashSet; //导入依赖的package包/类
protected boolean saveEntityState(long entityId, Class<?> type, Object entity, EntityRecoveryState state) {
LongOpenHashSet stashedEntities = stashed.get(type);
if (!stashedEntities.contains(entityId)) {
if (!serializer.isRegistered(entity.getClass()))
serializer.registerTransactionType(entity.getClass());
marshallEntity(entityId, type, entity, state);
stashedEntities.add(entityId);
return true;
} else
return false;
}