本文整理汇总了Java中gnu.trove.set.hash.THashSet类的典型用法代码示例。如果您正苦于以下问题:Java THashSet类的具体用法?Java THashSet怎么用?Java THashSet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
THashSet类属于gnu.trove.set.hash包,在下文中一共展示了THashSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addPartition
import gnu.trove.set.hash.THashSet; //导入依赖的package包/类
public void addPartition(EquivalenceManagedPartition partition) {
if (!this.observedPartitions.contains(partition.getIndices()) && !this.containsSimilarPartition(partition)) {
this.observedPartitions.add(partition.getIndices());
long hashNumber = partition.getHashNumber();
System.out.println(String.format("Partition[%s]\t%d\tSize: %d", partition.getIndices(), hashNumber, partition.size()));
partitionHashes.putIfAbsent(hashNumber, new TIntObjectHashMap<THashSet<EquivalenceManagedPartition>>());
partitionHashes.get(hashNumber).putIfAbsent(partition.size(), new THashSet<EquivalenceManagedPartition>());
THashSet<EquivalenceManagedPartition> partitionGroup = partitionHashes.get(hashNumber).get(partition.size());
if (partitionGroup.isEmpty()) {
partitionGroup.add(partition);
} else {
// then there is at least one element in the partitionGroup
checkPossibleEquivalences(partitionGroup, partition);
}
}
}
示例2: troveThashSetIteratorIsScalarized
import gnu.trove.set.hash.THashSet; //导入依赖的package包/类
@Test
public void troveThashSetIteratorIsScalarized() throws Exception {
final Collection<Integer> thashSet = new THashSet<>();
for( int i = 0; i < SIZE; i++ ) {
thashSet.add( i );
}
assertThat(
new Scenario() {
@Override
public long run() {
return summarize( thashSet );
}
},
finallyAllocatesNothing()
);
}
示例3: testReusesRemovedSlotsOnCollision
import gnu.trove.set.hash.THashSet; //导入依赖的package包/类
public void testReusesRemovedSlotsOnCollision() {
THashSet<Object> set = new THashSet<Object>( 11, 0.5f );
class Foo {
@Override
public int hashCode() {
return 4;
}
}
Foo f1 = new Foo();
Foo f2 = new Foo();
Foo f3 = new Foo();
set.add( f1 );
int idx = set.insertionIndex( f2 );
set.add( f2 );
assertEquals( f2, set._set[idx] );
set.remove( f2 );
assertEquals( THashSet.REMOVED, set._set[idx] );
assertEquals( idx, set.insertionIndex( f3 ) );
set.add( f3 );
assertEquals( f3, set._set[idx] );
}
示例4: InterpolatedTSV
import gnu.trove.set.hash.THashSet; //导入依赖的package包/类
public InterpolatedTSV(
GroupName group,
Map<MetricName, MetricValue> backward,
Map<MetricName, MetricValue> forward,
double backWeight,
double forwWeight) {
this.group = group;
this.backward = backward;
this.forward = forward;
this.backWeight = backWeight;
this.forwWeight = forwWeight;
// Compute the intersection of metric names.
final Set<MetricName> names = new THashSet<>(backward.keySet());
names.retainAll(forward.keySet());
this.metrics = unmodifiableMap(new LazyMap<>(key -> interpolate(backward.get(key), forward.get(key)), names));
}
示例5: getSlicesInRange
import gnu.trove.set.hash.THashSet; //导入依赖的package包/类
static Set<IDimensionSlice> getSlicesInRange(World w, int lx, int ly, int lz, int hx, int hy, int hz) {
THashSet<IDimensionSlice> found_deltachunks = new THashSet<IDimensionSlice>(10);
DeltaChunkMap map = DeltaChunk.getSlices(w); // NORELEASE: This guy keeps hold of dead DSEs? Such as after save reload.
IDimensionSlice last_found = null;
for (int x = lx; x <= hx; x += 16) {
for (int z = lz; z <= hz; z += 16) {
IDimensionSlice new_idcs[] = map.get(x/16, z/16);
for (IDimensionSlice idc : new_idcs) {
if (idc == last_found) continue;
found_deltachunks.add(idc);
last_found = idc;
}
}
}
return found_deltachunks;
}
示例6: testReusesRemovedSlotsOnCollision
import gnu.trove.set.hash.THashSet; //导入依赖的package包/类
public void testReusesRemovedSlotsOnCollision() {
THashSet<Object> set = new THashSet<Object>( 11, 0.5f );
class Foo {
public int hashCode() {
return 4;
}
}
Foo f1 = new Foo();
Foo f2 = new Foo();
Foo f3 = new Foo();
set.add( f1 );
int idx = set.insertionIndex( f2 );
set.add( f2 );
assertEquals( f2, set._set[idx] );
set.remove( f2 );
assertEquals( THashSet.REMOVED, set._set[idx] );
assertEquals( idx, set.insertionIndex( f3 ) );
set.add( f3 );
assertEquals( f3, set._set[idx] );
}
示例7: insertCandidateAtPosition
import gnu.trove.set.hash.THashSet; //导入依赖的package包/类
/**
* Make sure that concurring reads get associated with a unique candidate.
* We should *not* insert candidates directly into candidateSequences.
* Get interning as a small, beneficial side effect.
* @param candidate
* @param location
* @return
*/
private @NonNull CandidateSequence insertCandidateAtPosition(@NonNull CandidateSequence candidate,
@NonNull SequenceLocation location) {
//No need for synchronization since we should not be
//concurrently inserting two candidates at the same position
THashSet<CandidateSequence> candidates = candidateSequences.computeIfAbsent(location, k -> new THashSet<>(2, 0.2f));
CandidateSequence candidateMapValue = candidates.get(candidate);
if (candidateMapValue == null) {
boolean added = candidates.add(candidate);
Assert.isTrue(added);
} else {
candidateMapValue.mergeWith(candidate);
candidate = candidateMapValue;
}
return candidate;
}
示例8: removeRedundantSubClassAxioms
import gnu.trove.set.hash.THashSet; //导入依赖的package包/类
/**
* Remove the redundant and marked as inferred super class assertions for
* each class in the ontology signature. Uses the reasoner to infer the
* direct super classes.
*
* @param ontology
* @param reasoner
* @return map of class to set of redundant axioms
*/
public static Map<OWLClass, Set<RedundantAxiom>> removeRedundantSubClassAxioms(OWLOntology ontology, OWLReasoner reasoner) {
Iterable<OWLClass> classes = ontology.getClassesInSignature();
Map<OWLClass, Set<RedundantAxiom>> axioms = findRedundantSubClassAxioms(classes, ontology, reasoner);
if (!axioms.isEmpty()) {
Set<OWLSubClassOfAxiom> allAxioms = new THashSet<OWLSubClassOfAxiom>();
for(OWLClass cls : axioms.keySet()) {
for(RedundantAxiom redundantAxiom : axioms.get(cls)) {
allAxioms.add(redundantAxiom.getAxiom());
}
}
OWLOntologyManager manager = ontology.getOWLOntologyManager();
manager.removeAxioms(ontology, allAxioms);
LOG.info("Removed "+axioms.size()+" redundant axioms.");
}
return axioms;
}
示例9: getNeighborsOf
import gnu.trove.set.hash.THashSet; //导入依赖的package包/类
@Override
public Collection<IAgent> getNeighborsOf(final IScope scope, final IShape source, final Double distance,
final IAgentFilter filter) throws GamaRuntimeException {
if (!isTorus()) { return getSpatialIndex().allAtDistance(scope, source, distance, filter); }
// FOR TORUS ENVIRONMENTS ONLY
final Geometry g0 = returnToroidalGeom(source.getGeometry());
final Set<IAgent> agents = new THashSet<IAgent>();
final Map<Geometry, IAgent> agentsMap = getTororoidalAgents(scope, filter);
final IAgent sourceAgent = source.getAgent();
for (final Geometry g1 : agentsMap.keySet()) {
final IAgent ag = agentsMap.get(g1);
if (sourceAgent != null && ag == sourceAgent) {
continue;
}
final double dist = g0.distance(g1);
if (dist <= distance) {
agents.add(ag);
}
}
return agents;
}
示例10: getNeighborsOfRec
import gnu.trove.set.hash.THashSet; //导入依赖的package包/类
public Set<IShape> getNeighborsOfRec(final IScope scope, final IShape currentSource, final boolean edge,
final double currentDist, final ISpatialGraph graph, final Set<IShape> alr) throws GamaRuntimeException {
final Set<IShape> edges = new THashSet<IShape>();
final Set<IShape> eds =
graph.isDirected() ? graph.outgoingEdgesOf(currentSource) : graph.edgesOf(currentSource);
if (!edge)
edges.add(currentSource.getAgent());
for (final IShape ed : eds) {
if (alr.contains(ed))
continue;
alr.add(ed);
final double dist = getPlaces().getEdgeWeight(ed);
if (edge)
edges.add(ed);
if (currentDist - dist > 0) {
IShape nextNode = null;
if (graph.isDirected())
nextNode = graph.getEdgeTarget(ed);
else
nextNode = currentSource == graph.getEdgeTarget(ed) ? graph.getEdgeSource(ed)
: graph.getEdgeTarget(ed);
edges.addAll(getNeighborsOfRec(scope, nextNode, edge, currentDist - dist, graph, alr));
}
}
return edges;
}
示例11: crossOver
import gnu.trove.set.hash.THashSet; //导入依赖的package包/类
@Override
public Set<Chromosome> crossOver(final IScope scope, final Chromosome parent1, final Chromosome parent2) {
final Set<Chromosome> children = new THashSet<Chromosome>();
final int nbGenes = parent2.getGenes().length;
if ( nbGenes == 1 ) { return children; }
int cutPt = 0;
if ( nbGenes > 2 ) {
cutPt = scope.getRandom().between(0, nbGenes - 2);
}
final Chromosome child1 = new Chromosome(parent1);
final Chromosome child2 = new Chromosome(parent2);
for ( int i = 0; i < cutPt; i++ ) {
final double val1 = child1.getGenes()[i];
child1.getGenes()[i] = child2.getGenes()[i];
child2.getGenes()[i] = val1;
}
children.add(child1);
children.add(child2);
return children;
}
示例12: getStrings
import gnu.trove.set.hash.THashSet; //导入依赖的package包/类
@Override
public Set<String> getStrings(final IDescription context, final boolean skills) {
// Assuming of the form [aaa, bbb]
final Set<String> result = new THashSet<>();
final StringBuilder b = new StringBuilder();
for (final char c : value.toCharArray()) {
switch (c) {
case '[':
case ' ':
break;
case ']':
case ',': {
result.add(b.toString());
b.setLength(0);
break;
}
default:
b.append(c);
}
}
return result;
}
示例13: getStrings
import gnu.trove.set.hash.THashSet; //导入依赖的package包/类
@Override
public Set<String> getStrings(final IDescription context, final boolean skills) {
// Assuming of the form [aaa, bbb]
final Set<String> result = new THashSet<>();
final StringBuilder b = new StringBuilder();
for (final char c : string.toCharArray()) {
switch (c) {
case '[':
case ' ':
break;
case ']':
case ',': {
result.add(b.toString());
b.setLength(0);
break;
}
default:
b.append(c);
}
}
return result;
}
示例14: initResources
import gnu.trove.set.hash.THashSet; //导入依赖的package包/类
static void initResources() {
eType = GamlPackage.eINSTANCE.getTypeDefinition();
eVar = GamlPackage.eINSTANCE.getVarDefinition();
eSkill = GamlPackage.eINSTANCE.getSkillFakeDefinition();
eAction = GamlPackage.eINSTANCE.getActionDefinition();
eUnit = GamlPackage.eINSTANCE.getUnitFakeDefinition();
eEquation = GamlPackage.eINSTANCE.getEquationDefinition();
resources = new THashMap<>();
resources.put(eType, createResource("types.xmi"));
resources.put(eVar, createResource("vars.xmi"));
resources.put(eSkill, createResource("skills.xmi"));
resources.put(eUnit, createResource("units.xmi"));
resources.put(eAction, createResource("actions.xmi"));
resources.put(eEquation, createResource("equations.xmi"));
descriptions = new THashMap<>();
descriptions.put(eVar, new THashMap<>());
descriptions.put(eType, new THashMap<>());
descriptions.put(eSkill, new THashMap<>());
descriptions.put(eUnit, new THashMap<>());
descriptions.put(eAction, new THashMap<>());
descriptions.put(eEquation, new THashMap<>());
allNames = new THashSet<>();
}
示例15: removeFromVariableCaches
import gnu.trove.set.hash.THashSet; //导入依赖的package包/类
private void removeFromVariableCaches (Variable victim)
{
Set survivors = new THashSet(variablesSet ());
survivors.remove (victim);
int vi = 0;
TIntIntHashMap dict = new TIntIntHashMap (survivors.size ());
// dict.setDefaultValue (-1); No longer supported, but this.getIndex() written to avoid need for this.
my2global = new int[survivors.size ()];
for (Iterator it = survivors.iterator (); it.hasNext();) {
Variable var = (Variable) it.next ();
int gvi = var.getIndex ();
dict.put (gvi, vi);
my2global [vi] = gvi;
}
projectionMap = dict;
numNodes--; // do this at end b/c it affects getVertexSet()
}