本文整理汇总了Java中it.unimi.dsi.fastutil.ints.IntSet类的典型用法代码示例。如果您正苦于以下问题:Java IntSet类的具体用法?Java IntSet怎么用?Java IntSet使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IntSet类属于it.unimi.dsi.fastutil.ints包,在下文中一共展示了IntSet类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: writeSparseTo
import it.unimi.dsi.fastutil.ints.IntSet; //导入依赖的package包/类
public void writeSparseTo(DataOutputStream output) throws IOException {
try {
lock.readLock().lock();
super.writeTo(output);
output.writeUTF(RowType.T_INT_SPARSE.toString());
output.writeInt(nnz);
IntSet keys = sparseRep.keySet();
output.writeInt(keys.size());
for (int key : keys) {
output.writeInt(key);
output.writeInt(sparseRep.get(key));
}
} finally {
lock.readLock().unlock();
}
}
示例2: createLocalsChange
import it.unimi.dsi.fastutil.ints.IntSet; //导入依赖的package包/类
private DebugLocalsChange createLocalsChange(
Int2ReferenceMap<DebugLocalInfo> ending, Int2ReferenceMap<DebugLocalInfo> starting) {
if (ending.isEmpty() && starting.isEmpty()) {
return null;
}
if (ending.isEmpty() || starting.isEmpty()) {
return new DebugLocalsChange(ending, starting);
}
IntSet unneeded = new IntArraySet(Math.min(ending.size(), starting.size()));
for (Entry<DebugLocalInfo> entry : ending.int2ReferenceEntrySet()) {
if (starting.get(entry.getIntKey()) == entry.getValue()) {
unneeded.add(entry.getIntKey());
}
}
if (unneeded.size() == ending.size() && unneeded.size() == starting.size()) {
return null;
}
IntIterator iterator = unneeded.iterator();
while (iterator.hasNext()) {
int key = iterator.nextInt();
ending.remove(key);
starting.remove(key);
}
return new DebugLocalsChange(ending, starting);
}
示例3: hashCode
import it.unimi.dsi.fastutil.ints.IntSet; //导入依赖的package包/类
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
List<IntOpenHashSet> setCluster = this.convertClustersToSets(this.clusters);
Collections.sort(setCluster, new Comparator<IntSet>() {
@Override
public int compare(IntSet o1, IntSet o2) {
return o1.hashCode() - o2.hashCode();
}
});
result = prime * result + (setCluster.hashCode());
return result;
}
示例4: groupAttributesByValue
import it.unimi.dsi.fastutil.ints.IntSet; //导入依赖的package包/类
private Map<String, IntSet> groupAttributesByValue(final IntSet attributes)
throws AlgorithmExecutionException {
final Map<String, IntSet> attributesByValue = new HashMap<>();
for (final int attribute : attributes) {
final Collection<String> values = getValues(attribute);
if (configuration.isProcessEmptyColumns() && values.isEmpty()) {
handleEmptyAttribute(attribute, attributes);
} else {
for (final String value : values) {
attributesByValue.computeIfAbsent(value, k -> new IntOpenHashSet()).add(attribute);
}
}
}
return attributesByValue;
}
示例5: greedySolve
import it.unimi.dsi.fastutil.ints.IntSet; //导入依赖的package包/类
public double greedySolve(Mat mat) {
double sum = 0.0;
IntSet available = new IntRBTreeSet();
for(int i = 0; i < mat.M(); i++) {
available.add(i);
}
for(int i = 0; i < mat.N(); i++) {
double best = Double.NEGATIVE_INFINITY;
for(ME me : mat.row(i)) {
if(available.contains(me.j) && me.v > best) {
best = me.v;
available.remove(me.j);
}
}
sum += Math.max(best, 0.0);
}
return sum;
}
示例6: DepTree
import it.unimi.dsi.fastutil.ints.IntSet; //导入依赖的package包/类
public DepTree(TypedDependency root, Collection<TypedDependency> tds,
List<? extends HasWord> sentence, int[] remapping, IntSet stack) {
this.map = new HashMap<>();
int t = root.dep().index();
node = sentence.get(t - 1).word();
//tag = root.dep().tag();
tag = root.dep().label().tag();
this.idx = remapping[t - 1];
if (!stack.contains(t)) {
IntSet stack2 = new IntRBTreeSet(stack);
stack2.add(t);
for (TypedDependency td : tds) {
if (td.gov().index() == t && td.dep().index() != t) {
map.put(td.reln().getShortName(), new DepTree(td, tds, sentence, remapping, stack2));
}
}
}
}
示例7: replayTrain
import it.unimi.dsi.fastutil.ints.IntSet; //导入依赖的package包/类
private void replayTrain(@Nonnull final ByteBuffer buf) {
final int itemI = buf.getInt();
final int knnSize = buf.getInt();
final Int2ObjectMap<Int2FloatMap> knnItems = new Int2ObjectOpenHashMap<>(1024);
final IntSet pairItems = new IntOpenHashSet();
for (int i = 0; i < knnSize; i++) {
int user = buf.getInt();
int ruSize = buf.getInt();
Int2FloatMap ru = new Int2FloatOpenHashMap(ruSize);
ru.defaultReturnValue(0.f);
for (int j = 0; j < ruSize; j++) {
int itemK = buf.getInt();
pairItems.add(itemK);
float ruk = buf.getFloat();
ru.put(itemK, ruk);
}
knnItems.put(user, ru);
}
for (int itemJ : pairItems) {
train(itemI, knnItems, itemJ);
}
}
示例8: hashCode
import it.unimi.dsi.fastutil.ints.IntSet; //导入依赖的package包/类
@Override
public int hashCode() {
final int prime = 31;
int result = 1;
List<IntOpenHashSet> setCluster = convertClustersToSets(clusters);
Collections.sort(setCluster, new Comparator<IntSet>() {
@Override
public int compare(IntSet o1, IntSet o2) {
return o1.hashCode() - o2.hashCode();
}
});
result = prime * result + (setCluster.hashCode());
return result;
}
示例9: createNewAttribute
import it.unimi.dsi.fastutil.ints.IntSet; //导入依赖的package包/类
public Attribute createNewAttribute(HashMap<String, Attribute> attributes,
String attribute, int noMonths) {
Attribute a = attributes.get(attribute);
int ct = 0;
IntSet keys = a.data.keySet();
IntIterator it = keys.iterator();
ArrayList<SpatioTemporalVal> arr = new ArrayList<SpatioTemporalVal>();
while(ct < noMonths) {
if(!it.hasNext()) {
Utilities.er("no. of months is greater than what is present");
}
int month = it.nextInt();
arr.addAll(a.data.get(month));
ct++;
}
Collections.sort(arr);
Attribute na = new Attribute();
na.data.put(0, arr);
na.nodeSet = a.nodeSet;
return na;
}
示例10: generateRandomKeys
import it.unimi.dsi.fastutil.ints.IntSet; //导入依赖的package包/类
public static KeyTestInfo generateRandomKeys(Random random, int maxNumKeys) {
int maxKeyOrValue = maxNumKeys << 2;
int[] keysAndValues = new int[maxNumKeys * 3];
int[] nonKeys = new int[maxNumKeys];
IntSet keySet = new IntOpenHashBigSet(maxNumKeys);
for (int i = 0; i < maxNumKeys; i++) {
int entry;
do {
entry = random.nextInt(maxKeyOrValue);
} while (keySet.contains(entry));
keysAndValues[i * 3] = entry;
keysAndValues[i * 3 + 1] = random.nextInt(maxKeyOrValue);
keysAndValues[i * 3 + 2] = random.nextInt(maxKeyOrValue);
keySet.add(entry);
}
for (int i = 0; i < maxNumKeys; i++) {
int nonKey;
do {
nonKey = random.nextInt(maxKeyOrValue);
} while (keySet.contains(nonKey));
nonKeys[i] = nonKey;
}
return new KeyTestInfo(keysAndValues, nonKeys);
}
示例11: IntMapGraph
import it.unimi.dsi.fastutil.ints.IntSet; //导入依赖的package包/类
public IntMapGraph(Int2ObjectMap<IntSet> map) {
this.map = map;
if (map.defaultReturnValue() == null || !map.defaultReturnValue().equals(IntSets.EMPTY_SET)) {
LOGGER.warn("It is necessary to set default return value of the map as the empty set.");
map.defaultReturnValue(IntSets.EMPTY_SET);
}
int maxNodeIndex = 0, numArcs = 0;
for (Entry<IntSet> x : map.int2ObjectEntrySet()) {
if (x.getIntKey() > maxNodeIndex)
maxNodeIndex = x.getIntKey();
for (int succ : x.getValue()) {
if (succ > maxNodeIndex)
maxNodeIndex = succ;
numArcs++;
}
}
this.numArcs = numArcs;
this.numNodes = maxNodeIndex+1;
}
示例12: LatentMatrixEstimator
import it.unimi.dsi.fastutil.ints.IntSet; //导入依赖的package包/类
public LatentMatrixEstimator(ImmutableGraph graph, Int2ObjectMap<IntSet> node2cat, String output, Matrix initialMatrix) {
rnd = RandomSingleton.get();
pl = new ProgressLogger(LOGGER, "node couples");
this.graph = graph;
this.node2cat = node2cat;
if (graph.numNodes() != node2cat.size()) {
LOGGER.warn("node2cat file and graph file have a different number of nodes: " +
"respectively, " + node2cat.size() + " and " + graph.numNodes());
}
numNodes = graph.numNodes();
classifier = new PAClassifier(initialMatrix);
this.output = output;
nArcsLearned = 0;
}
示例13: learnNode
import it.unimi.dsi.fastutil.ints.IntSet; //导入依赖的package包/类
protected void learnNode(int node, IntSet successors ) throws IOException {
for (int successor : successors) {
classifier.learn(node2cat.get(node), node2cat.get(successor), true);
anArcHasBeenLearned();
pl.lightUpdate();
}
int nonSucc;
for (int i = successors.size()-1; i >= 0; i--) {
do {
nonSucc = rnd.nextInt(numNodes);
} while (successors.contains(nonSucc));
classifier.learn(node2cat.get(node), node2cat.get(nonSucc), false);
anArcHasBeenLearned();
pl.lightUpdate();
}
}
示例14: createTestingSet
import it.unimi.dsi.fastutil.ints.IntSet; //导入依赖的package包/类
public int[] createTestingSet(int numOfSamples) {
numOfSamples = Math.min(numOfSamples, numNodes);
if (verbose) LOGGER.info("Creating test set with "+numOfSamples+" nodes...");
if (numOfSamples >= (numNodes/2)) {
final Random rnd = RandomSingleton.get();
int[] samples = MathArrays.natural(numNodes);
IntArrays.shuffle(samples, rnd);
return IntArrays.trim(samples, numOfSamples);
} else {
IntSet set = new IntOpenHashSet();
while (set.size() < numOfSamples) {
set.add(rnd.nextInt(numNodes));
}
int[] r = set.toIntArray();
return r;
}
}
示例15: parseCategories
import it.unimi.dsi.fastutil.ints.IntSet; //导入依赖的package包/类
private IntSet parseCategories(Document wikiPage) throws IOException {
String categoryString = IOUtils.toString((Reader) wikiPage.content(CATEGORY_FIELD));
IntSet categoryIds = new IntOpenHashSet();
int pipeIndex;
for (String category : categoryString.split(SEPARATOR_REGEX)) {
if ((pipeIndex = category.indexOf('|')) > -1)
category = category.substring(0, pipeIndex);
category = StringUtils.strip(category);
if (category.length() > 0)
categoryIds.add(getCategoryId(category));
}
return categoryIds;
}