Search in sources :

Example 86 with TIntArrayList

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

the class CutCopyPasteSupport method performPaste.

public void performPaste(@NotNull final DataContext dataContext) {
    final String serializedComponents = getSerializedComponents();
    if (serializedComponents == null) {
        return;
    }
    final ArrayList<RadComponent> componentsToPaste = new ArrayList<>();
    final TIntArrayList xs = new TIntArrayList();
    final TIntArrayList ys = new TIntArrayList();
    loadComponentsToPaste(myEditor, serializedComponents, xs, ys, componentsToPaste);
    myEditor.getMainProcessor().startPasteProcessor(componentsToPaste, xs, ys);
}
Also used : ArrayList(java.util.ArrayList) TIntArrayList(gnu.trove.TIntArrayList) RadComponent(com.intellij.uiDesigner.radComponents.RadComponent) TIntArrayList(gnu.trove.TIntArrayList)

Example 87 with TIntArrayList

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

the class Reindexer method discard.

private int[] discard(int[] needed, int[] toDiscard, int arrayIndex) {
    myOriginalLengths[arrayIndex] = toDiscard.length;
    int[] sorted1 = createSorted(needed);
    TIntArrayList discarded = new TIntArrayList(toDiscard.length);
    TIntArrayList oldIndecies = new TIntArrayList(toDiscard.length);
    for (int i = 0; i < toDiscard.length; i++) {
        int index = toDiscard[i];
        if (Arrays.binarySearch(sorted1, index) >= 0) {
            discarded.add(index);
            oldIndecies.add(i);
        }
    }
    myOldIndecies[arrayIndex] = oldIndecies.toNativeArray();
    myDiscardedLengths[arrayIndex] = discarded.size();
    return discarded.toNativeArray();
}
Also used : TIntArrayList(gnu.trove.TIntArrayList)

Example 88 with TIntArrayList

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

the class CompactStorageTest method testCompactAndIterators.

public void testCompactAndIterators() throws IOException {
    TIntArrayList recordsList = new TIntArrayList();
    // 1000 records after deletion greater than 3M limit for init time compaction
    final int recordCount = 2000;
    for (int i = 0; i < recordCount; ++i) recordsList.add(createTestRecord());
    final int physicalRecordCount = myStorage.getLiveRecordsCount();
    for (int i = 0; i < recordCount / 2; ++i) myStorage.deleteRecord(recordsList.getQuick(i));
    int logicalRecordCount = countLiveLogicalRecords();
    assertEquals(recordCount / 2, logicalRecordCount);
    // compact is triggered
    Disposer.dispose(myStorage);
    myStorage = createStorage(getFileName());
    assertEquals(myStorage.getLiveRecordsCount(), physicalRecordCount / 2);
    logicalRecordCount = 0;
    RecordIdIterator recordIdIterator = myStorage.createRecordIdIterator();
    while (recordIdIterator.hasNextId()) {
        boolean validId = recordIdIterator.validId();
        int nextId = recordIdIterator.nextId();
        if (!validId)
            continue;
        ++logicalRecordCount;
        checkTestRecord(nextId);
    }
    assertEquals(recordCount / 2, logicalRecordCount);
}
Also used : RecordIdIterator(com.intellij.util.io.storage.RecordIdIterator) TIntArrayList(gnu.trove.TIntArrayList)

Example 89 with TIntArrayList

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

the class UsageViewImpl method fireEvents.

// this method is called regularly every 50ms to fire events in batch
private void fireEvents() {
    ApplicationManager.getApplication().assertIsDispatchThread();
    List<Node> insertedUnder;
    synchronized (nodesInsertedUnder) {
        insertedUnder = new ArrayList<>(nodesInsertedUnder);
        nodesInsertedUnder.clear();
    }
    // for each node synchronize its Swing children (javax.swing.tree.DefaultMutableTreeNode.children)
    // and its model children (com.intellij.usages.impl.GroupNode.getChildren())
    // by issuing corresponding javax.swing.tree.DefaultMutableTreeNode.insert() and then javax.swing.tree.DefaultTreeModel.nodesWereInserted()
    TIntArrayList indicesToFire = new TIntArrayList();
    List<Node> nodesToFire = new ArrayList<>();
    for (Node parentNode : insertedUnder) {
        List<Node> swingChildren = ((GroupNode) parentNode).getSwingChildren();
        synchronized (parentNode) {
            List<Node> modelChildren = ((GroupNode) parentNode).getChildren();
            assert modelChildren.size() >= swingChildren.size();
            // index in swingChildren
            int k = 0;
            for (int i = 0; i < modelChildren.size(); i++) {
                Node modelNode = modelChildren.get(i);
                Node swingNode = k >= swingChildren.size() ? null : swingChildren.get(k);
                if (swingNode == modelNode) {
                    k++;
                    continue;
                }
                parentNode.insertNewNode(modelNode, i);
                indicesToFire.add(i);
                nodesToFire.add(modelNode);
                // ignore just inserted node
                if (k == i)
                    k++;
                if (modelNode instanceof UsageNode) {
                    Node parent = (Node) modelNode.getParent();
                    if (parent instanceof GroupNode) {
                        ((GroupNode) parent).incrementUsageCount();
                    }
                }
            }
        }
        myModel.fireTreeNodesInserted(parentNode, myModel.getPathToRoot(parentNode), indicesToFire.toNativeArray(), nodesToFire.toArray(new Node[0]));
        nodesToFire.clear();
        indicesToFire.clear();
    }
    // group nodes from changedNodesToFire by their parents and issue corresponding javax.swing.tree.DefaultTreeModel.fireTreeNodesChanged()
    List<Map.Entry<Node, Collection<Node>>> changed;
    synchronized (changedNodesToFire) {
        changed = new ArrayList<>(changedNodesToFire.entrySet());
        changedNodesToFire.clear();
    }
    for (Map.Entry<Node, Collection<Node>> entry : changed) {
        Node parentNode = entry.getKey();
        Set<Node> childrenToUpdate = new THashSet<>(entry.getValue());
        for (int i = 0; i < parentNode.getChildCount(); i++) {
            Node childNode = (Node) parentNode.getChildAt(i);
            if (childrenToUpdate.contains(childNode)) {
                nodesToFire.add(childNode);
                indicesToFire.add(i);
            }
        }
        myModel.fireTreeNodesChanged(parentNode, myModel.getPathToRoot(parentNode), indicesToFire.toNativeArray(), nodesToFire.toArray(new Node[0]));
        nodesToFire.clear();
        indicesToFire.clear();
    }
}
Also used : TIntArrayList(gnu.trove.TIntArrayList) TIntArrayList(gnu.trove.TIntArrayList) THashSet(gnu.trove.THashSet) MultiMap(com.intellij.util.containers.MultiMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) LinkedMultiMap(com.intellij.util.containers.LinkedMultiMap)

Example 90 with TIntArrayList

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

the class StringSearcher method findAllOccurrences.

@NotNull
public int[] findAllOccurrences(@NotNull CharSequence text) {
    int end = text.length();
    TIntArrayList result = new TIntArrayList();
    for (int index = 0; index < end; index++) {
        //noinspection AssignmentToForLoopParameter
        index = scan(text, index, end);
        if (index < 0)
            break;
        result.add(index);
    }
    return result.toNativeArray();
}
Also used : TIntArrayList(gnu.trove.TIntArrayList) NotNull(org.jetbrains.annotations.NotNull)

Aggregations

TIntArrayList (gnu.trove.TIntArrayList)104 NotNull (org.jetbrains.annotations.NotNull)34 ArrayList (java.util.ArrayList)9 List (java.util.List)7 Nullable (org.jetbrains.annotations.Nullable)7 VirtualFile (com.intellij.openapi.vfs.VirtualFile)4 ArrangementMatchingRulesControl (com.intellij.application.options.codeStyle.arrangement.match.ArrangementMatchingRulesControl)3 StringSearcher (com.intellij.util.text.StringSearcher)3 TIntHashSet (gnu.trove.TIntHashSet)3 TIntProcedure (gnu.trove.TIntProcedure)3 IOException (java.io.IOException)3 IDevice (com.android.ddmlib.IDevice)2 ArrangementMatchingRulesModel (com.intellij.application.options.codeStyle.arrangement.match.ArrangementMatchingRulesModel)2 FileChooserDescriptor (com.intellij.openapi.fileChooser.FileChooserDescriptor)2 Project (com.intellij.openapi.project.Project)2 TextRange (com.intellij.openapi.util.TextRange)2 ElementToWorkOn (com.intellij.refactoring.introduceField.ElementToWorkOn)2 IntroduceParameterProcessor (com.intellij.refactoring.introduceParameter.IntroduceParameterProcessor)2 RelativePoint (com.intellij.ui.awt.RelativePoint)2 RadComponent (com.intellij.uiDesigner.radComponents.RadComponent)2