Java Code Examples for com.intellij.util.containers.ContainerUtil#groupAndRuns()

The following examples show how to use com.intellij.util.containers.ContainerUtil#groupAndRuns() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: PsiVFSListener.java    From consulo with Apache License 2.0 5 votes vote down vote up
private void groupAndFire(@Nonnull List<? extends VFileEvent> events) {
  // group several VFileDeleteEvents together, several VFileMoveEvents together, place all other events into one-element lists

  BiPredicate<VFileEvent, VFileEvent> check =
          (event1, event2) -> event1 instanceof VFileDeleteEvent && event2 instanceof VFileDeleteEvent || event1 instanceof VFileMoveEvent && event2 instanceof VFileMoveEvent;

  ContainerUtil.groupAndRuns(events, check, it -> fireForGrouped(it));
}
 
Example 2
Source File: GotoFileItemProvider.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static <T> List<List<T>> sortAndGroup(@Nonnull List<T> items, @Nonnull Comparator<? super T> comparator) {
  List<T> sorted = new ArrayList<T>(items);
  sorted.sort(comparator);

  List result = new ArrayList<>();
  ContainerUtil.groupAndRuns(sorted, (n1, n2) -> comparator.compare(n1, n2) == 0, ts -> result.add(ts));
  return result;
}