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);
}
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();
}
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);
}
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();
}
}
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();
}
Aggregations