本文整理汇总了Java中it.unimi.dsi.fastutil.ints.IntSet.add方法的典型用法代码示例。如果您正苦于以下问题:Java IntSet.add方法的具体用法?Java IntSet.add怎么用?Java IntSet.add使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类it.unimi.dsi.fastutil.ints.IntSet
的用法示例。
在下文中一共展示了IntSet.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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;
}
示例3: 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));
}
}
}
}
示例4: 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);
}
}
示例5: 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);
}
示例6: 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;
}
}
示例7: 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;
}
示例8: removeIfNotOneRelevantAndOneIrrelevant
import it.unimi.dsi.fastutil.ints.IntSet; //导入方法依赖的package包/类
public void removeIfNotOneRelevantAndOneIrrelevant() {
IntSet queriesToRemove = new IntOpenHashSet();
for (int query : queries()) {
int nEval = query2evaluateddocs.get(query).size();
int nRelev = query2relevantdocs.get(query).size();
int nIrrelev = nEval - nRelev;
if (nRelev < 1 || nIrrelev < 1)
queriesToRemove.add(query);
}
int originalNQueries = queries().size();
for (int q : queriesToRemove) {
query2doc2relevance.remove(q);
query2evaluateddocs.remove(q);
query2relevantdocs.remove(q);
}
LOGGER.info(queriesToRemove.size() + " queries were without "
+ "relevant or irrilevant results and were removed. "
+ "Number of queries went from " + originalNQueries
+ " to " + queries().size() + ".");
}
示例9: compute
import it.unimi.dsi.fastutil.ints.IntSet; //导入方法依赖的package包/类
public void compute() {
ProgressLogger pl = new ProgressLogger(LOGGER, "pages");
pl.expectedUpdates = page2cat.size();
pl.start("Moving old categories to closest milestones...");
for (IntSet entry : page2cat.values()) {
IntSet newCategories = new IntOpenHashSet();
int milestone;
for (int cat : entry) {
milestone = closestMilestones[cat];
if (milestone != -1)
newCategories.add(milestone);
}
entry.clear();
entry.addAll(newCategories);
pl.lightUpdate();
}
pl.done();
}
示例10: mergeAndDedup
import it.unimi.dsi.fastutil.ints.IntSet; //导入方法依赖的package包/类
/**
* Baseline implementation. Augments the "standard" list with alternatives.
*
* @param l1
* @param l2
* @return
*/
public static <TK,FV> List<RichTranslation<TK,FV>> mergeAndDedup(List<RichTranslation<TK,FV>> standard,
List<RichTranslation<TK,FV>> alt, int maxAltItems) {
IntSet hashCodeSet = new IntOpenHashSet(standard.size());
for (RichTranslation<TK,FV> s : standard) {
hashCodeSet.add(derivationHashCode(s.getFeaturizable().derivation));
}
List<RichTranslation<TK,FV>> returnList = new ArrayList<>(standard);
for (int i = 0, sz = Math.min(maxAltItems, alt.size()); i < sz; ++i) {
RichTranslation<TK,FV> t = alt.get(i);
int hashCode = derivationHashCode(t.getFeaturizable().derivation);
if (! hashCodeSet.contains(hashCode)) returnList.add(t);
}
Collections.sort(returnList);
return returnList;
}
示例11: collectEntry
import it.unimi.dsi.fastutil.ints.IntSet; //导入方法依赖的package包/类
/**
* Collect statistics for the given entry.
* - Add it to the passed in set (which could be raw or aggregated)
* - Update maximum number of values for Multi-valued entries
* - Update Total number of entries
* - Check if entry is sorted.
* @param entry
* @param set
*/
private void collectEntry(Object entry, IntSet set) {
if (entry instanceof Object[]) {
for (Object e : (Object[]) entry) {
set.add(((Number) e).intValue());
}
if (maxNumberOfMultiValues < ((Object[]) entry).length) {
maxNumberOfMultiValues = ((Object[]) entry).length;
}
updateTotalNumberOfEntries((Object[]) entry);
} else {
int value = ((Number) entry).intValue();
addressSorted(value);
updatePartition(value);
set.add(value);
totalNumberOfEntries++;
}
}
示例12: calcRandomHits
import it.unimi.dsi.fastutil.ints.IntSet; //导入方法依赖的package包/类
int calcRandomHits(int _size, int _seed) {
IntSet _cache = new IntOpenHashSet();
IntList _list = new IntArrayList();
Random _random = new Random(_seed);
int _hitCnt = 0;
for (int v : getTrace()) {
if(_cache.contains(v)) {
_hitCnt++;
} else {
if (_cache.size() == _size) {
int cnt = _random.nextInt(_cache.size());
_cache.remove(_list.get(cnt));
_list.remove(cnt);
}
_cache.add(v);
_list.add(v);
}
}
return _hitCnt;
}
示例13: allIds
import it.unimi.dsi.fastutil.ints.IntSet; //导入方法依赖的package包/类
private IntSet allIds() {
final IntSet ids = new IntOpenHashSet(attributeIndex.length);
for (int index = 0; index < attributeIndex.length; ++index) {
ids.add(index);
}
return ids;
}
示例14: buildInputDataPartitionSchema
import it.unimi.dsi.fastutil.ints.IntSet; //导入方法依赖的package包/类
private String buildInputDataPartitionSchema(List<JCL_result> r, int numOfJCLThreads){
IntSet sorted = new IntAVLTreeSet();
long totalF=0;
Int2LongMap map = new Int2LongOpenHashMap();
for(JCL_result oneR:r){
try{
@SuppressWarnings("unchecked")
List<String> l = (List<String>) oneR.getCorrectResult();
for(String s : l){
String[] args = s.split(":");
int key = Integer.parseInt(args[0]); long freq = Long.parseLong(args[1]);
sorted.add(key);
if(map.containsKey(key)){
freq+=map.get(key);
totalF+=map.get(key);
} else totalF+=freq;
map.put(key, freq);
}
}catch(Exception e){}
}
long load=0; int b; String result = "";
for(int ac:sorted){
load += map.get(ac);
if(load > (totalF/(numOfJCLThreads))){
b=ac;
result += b + ":";
load=0;
}
}
return result;
}
示例15: countUnique
import it.unimi.dsi.fastutil.ints.IntSet; //导入方法依赖的package包/类
@Override
public int countUnique() {
IntSet ints = new IntOpenHashSet(size());
for (int i = 0; i < size(); i++) {
ints.add(data.getInt(i));
}
return ints.size();
}