Search in sources :

Example 11 with TIntHashSet

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");
    }
}
Also used : TIntHashSet(gnu.trove.TIntHashSet) LinkedList(java.util.LinkedList)

Example 12 with TIntHashSet

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);
    }
}
Also used : TIntHashSet(gnu.trove.TIntHashSet)

Example 13 with TIntHashSet

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();
        }
    }
}
Also used : TIntHashSet(gnu.trove.TIntHashSet)

Example 14 with 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;
}
Also used : TIntArrayList(gnu.trove.TIntArrayList) TIntHashSet(gnu.trove.TIntHashSet) Nullable(org.jetbrains.annotations.Nullable)

Example 15 with TIntHashSet

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;
}
Also used : TIntProcedure(gnu.trove.TIntProcedure) TIntHashSet(gnu.trove.TIntHashSet) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

TIntHashSet (gnu.trove.TIntHashSet)50 NotNull (org.jetbrains.annotations.NotNull)16 TIntArrayList (gnu.trove.TIntArrayList)5 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 IOException (java.io.IOException)4 Nullable (org.jetbrains.annotations.Nullable)4 TIntProcedure (gnu.trove.TIntProcedure)3 ArrayList (java.util.ArrayList)3 ProgressIndicator (com.intellij.openapi.progress.ProgressIndicator)2 Processor (com.intellij.util.Processor)2 StorageException (com.intellij.util.indexing.StorageException)2 CharArrayCharSequence (com.intellij.util.text.CharArrayCharSequence)2 THashSet (gnu.trove.THashSet)2 TIntIterator (gnu.trove.TIntIterator)2 LightRef (org.jetbrains.jps.backwardRefs.LightRef)2 GenerateMembersUtil (com.intellij.codeInsight.generation.GenerateMembersUtil)1 Edge (com.intellij.codeInspection.bytecodeAnalysis.asm.ControlFlowGraph.Edge)1 CompilerReferenceFindUsagesTestInfo (com.intellij.compiler.backwardRefs.view.CompilerReferenceFindUsagesTestInfo)1 DirtyScopeTestInfo (com.intellij.compiler.backwardRefs.view.DirtyScopeTestInfo)1 PluginException (com.intellij.diagnostic.PluginException)1