Class CollectionUtils.SetOperationCardinalityHelper<O>

  • Type Parameters:
    O - the element type
    All Implemented Interfaces:
    java.lang.Iterable<O>
    Enclosing class:
    CollectionUtils

    private static class CollectionUtils.SetOperationCardinalityHelper<O>
    extends CollectionUtils.CardinalityHelper<O>
    implements java.lang.Iterable<O>
    Helper class for set-related operations, e.g. union, subtract, intersection.
    • Constructor Summary

      Constructors 
      Constructor Description
      SetOperationCardinalityHelper​(java.lang.Iterable<? extends O> a, java.lang.Iterable<? extends O> b)
      Create a new set operation helper from the two collections.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.util.Iterator<O> iterator()  
      java.util.Collection<O> list()
      Returns the resulting collection.
      void setCardinality​(O obj, int count)
      Add the object count times to the result collection.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
      • Methods inherited from interface java.lang.Iterable

        forEach, spliterator
    • Field Detail

      • elements

        private final java.util.Set<O> elements
        Contains the unique elements of the two collections.
      • newList

        private final java.util.List<O> newList
        Output collection.
    • Constructor Detail

      • SetOperationCardinalityHelper

        public SetOperationCardinalityHelper​(java.lang.Iterable<? extends O> a,
                                             java.lang.Iterable<? extends O> b)
        Create a new set operation helper from the two collections.
        Parameters:
        a - the first collection
        b - the second collection
    • Method Detail

      • iterator

        public java.util.Iterator<O> iterator()
        Specified by:
        iterator in interface java.lang.Iterable<O>
      • setCardinality

        public void setCardinality​(O obj,
                                   int count)
        Add the object count times to the result collection.
        Parameters:
        obj - the object to add
        count - the count
      • list

        public java.util.Collection<O> list()
        Returns the resulting collection.
        Returns:
        the result