mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
vcs: Replaced "CollectionSplitter" usages with "JBIterable.partition()"
Marked "CollectionSplitter" as deprecated.
This commit is contained in:
@@ -1,7 +1,16 @@
|
||||
package com.intellij.openapi.vcs;
|
||||
|
||||
import java.util.*;
|
||||
import com.intellij.util.containers.JBIterable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @deprecated Use {@link JBIterable#from(Iterable)} and {@link JBIterable#partition(int, boolean)} directly.
|
||||
*/
|
||||
@SuppressWarnings("unused") // Required for compatibility with external plugins.
|
||||
@Deprecated
|
||||
public class CollectionSplitter<T> {
|
||||
private final int myBunchSize;
|
||||
|
||||
@@ -9,21 +18,8 @@ public class CollectionSplitter<T> {
|
||||
myBunchSize = bunchSize;
|
||||
}
|
||||
|
||||
public List<List<T>> split(final Collection<T> in) {
|
||||
if (in.size() <= myBunchSize) return Collections.<List<T>>singletonList(new ArrayList<>(in));
|
||||
|
||||
final List<List<T>> result = new LinkedList<>();
|
||||
List<T> piece = new LinkedList<>();
|
||||
for (T path : in) {
|
||||
if (myBunchSize == piece.size()) {
|
||||
result.add(piece);
|
||||
piece = new LinkedList<>();
|
||||
}
|
||||
piece.add(path);
|
||||
}
|
||||
if (! piece.isEmpty()) {
|
||||
result.add(piece);
|
||||
}
|
||||
return result;
|
||||
@NotNull
|
||||
public List<List<T>> split(@NotNull Collection<T> in) {
|
||||
return JBIterable.from(in).partition(myBunchSize, false).toList();
|
||||
}
|
||||
}
|
||||
|
||||
+6
-3
@@ -20,7 +20,10 @@ import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.util.io.BufferExposingByteArrayOutputStream;
|
||||
import com.intellij.openapi.util.io.FileUtil;
|
||||
import com.intellij.openapi.util.text.StringUtil;
|
||||
import com.intellij.openapi.vcs.*;
|
||||
import com.intellij.openapi.vcs.AbstractVcs;
|
||||
import com.intellij.openapi.vcs.CachingCommittedChangesProvider;
|
||||
import com.intellij.openapi.vcs.RepositoryLocation;
|
||||
import com.intellij.openapi.vcs.VcsException;
|
||||
import com.intellij.openapi.vcs.changes.Change;
|
||||
import com.intellij.openapi.vcs.changes.ContentRevision;
|
||||
import com.intellij.openapi.vcs.changes.committed.ReceivedChangeList;
|
||||
@@ -28,6 +31,7 @@ import com.intellij.openapi.vcs.versionBrowser.CommittedChangeList;
|
||||
import com.intellij.util.ThrowableConsumer;
|
||||
import com.intellij.util.ThrowableConvertor;
|
||||
import com.intellij.util.ThrowableRunnable;
|
||||
import com.intellij.util.containers.JBIterable;
|
||||
import com.intellij.util.containers.MultiMap;
|
||||
import com.intellij.util.io.DataOutputStream;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
@@ -297,9 +301,8 @@ public class VcsSqliteLayer {
|
||||
final RevisionId lastRevData = myKnownRepositoryLocations.getLastRevision(locationId);
|
||||
final Long lastRevision = lastRevData == null ? null : lastRevData.getNumber();
|
||||
|
||||
final List<List<CommittedChangeList>> split = new CollectionSplitter<CommittedChangeList>(20).split(lists);
|
||||
final Map<String, Long> knowPaths = new HashMap<>();
|
||||
for (List<CommittedChangeList> changeLists : split) {
|
||||
for (List<CommittedChangeList> changeLists : JBIterable.from(lists).partition(20, false)) {
|
||||
final Set<String> names = new HashSet<>();
|
||||
final Set<String> paths = new HashSet<>();
|
||||
for (Iterator<CommittedChangeList> iterator = changeLists.iterator(); iterator.hasNext(); ) {
|
||||
|
||||
@@ -15,17 +15,17 @@
|
||||
*/
|
||||
package org.jetbrains.idea.svn.dialogs;
|
||||
|
||||
import com.intellij.openapi.vcs.CollectionSplitter;
|
||||
import com.intellij.util.containers.JBIterable;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BasePageEngine<T> implements PageEngine<List<T>> {
|
||||
private List<List<T>> mySplitData;
|
||||
@NotNull private final List<List<T>> mySplitData;
|
||||
private int myIdx;
|
||||
|
||||
public BasePageEngine(final List<T> data, final int pageSize) {
|
||||
final CollectionSplitter<T> splitter = new CollectionSplitter<>(pageSize);
|
||||
mySplitData = splitter.split(data);
|
||||
public BasePageEngine(@NotNull List<T> data, int pageSize) {
|
||||
mySplitData = JBIterable.from(data).partition(pageSize, false).toList();
|
||||
myIdx = 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user