Computes the union of all sets, matching on tags and optionally the
aggregated tags across each variable.
423611
private void computeUnion() {
    // key = flattened tags, array of queries.size()
    final ByteMap<ExpressionDataPoint[]> ordered_union = 
        new ByteMap<ExpressionDataPoint[]>(); 

    final Iterator<ITimeSyncedIterator> it = queries.values().iterator();
    while (it.hasNext()) {
      final ITimeSyncedIterator sub = it.next();
      final ExpressionDataPoint[] dps = sub.values();
      final ByteMap<Integer> local_tags = new ByteMap<Integer>();
      
      for (int i = 0; i < sub.size(); i++) {
        final byte[] key = flattenTags(union_on_query_tagks, include_agg_tags, 
            dps[i], sub);
        local_tags.put(key, i);
        ExpressionDataPoint[] udps = ordered_union.get(key);
        if (udps == null) {
          udps = new ExpressionDataPoint[queries.size()];
          ordered_union.put(key, udps);
        }
        udps[sub.getIndex()] = dps[i];
      }
    }
    
    if (ordered_union.size() < 1) {
      // if no data, just stop here
      return;
    }
    
    setCurrentAndMeta(ordered_union);
  }
1210440
private Set<Tuple> getOnceTupleDefs( final List<VarDef> combinedVars)
    {
    try
      {
      return
        new HashSet<Tuple>(
          IteratorUtils.toList(
            IteratorUtils.transformedIterator(
              getOnceTuples(),
              tupleRef -> toTuple( combinedVars, tupleRef))));
      }
    catch( Exception e)
      {
      throw new IllegalStateException( "Invalid once-only tuple definition", e);
      }
    }
1065653
Set<E> union(final SmallSet<E> s) {
        if ((s.e1 == e1 && s.e2 == e2) || (s.e1 == e2 && s.e2 == e1)) {
            return this; // if the two sets are equal, return this
        }
        if (s.e1 == null) {
            return this; // if s is empty, return this
        }
        if (e1 == null) {
            return s; // if this is empty, return s
        }
        if (s.e2 == null) { // s contains exactly one element
            if (e2 == null) {
                return new SmallSet<E>(e1, s.e1); // necessarily e1 != s.e1
            } else if (s.e1 == e1 || s.e1 == e2) { // s is included in this
                return this;
            }
        }
        if (e2 == null) { // this contains exactly one element
            // if (s.e2 == null) { // cannot happen
            // return new SmallSet(e1, s.e1); // necessarily e1 != s.e1
            // } else
            if (e1 == s.e1 || e1 == s.e2) { // this in included in s
                return s;
            }
        }
        // here we know that there are at least 3 distinct elements
        HashSet<E> r = new HashSet<E>(4);
        r.add(e1);
        if (e2 != null) {
            r.add(e2);
        }
        r.add(s.e1);
        if (s.e2 != null) {
            r.add(s.e2);
        }
        return r;
    }
589441
private Collection<Tuple> getUncombinedTuples( List<VarDef> uncombinedVars, int defaultTupleSize)
    {
    Collection<Tuple> tuples = TupleCombiner.getTuples( uncombinedVars, defaultTupleSize);
    if( defaultTupleSize == 1)
      {
      for( Tuple tuple : tuples)
        {
        VarValueDef value = tuple.getBindings().next().getValueDef();
        tuple.setOnce( value.getType() == VarValueDef.Type.ONCE);
        }
      }
    return tuples;
    }
843911
def _combine_sets(self, sets, final_set):
        
        if self._has_sortedsets:
            self.cls.get_connection().zinterstore(final_set, list(sets))
        else:
            final_set = super(ExtendedCollectionManager, self)._combine_sets(sets, final_set)
        return final_set
551320
public boolean containsAll(UnicodeSet b) {
        // The specified set is a subset if all of its pairs are contained in
        // this set. This implementation accesses the lists directly for speed.
        // TODO: this could be faster if size() were cached. But that would affect building speed
        // so it needs investigation.
        int[] listB = b.list;
        boolean needA = true;
        boolean needB = true;
        int aPtr = 0;
        int bPtr = 0;
        int aLen = len - 1;
        int bLen = b.len - 1;
        int startA = 0, startB = 0, limitA = 0, limitB = 0;
        while (true) {
            // double iterations are such a pain...
            if (needA) {
                if (aPtr >= aLen) {
                    // ran out of A. If B is also exhausted, then break;
                    if (needB && bPtr >= bLen) {
                        break;
                    }
                    return false;
                }
                startA = list[aPtr++];
                limitA = list[aPtr++];
            }
            if (needB) {
                if (bPtr >= bLen) {
                    // ran out of B. Since we got this far, we have an A and we are ok so far
                    break;
                }
                startB = listB[bPtr++];
                limitB = listB[bPtr++];
            }
            // if B doesn't overlap and is greater than A, get new A
            if (startB >= limitA) {
                needA = true;
                needB = false;
                continue;
            }
            // if B is wholy contained in A, then get a new B
            if (startB >= startA && limitB <= limitA) {
                needA = false;
                needB = true;
                continue;
            }
            // all other combinations mean we fail
            return false;
        }

        if (!strings.containsAll(b.strings)) return false;
        return true;
    }
322664
public static Assignment unionAll(Collection<Assignment> assignments) {
    int numVars = 0;
    for (Assignment assignment : assignments) {
      numVars += assignment.size();
    }

    int[] vars = new int[numVars];
    Object[] values = new Object[numVars];
    int numFilled = 0;
    for (Assignment assignment : assignments) {
      int[] assignmentVars = assignment.vars;
      Object[] assignmentValues = assignment.values;
      int numAssignmentVars = assignment.vars.length;
      for (int i = 0; i < numAssignmentVars; i++) {
        vars[numFilled] = assignmentVars[i];
        values[numFilled] = assignmentValues[i];
        numFilled++;
      }
    }
    Preconditions.checkState(numFilled == numVars);
    return Assignment.fromUnsortedArrays(vars, values);
  }
167984
public static VariableNumMap unionAll(Collection<VariableNumMap> varNumMaps) {
    VariableNumMap curMap = EMPTY;
    for (VariableNumMap varNumMap : varNumMaps) {
      curMap = curMap.union(varNumMap);
    }
    return curMap;
  }
395280
def power(set_):
    
    ensure_countable(set_)

    result = chain.from_iterable(combinations(set_, r)
                                 for r in xrange(len(set_) + 1))
    return _harmonize_subset_types(set_, result)
304639
def tag(self, *tags):
        
        if any([not isinstance(tag, collections.Hashable) for tag in tags]):
            raise TypeError('Every tag should be hashable')

        if not all(isinstance(tag, collections.Hashable) for tag in tags):
            raise TypeError('Tags must be hashable')
        self.tags.update(tags)
        return self
309734
public static <E> Set<E> union(final Set<? extends E> set1, final Set<? extends E> set2) {
        checkArgumentNotNull(set1, "set1");
        checkArgumentNotNull(set2, "set2");

        // Set 2 minus set 1
        final Set<E> difference = new HashSet<>(set2);
        difference.removeAll(set1);
        // Following stream does not compile on some JDKs
        // See also https://bugs.openjdk.java.net/browse/JDK-8051443
        // set2.stream().filter((e) -> !set1.contains(e)).collect(Collectors.toSet());

        return new AbstractSet<E>() {

            @Override
            public Iterator<E> iterator() {
                final Iterator<E> iterator = Iterators.concat(ImmutableList.of(set1.iterator(), difference.iterator()).iterator());
                // Remove operation is not supported by default
                return new Iterator<E>() {
                    @Override
                    public boolean hasNext() {
                        return iterator.hasNext();
                    }

                    @Override
                    public E next() {
                        return iterator.next();
                    }
                };
            }

            @Override
            public int size() {
                return set1.size() + difference.size();
            }

            @Override
            public boolean isEmpty() {
                return set1.isEmpty() && difference.isEmpty();
            }

            @Override
            public boolean contains(Object o) {
                return set1.contains(o) || difference.contains(o);
            }
        };
    }
1100287
def union_elements(elements):
    

    if len(elements) < 2: return elements
    assert set( [e[3] for e in elements] ) == set( [elements[0][3]] ), "more than one id"
    el_id = elements[0][3]

    unioned_elements = []
    for ch, chgrp in groupby(elements, key=itemgetter(0)):
        for (s, e) in elem_u( np.array([itemgetter(1, 2)(_) for _ in chgrp], dtype=np.uint) ):
            if (s < e):
                unioned_elements.append( (ch, s, e, el_id) )
    assert len(unioned_elements) <= len(elements)
    return unioned_elements
1364257
def union(self,other):
        
        if self.everything:
            return self
        elif other.everything:
            return other
        else:
            return DiscreteSet(self.elements.union(other.elements))
435774
def union(self, *others):
        
        others = self._typesafe_others(others)
        return set(map(
            self._loads, self._client.sunion(self.key_prefix, *others)))
490882
public static List<Range> union(List<Range> ranges){
        ranges = new ArrayList<Range>(ranges);
        Collections.sort(ranges, new Comparator<Range>(){
            @Override
            public int compare(Range r1, Range r2){
                return r1.min-r2.min;
            }
        });
        List<Range> union = new ArrayList<Range>();
        for(Range r: ranges){
            if(union.isEmpty())
                union.add(r);
            else
                CollectionUtil.addAll(union, union.remove(union.size() - 1).union(r));
        }
        return union;
    }
1374704
def union(self):
        
        usegs = reduce(operator.or_, self.values())
        usegs.name = ' | '.join(self.keys())
        return usegs
1104803
def contains_variables_from_set(expression, variables):
    """"""
    if hasattr(expression, 'variable_name') and expression.variable_name in variables:
        return True
    if isinstance(expression, Operation):
        return any(contains_variables_from_set(o, variables) for o in op_iter(expression))
    return False