Class Sets

java.lang.Object
org.elasticsearch.common.util.set.Sets

public final class Sets extends Object
  • Method Details

    • newHashSet

      public static <T> HashSet<T> newHashSet(Iterator<T> iterator)
    • newHashSet

      public static <T> HashSet<T> newHashSet(Iterable<T> iterable)
    • newHashSet

      public static <T> HashSet<T> newHashSet(T... elements)
    • newConcurrentHashSet

      public static <T> Set<T> newConcurrentHashSet()
    • haveEmptyIntersection

      public static <T> boolean haveEmptyIntersection(Set<T> left, Set<T> right)
    • haveNonEmptyIntersection

      public static <T> boolean haveNonEmptyIntersection(Set<T> left, Set<T> right)
    • difference

      public static <T> Set<T> difference(Set<T> left, Set<T> right)
      The relative complement, or difference, of the specified left and right set. Namely, the resulting set contains all the elements that are in the left set but not in the right set. Neither input is mutated by this operation, an entirely new set is returned.
      Type Parameters:
      T - the type of the elements of the sets
      Parameters:
      left - the left set
      right - the right set
      Returns:
      the relative complement of the left set with respect to the right set
    • sortedDifference

      public static <T> SortedSet<T> sortedDifference(Set<T> left, Set<T> right)
      The relative complement, or difference, of the specified left and right set, returned as a sorted set. Namely, the resulting set contains all the elements that are in the left set but not in the right set, and the set is sorted using the natural ordering of element type. Neither input is mutated by this operation, an entirely new set is returned.
      Type Parameters:
      T - the type of the elements of the sets
      Parameters:
      left - the left set
      right - the right set
      Returns:
      the sorted relative complement of the left set with respect to the right set
    • toSortedSet

      public static <T> Collector<T,SortedSet<T>,SortedSet<T>> toSortedSet()
      Returns a Collector that accumulates the input elements into a sorted set.
      Type Parameters:
      T - the type of the input elements
      Returns:
      a sorted set
    • toUnmodifiableSortedSet

      public static <T> Collector<T,SortedSet<T>,SortedSet<T>> toUnmodifiableSortedSet()
      Returns a Collector that accumulates the input elements into a sorted set and finishes the resulting set into an unmodifiable set. The resulting read-only view through the unmodifiable set is a sorted set.
      Type Parameters:
      T - the type of the input elements
      Returns:
      an unmodifiable set where the underlying set is sorted
    • union

      public static <T> Set<T> union(Set<T> left, Set<T> right)
    • intersection

      public static <T> Set<T> intersection(Set<T> set1, Set<T> set2)