use of gnu.trove.TIntHashSet in project intellij-community by JetBrains.
the class IntIntMultiMaplet method toStream.
public void toStream(final DependencyContext context, final PrintStream stream) {
final OrderProvider op = new OrderProvider(context);
forEachEntry(new TIntObjectProcedure<TIntHashSet>() {
@Override
public boolean execute(final int a, final TIntHashSet b) {
op.register(a);
return true;
}
});
final int[] keys = op.get();
for (final int a : keys) {
final TIntHashSet b = get(a);
stream.print(" Key: ");
stream.println(context.getValue(a));
stream.println(" Values:");
final List<String> list = new LinkedList<>();
b.forEach(value -> {
list.add(context.getValue(value));
return true;
});
Collections.sort(list);
for (final String l : list) {
stream.print(" ");
stream.println(l);
}
stream.println(" End Of Values");
}
}
use of gnu.trove.TIntHashSet in project intellij-community by JetBrains.
the class IntIntTransientMultiMaplet method put.
@Override
public void put(final int key, final int value) {
final TIntHashSet collection = myMap.get(key);
if (collection == null) {
final TIntHashSet x = new TIntHashSet();
x.add(value);
myMap.put(key, x);
} else {
collection.add(value);
}
}
use of gnu.trove.TIntHashSet in project intellij-community by JetBrains.
the class VfsData method killInvalidatedFiles.
private static void killInvalidatedFiles() {
synchronized (ourDeadMarker) {
if (!ourDyingIds.isEmpty()) {
for (int id : ourDyingIds.toArray()) {
assertNotNull(getSegment(id, false)).myObjectArray.set(getOffset(id), ourDeadMarker);
ourChangedParents.remove(id);
}
ourDyingIds = new TIntHashSet();
}
}
}
use of gnu.trove.TIntHashSet in project intellij-community by JetBrains.
the class PatternCompiler method checkErrorElements.
/**
* False: there are no error elements before offset, except patternEndOffset
* Null: there are only error elements located exactly after template variables or at the end of the pattern
* True: otherwise
*/
@Nullable
private static Boolean checkErrorElements(PsiElement element, final int offset, final int patternEndOffset, final int[] varEndOffsets, final boolean strict) {
final TIntArrayList errorOffsets = new TIntArrayList();
final boolean[] containsErrorTail = { false };
final TIntHashSet varEndOffsetsSet = new TIntHashSet(varEndOffsets);
element.accept(new PsiRecursiveElementWalkingVisitor() {
@Override
public void visitErrorElement(PsiErrorElement element) {
super.visitErrorElement(element);
final int startOffset = element.getTextRange().getStartOffset();
if ((strict || !varEndOffsetsSet.contains(startOffset)) && startOffset != patternEndOffset) {
errorOffsets.add(startOffset);
}
if (startOffset == offset) {
containsErrorTail[0] = true;
}
}
});
for (int i = 0; i < errorOffsets.size(); i++) {
final int errorOffset = errorOffsets.get(i);
if (errorOffset <= offset) {
return true;
}
}
return containsErrorTail[0] ? null : false;
}
use of gnu.trove.TIntHashSet in project intellij-community by JetBrains.
the class InvertedIndexUtil method collectInputIdsContainingAllKeys.
@NotNull
public static <K, V, I> TIntHashSet collectInputIdsContainingAllKeys(@NotNull InvertedIndex<K, V, I> index, @NotNull Collection<K> dataKeys, @Nullable Condition<K> keyChecker, @Nullable Condition<V> valueChecker, @Nullable ValueContainer.IntPredicate idChecker) throws StorageException {
TIntHashSet mainIntersection = null;
for (K dataKey : dataKeys) {
if (keyChecker != null && !keyChecker.value(dataKey))
continue;
final TIntHashSet copy = new TIntHashSet();
final ValueContainer<V> container = index.getData(dataKey);
for (ValueContainer.ValueIterator<V> valueIt = container.getValueIterator(); valueIt.hasNext(); ) {
final V value = valueIt.next();
if (valueChecker != null && !valueChecker.value(value)) {
continue;
}
ValueContainer.IntIterator iterator = valueIt.getInputIdsIterator();
final ValueContainer.IntPredicate predicate;
if (mainIntersection == null || iterator.size() < mainIntersection.size() || (predicate = valueIt.getValueAssociationPredicate()) == null) {
while (iterator.hasNext()) {
final int id = iterator.next();
if (mainIntersection == null && (idChecker == null || idChecker.contains(id)) || mainIntersection != null && mainIntersection.contains(id)) {
copy.add(id);
}
}
} else {
mainIntersection.forEach(new TIntProcedure() {
@Override
public boolean execute(int id) {
if (predicate.contains(id))
copy.add(id);
return true;
}
});
}
}
mainIntersection = copy;
if (mainIntersection.isEmpty()) {
return EmptyIntHashSet.INSTANCE;
}
}
return mainIntersection == null ? EmptyIntHashSet.INSTANCE : mainIntersection;
}
Aggregations