Search in sources :

Example 16 with TIntHashSet

use of gnu.trove.TIntHashSet in project intellij-community by JetBrains.

the class IntToIntSetMap method addOccurence.

public void addOccurence(int key, int value) {
    if (mySingle.containsKey(key)) {
        int old = mySingle.get(key);
        TIntHashSet items = new TIntHashSet(3);
        items.add(old);
        items.add(value);
        mySingle.remove(key);
        myMulti.put(key, items);
        return;
    }
    final TIntHashSet items = myMulti.get(key);
    if (items != null) {
        items.add(value);
        return;
    }
    mySingle.put(key, value);
}
Also used : TIntHashSet(gnu.trove.TIntHashSet)

Example 17 with TIntHashSet

use of gnu.trove.TIntHashSet in project intellij-community by JetBrains.

the class IntToIntSetMap method removeOccurence.

public void removeOccurence(int key, int value) {
    if (mySingle.containsKey(key)) {
        mySingle.remove(key);
        return;
    }
    TIntHashSet items = myMulti.get(key);
    if (items != null) {
        items.remove(value);
        if (items.size() == 1) {
            mySingle.put(key, items.toArray()[0]);
            myMulti.remove(key);
        }
    }
}
Also used : TIntHashSet(gnu.trove.TIntHashSet)

Example 18 with TIntHashSet

use of gnu.trove.TIntHashSet in project intellij-community by JetBrains.

the class DefinitionMap method registerDef.

public void registerDef(Instruction varInsn, int varId) {
    TIntHashSet defs = myMap.get(varId);
    if (defs == null) {
        myMap.put(varId, defs = new TIntHashSet());
    } else {
        defs.clear();
    }
    defs.add(varInsn.num());
}
Also used : TIntHashSet(gnu.trove.TIntHashSet)

Example 19 with TIntHashSet

use of gnu.trove.TIntHashSet in project intellij-community by JetBrains.

the class ChangeList method iterChanges.

// todo synchronization issue: changeset may me modified while being iterated
public synchronized Iterable<ChangeSet> iterChanges() {
    return new Iterable<ChangeSet>() {

        public Iterator<ChangeSet> iterator() {
            return new Iterator<ChangeSet>() {

                private final TIntHashSet recursionGuard = new TIntHashSet(1000);

                private ChangeSetHolder currentBlock;

                private ChangeSet next = fetchNext();

                public boolean hasNext() {
                    return next != null;
                }

                public ChangeSet next() {
                    ChangeSet result = next;
                    next = fetchNext();
                    return result;
                }

                private ChangeSet fetchNext() {
                    if (currentBlock == null) {
                        synchronized (ChangeList.this) {
                            if (myCurrentChangeSet != null) {
                                currentBlock = new ChangeSetHolder(-1, myCurrentChangeSet);
                            } else {
                                currentBlock = myStorage.readPrevious(-1, recursionGuard);
                            }
                        }
                    } else {
                        synchronized (ChangeList.this) {
                            currentBlock = myStorage.readPrevious(currentBlock.id, recursionGuard);
                        }
                    }
                    if (currentBlock == null)
                        return null;
                    return currentBlock.changeSet;
                }

                public void remove() {
                    throw new UnsupportedOperationException();
                }
            };
        }
    };
}
Also used : Iterator(java.util.Iterator) ChangeSet(com.intellij.history.core.changes.ChangeSet) TIntHashSet(gnu.trove.TIntHashSet)

Example 20 with TIntHashSet

use of gnu.trove.TIntHashSet in project intellij-community by JetBrains.

the class ChangeListStorageImpl method purge.

public synchronized void purge(long period, int intervalBetweenActivities, Consumer<ChangeSet> processor) {
    if (isCompletelyBroken)
        return;
    TIntHashSet recursionGuard = new TIntHashSet(1000);
    try {
        int firstObsoleteId = findFirstObsoleteBlock(period, intervalBetweenActivities, recursionGuard);
        if (firstObsoleteId == 0)
            return;
        int eachBlockId = firstObsoleteId;
        while (eachBlockId != 0) {
            processor.consume(doReadBlock(eachBlockId).changeSet);
            eachBlockId = doReadPrevSafely(eachBlockId, recursionGuard);
        }
        myStorage.deleteRecordsUpTo(firstObsoleteId);
        myStorage.force();
    } catch (IOException e) {
        handleError(e, null);
    }
}
Also used : IOException(java.io.IOException) TIntHashSet(gnu.trove.TIntHashSet)

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