本文整理汇总了Java中it.unimi.dsi.fastutil.longs.LongOpenHashSet.add方法的典型用法代码示例。如果您正苦于以下问题:Java LongOpenHashSet.add方法的具体用法?Java LongOpenHashSet.add怎么用?Java LongOpenHashSet.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类it.unimi.dsi.fastutil.longs.LongOpenHashSet
的用法示例。
在下文中一共展示了LongOpenHashSet.add方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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);
}
示例4: 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;
}
示例5: LongRawValueBasedNotInPredicateEvaluator
import it.unimi.dsi.fastutil.longs.LongOpenHashSet; //导入方法依赖的package包/类
LongRawValueBasedNotInPredicateEvaluator(NotInPredicate notInPredicate) {
String[] values = notInPredicate.getValues();
_nonMatchingValues = new LongOpenHashSet(values.length);
for (String value : values) {
_nonMatchingValues.add(Long.parseLong(value));
}
}
示例6: LongRawValueBasedInPredicateEvaluator
import it.unimi.dsi.fastutil.longs.LongOpenHashSet; //导入方法依赖的package包/类
LongRawValueBasedInPredicateEvaluator(InPredicate predicate) {
String[] values = predicate.getValues();
_matchingValues = new LongOpenHashSet(values.length);
for (String value : values) {
_matchingValues.add(Long.parseLong(value));
}
}
示例7: createOplogs
import it.unimi.dsi.fastutil.longs.LongOpenHashSet; //导入方法依赖的package包/类
public void createOplogs(boolean needsOplogs, Map<File, DirectoryHolder> backupFiles) {
LongOpenHashSet foundCrfs = new LongOpenHashSet();
LongOpenHashSet foundDrfs = new LongOpenHashSet();
for (Map.Entry<File, DirectoryHolder> entry : backupFiles.entrySet()) {
File file = entry.getKey();
String absolutePath = file.getAbsolutePath();
int underscorePosition = absolutePath.lastIndexOf("_");
int pointPosition = absolutePath.lastIndexOf(".");
String opid = absolutePath.substring(underscorePosition + 1, pointPosition);
long oplogId = Long.parseLong(opid);
maxRecoveredOplogId = Math.max(maxRecoveredOplogId, oplogId);
// here look diskinit file and check if this opid already deleted or not
// if deleted then don't process it.
if (Oplog.isCRFFile(file.getName())) {
if (!isCrfOplogIdPresent(oplogId)) {
deleteFileOnRecovery(file);
try {
String krfFileName = Oplog.getKRFFilenameFromCRFFilename(file.getAbsolutePath());
File krfFile = new File(krfFileName);
deleteFileOnRecovery(krfFile);
} catch (Exception ex) {// ignore
}
continue; // this file we unable to delete earlier
}
} else if (Oplog.isDRFFile(file.getName())) {
if (!isDrfOplogIdPresent(oplogId)) {
deleteFileOnRecovery(file);
continue; // this file we unable to delete earlier
}
}
Oplog oplog = getChild(oplogId);
if (oplog == null) {
oplog = new Oplog(oplogId, this);
// oplogSet.add(oplog);
addRecoveredOplog(oplog);
}
if (oplog.addRecoveredFile(file, entry.getValue())) {
foundCrfs.add(oplogId);
} else {
foundDrfs.add(oplogId);
}
}
if (needsOplogs) {
verifyOplogs(foundCrfs, foundDrfs);
}
}
示例8: testLesMisGraph
import it.unimi.dsi.fastutil.longs.LongOpenHashSet; //导入方法依赖的package包/类
@Test
public void testLesMisGraph() throws Exception {
OutIndexedPowerLawMultiSegmentDirectedGraph graph =
new OutIndexedPowerLawMultiSegmentDirectedGraph(1, 1000, 100, 10, 2,
new IdentityEdgeTypeMask(), new NullStatsReceiver());
for (int i=0; i<LES_MIS_GRAPH.length; i++) {
graph.addEdge(LES_MIS_GRAPH[i][0], LES_MIS_GRAPH[i][1], (byte) 0);
}
// Spot check the graph to make sure it's been loaded correctly.
assertEquals(7, graph.getOutDegree(76));
assertEquals(new LongArrayList(new long[]{64, 65, 66, 63, 62, 48, 58}), new LongArrayList(graph.getOutEdges(76)));
assertEquals(1, graph.getOutDegree(30));
assertEquals(new LongArrayList(new long[]{23}), new LongArrayList(graph.getOutEdges(30)));
assertEquals(4, graph.getOutDegree(11));
assertEquals(new LongArrayList(new long[]{10, 3, 2, 0}), new LongArrayList(graph.getOutEdges(11)));
LongOpenHashSet nodes = new LongOpenHashSet();
long maxNodeId = 0;
for (int i=0; i<LES_MIS_GRAPH.length; i++) {
if ( !nodes.contains(LES_MIS_GRAPH[i][0])) nodes.add(LES_MIS_GRAPH[i][0]);
if ( !nodes.contains(LES_MIS_GRAPH[i][1])) nodes.add(LES_MIS_GRAPH[i][1]);
if ( LES_MIS_GRAPH[i][0] > maxNodeId ) maxNodeId = LES_MIS_GRAPH[i][0];
if ( LES_MIS_GRAPH[i][1] > maxNodeId ) maxNodeId = LES_MIS_GRAPH[i][1];
}
assertEquals(76, maxNodeId);
PageRank pr = new PageRank(graph, nodes, maxNodeId, 0.85, 10, 1e-15);
int numIterations = pr.run();
double normL1 = pr.getL1Norm();
double[] pagerank = pr.getPageRankVector();
assertEquals(10, numIterations);
assertEquals(0.00108, normL1, 10e-4);
List<Map.Entry<Long, Double>> scores = new ArrayList<>();
for (int i=0; i<maxNodeId+1; i++) {
scores.add(new AbstractMap.SimpleEntry<>((long) i, pagerank[i]));
}
// Sort by score.
scores.sort((e1, e2) -> e2.getValue() > e1.getValue() ? 1 : e2.getKey().compareTo(e1.getKey()));
// We're going to verify that the ranking and score are both correct. These rankings have been verified against an
// external implementation (JUNG).
assertEquals(11, (long) scores.get(0).getKey());
assertEquals(0.1088995, scores.get(0).getValue(), 10e-4);
assertEquals(0, (long) scores.get(1).getKey());
assertEquals(0.09538347, scores.get(1).getValue(), 10e-4);
assertEquals(16, (long) scores.get(2).getKey());
assertEquals(0.05104386, scores.get(2).getValue(), 10e-4);
assertEquals(23, (long) scores.get(3).getKey());
assertEquals(0.04389916, scores.get(3).getValue(), 10e-4);
assertEquals(25, (long) scores.get(4).getKey());
assertEquals(0.04095956, scores.get(4).getValue(), 10e-4);
assertEquals(2, (long) scores.get(5).getKey());
assertEquals(0.03868165, scores.get(5).getValue(), 10e-4);
assertEquals(24, (long) scores.get(6).getKey());
assertEquals(0.03617344, scores.get(6).getValue(), 10e-4);
assertEquals(48, (long) scores.get(7).getKey());
assertEquals(0.0290502, scores.get(7).getValue(), 10e-4);
assertEquals(10, (long) scores.get(8).getKey());
assertEquals(0.02714507, scores.get(8).getValue(), 10e-4);
assertEquals(3, (long) scores.get(9).getKey());
assertEquals(0.02714507, scores.get(9).getValue(), 10e-4);
double totalMass = 0.0;
for (int i=0; i<maxNodeId+1; i++) {
totalMass += scores.get(i).getValue();
}
// Total mass should still be 1.0.
assertEquals(1.0, totalMass, 10e-10);
}
示例9: testLesMisGraph
import it.unimi.dsi.fastutil.longs.LongOpenHashSet; //导入方法依赖的package包/类
@Test
public void testLesMisGraph() throws Exception {
OutIndexedPowerLawMultiSegmentDirectedGraph graph =
new OutIndexedPowerLawMultiSegmentDirectedGraph(1, 1000, 100, 10, 2,
new IdentityEdgeTypeMask(), new NullStatsReceiver());
for (int i=0; i<LES_MIS_GRAPH.length; i++) {
graph.addEdge(LES_MIS_GRAPH[i][0], LES_MIS_GRAPH[i][1], (byte) 0);
}
// Spot check the graph to make sure it's been loaded correctly.
assertEquals(7, graph.getOutDegree(76));
assertEquals(new LongArrayList(new long[]{64, 65, 66, 63, 62, 48, 58}), new LongArrayList(graph.getOutEdges(76)));
assertEquals(1, graph.getOutDegree(30));
assertEquals(new LongArrayList(new long[]{23}), new LongArrayList(graph.getOutEdges(30)));
assertEquals(4, graph.getOutDegree(11));
assertEquals(new LongArrayList(new long[]{10, 3, 2, 0}), new LongArrayList(graph.getOutEdges(11)));
LongOpenHashSet nodes = new LongOpenHashSet();
long maxNodeId = 0;
for (int i=0; i<LES_MIS_GRAPH.length; i++) {
if ( !nodes.contains(LES_MIS_GRAPH[i][0])) nodes.add(LES_MIS_GRAPH[i][0]);
if ( !nodes.contains(LES_MIS_GRAPH[i][1])) nodes.add(LES_MIS_GRAPH[i][1]);
if ( LES_MIS_GRAPH[i][0] > maxNodeId ) maxNodeId = LES_MIS_GRAPH[i][0];
if ( LES_MIS_GRAPH[i][1] > maxNodeId ) maxNodeId = LES_MIS_GRAPH[i][1];
}
assertEquals(76, maxNodeId);
MultiThreadedPageRank pr = new MultiThreadedPageRank(graph, new LongArrayList(nodes), maxNodeId, 0.85, 10, 1e-15, 3);
int numIterations = pr.run();
double normL1 = pr.getL1Norm();
AtomicDoubleArray pagerank = pr.getPageRankVector();
assertEquals(10, numIterations);
assertEquals(0.00108, normL1, 10e-4);
List<Map.Entry<Long, Double>> scores = new ArrayList<>();
for (int i=0; i<maxNodeId+1; i++) {
scores.add(new AbstractMap.SimpleEntry<>((long) i, pagerank.get(i)));
}
// Sort by score.
scores.sort((e1, e2) -> e2.getValue() > e1.getValue() ? 1 : e2.getKey().compareTo(e1.getKey()));
// We're going to verify that the ranking and score are both correct. These rankings have been verified against an
// external implementation (JUNG).
assertEquals(11, (long) scores.get(0).getKey());
assertEquals(0.1088995, scores.get(0).getValue(), 10e-4);
assertEquals(0, (long) scores.get(1).getKey());
assertEquals(0.09538347, scores.get(1).getValue(), 10e-4);
assertEquals(16, (long) scores.get(2).getKey());
assertEquals(0.05104386, scores.get(2).getValue(), 10e-4);
assertEquals(23, (long) scores.get(3).getKey());
assertEquals(0.04389916, scores.get(3).getValue(), 10e-4);
assertEquals(25, (long) scores.get(4).getKey());
assertEquals(0.04095956, scores.get(4).getValue(), 10e-4);
assertEquals(2, (long) scores.get(5).getKey());
assertEquals(0.03868165, scores.get(5).getValue(), 10e-4);
assertEquals(24, (long) scores.get(6).getKey());
assertEquals(0.03617344, scores.get(6).getValue(), 10e-4);
assertEquals(48, (long) scores.get(7).getKey());
assertEquals(0.0290502, scores.get(7).getValue(), 10e-4);
assertEquals(10, (long) scores.get(8).getKey());
assertEquals(0.02714507, scores.get(8).getValue(), 10e-4);
assertEquals(3, (long) scores.get(9).getKey());
assertEquals(0.02714507, scores.get(9).getValue(), 10e-4);
double totalMass = 0.0;
for (int i=0; i<maxNodeId+1; i++) {
totalMass += scores.get(i).getValue();
}
// Total mass should still be 1.0.
assertEquals(1.0, totalMass, 10e-10);
}
示例10: testErdosRenyi
import it.unimi.dsi.fastutil.longs.LongOpenHashSet; //导入方法依赖的package包/类
@Test
public void testErdosRenyi() throws IOException {
for( int size: new int[] { 10, 100, 1000, 10000 } ) {
for( boolean upperBound: new boolean[] { false, true } ) {
final String basename = File.createTempFile( getClass().getSimpleName(), "test" ).toString();
final ImmutableGraph g = new ArrayListMutableGraph( new ErdosRenyiGraph( size, .001, 0, false ) ).immutableView();
EFGraph.store( g, upperBound ? size * size : size, basename, 3, 1024, ByteOrder.nativeOrder(), null );
final EFGraph efGraph = (EFGraph)ImmutableGraph.load( basename );
assertEquals( g, efGraph );
for( int i = 0; i < size; i++ ) {
for( int j = i + 1; j < size; j++ ) {
LongOpenHashSet a = new LongOpenHashSet();
LongOpenHashSet b = new LongOpenHashSet();
LazyIntIterator sa = g.successors( i );
LazyIntIterator sb = g.successors( j );
for( long s; ( s = sa.nextInt() ) != -1; ) a.add( s );
for( long t; ( t = sb.nextInt() ) != -1; ) b.add( t );
a.retainAll( b );
b.clear();
final LazyIntSkippableIterator sx = efGraph.successors( i );
final LazyIntSkippableIterator sy = efGraph.successors( j );
int x = sx.nextInt();
int y = sy.nextInt();
while( x != -1 && x != LazyIntSkippableIterator.END_OF_LIST && y != -1 && y != LazyIntSkippableIterator.END_OF_LIST ) {
if ( x == y ) {
b.add ( x );
x = sx.nextInt();
}
else if( x < y ) x = sx.skipTo( y );
else y = sy.skipTo( x );
}
assertEquals( a, b );
}
}
new File( basename ).delete();
new File( basename + EFGraph.GRAPH_EXTENSION ).delete();
new File( basename + EFGraph.OFFSETS_EXTENSION ).delete();
new File( basename + EFGraph.PROPERTIES_EXTENSION ).delete();
}
}
}
示例11: setUp
import it.unimi.dsi.fastutil.longs.LongOpenHashSet; //导入方法依赖的package包/类
@BeforeClass
public void setUp()
throws Exception {
FileUtils.deleteQuietly(TEMP_DIR);
IntOpenHashSet intSet = new IntOpenHashSet();
while (intSet.size() < NUM_VALUES) {
intSet.add(RANDOM.nextInt());
}
_intValues = intSet.toIntArray();
Arrays.sort(_intValues);
LongOpenHashSet longSet = new LongOpenHashSet();
while (longSet.size() < NUM_VALUES) {
longSet.add(RANDOM.nextLong());
}
_longValues = longSet.toLongArray();
Arrays.sort(_longValues);
FloatOpenHashSet floatSet = new FloatOpenHashSet();
while (floatSet.size() < NUM_VALUES) {
floatSet.add(RANDOM.nextFloat());
}
_floatValues = floatSet.toFloatArray();
Arrays.sort(_floatValues);
DoubleOpenHashSet doubleSet = new DoubleOpenHashSet();
while (doubleSet.size() < NUM_VALUES) {
doubleSet.add(RANDOM.nextDouble());
}
_doubleValues = doubleSet.toDoubleArray();
Arrays.sort(_doubleValues);
Set<String> stringSet = new HashSet<>();
while (stringSet.size() < NUM_VALUES) {
stringSet.add(RandomStringUtils.random(RANDOM.nextInt(MAX_STRING_LENGTH)).replace('\0', ' '));
}
_stringValues = stringSet.toArray(new String[NUM_VALUES]);
Arrays.sort(_stringValues);
boolean[] isSorted = {true};
SegmentDictionaryCreator dictionaryCreator = new SegmentDictionaryCreator(false, _intValues,
new DimensionFieldSpec(INT_COLUMN_NAME, FieldSpec.DataType.INT, true), TEMP_DIR, '\0');
dictionaryCreator.build(isSorted);
dictionaryCreator = new SegmentDictionaryCreator(false, _longValues,
new DimensionFieldSpec(LONG_COLUMN_NAME, FieldSpec.DataType.LONG, true), TEMP_DIR, '\0');
dictionaryCreator.build(isSorted);
dictionaryCreator = new SegmentDictionaryCreator(false, _floatValues,
new DimensionFieldSpec(FLOAT_COLUMN_NAME, FieldSpec.DataType.FLOAT, true), TEMP_DIR, '\0');
dictionaryCreator.build(isSorted);
dictionaryCreator = new SegmentDictionaryCreator(false, _doubleValues,
new DimensionFieldSpec(DOUBLE_COLUMN_NAME, FieldSpec.DataType.DOUBLE, true), TEMP_DIR, '\0');
dictionaryCreator.build(isSorted);
dictionaryCreator = new SegmentDictionaryCreator(false, _stringValues,
new DimensionFieldSpec(STRING_COLUMN_NAME, FieldSpec.DataType.STRING, true), TEMP_DIR, '\0');
dictionaryCreator.build(isSorted);
_numBytesPerStringValue = dictionaryCreator.getStringColumnMaxLength();
}