/*-------------------------------------------------[ Union ]---------------------------------------------------
504741
public XSDocument startUnion(String... memberParts) throws SAXException{
        xml.startElement(URI_XSD, "union");

        StringBuilder buff = new StringBuilder();
        for(int i=0; i<memberParts.length; i+=2){
            if(buff.length()>0)
                buff.append(' ');
            buff.append(xml.toQName(memberParts[i], memberParts[i+1]));
        }
        if(buff.length()>0)
            xml.addAttribute("memberTypes", buff.toString());

        xml.endElement();
        return this;
    }
767541
private <T> Collection<Integer> transformUnion(UnionTransformation<T> union) {
		List<StreamTransformation<T>> inputs = union.getInputs();
		List<Integer> resultIds = new ArrayList<>();

		for (StreamTransformation<T> input: inputs) {
			resultIds.addAll(transform(input));
		}

		return resultIds;
	}
755679
function combine(types, opts) {
  if (!types.length) {
    throw new Error('no types to combine');
  }
  if (types.length === 1) {
    return types[0]; // Nothing to do.
  }
  opts = opts || {};

  // Extract any union types, with special care for wrapped unions (see below).
  var expanded = [];
  var numWrappedUnions = 0;
  var isValidWrappedUnion = true;
  types.forEach(function (type) {
    switch (type.getTypeName()) {
      case 'union:unwrapped':
        isValidWrappedUnion = false;
        expanded = expanded.concat(type.getTypes());
        break;
      case 'union:wrapped':
        numWrappedUnions++;
        expanded = expanded.concat(type.getTypes());
        break;
      case 'null':
        expanded.push(type);
        break;
      default:
        isValidWrappedUnion = false;
        expanded.push(type);
    }
  });
  if (numWrappedUnions) {
    if (!isValidWrappedUnion) {
      // It is only valid to combine wrapped unions when no other type is
      // present other than wrapped unions and nulls (otherwise the values of
      // others wouldn't be valid in the resulting union).
      throw new Error('cannot combine wrapped union');
    }
    var branchTypes = {};
    expanded.forEach(function (type) {
      var name = type.getName(true);
      var branchType = branchTypes[name];
      if (!branchType) {
        branchTypes[name] = type;
      } else if (!type.equals(branchType)) {
        throw new Error('inconsistent branch type');
      }
    });
    var wrapUnions = opts.wrapUnions;
    var unionType;
    opts.wrapUnions = true;
    try {
      unionType = createType(Object.keys(branchTypes).map(function (name) {
        return branchTypes[name];
      }), opts);
    } catch (err) {
      opts.wrapUnions = wrapUnions;
      throw err;
    }
    opts.wrapUnions = wrapUnions;
    return unionType;
  }

  // Group types by category, similar to the logic for unwrapped unions.
  var bucketized = {};
  expanded.forEach(function (type) {
    var bucket = getTypeBucket(type);
    var bucketTypes = bucketized[bucket];
    if (!bucketTypes) {
      bucketized[bucket] = bucketTypes = [];
    }
    bucketTypes.push(type);
  });

  // Generate the "augmented" type for each group.
  var buckets = Object.keys(bucketized);
  var augmented = buckets.map(function (bucket) {
    var bucketTypes = bucketized[bucket];
    if (bucketTypes.length === 1) {
      return bucketTypes[0];
    } else {
      switch (bucket) {
        case 'null':
        case 'boolean':
          return bucketTypes[0];
        case 'number':
          return combineNumbers(bucketTypes);
        case 'string':
          return combineStrings(bucketTypes, opts);
        case 'buffer':
          return combineBuffers(bucketTypes, opts);
        case 'array':
          // Remove any sentinel arrays (used when inferring from empty arrays)
          // to avoid making things nullable when they shouldn't be.
          bucketTypes = bucketTypes.filter(function (t) {
            return t !== EMPTY_ARRAY_TYPE;
          });
          if (!bucketTypes.length) {
            // We still don't have a real type, just return the sentinel.
            return EMPTY_ARRAY_TYPE;
          }
          return createType({
            type: 'array',
            items: combine(bucketTypes.map(function (t) {
              return t.getItemsType();
            }))
          }, opts);
        default:
          return combineObjects(bucketTypes, opts);
      }
    }
  });

  if (augmented.length === 1) {
    return augmented[0];
  } else {
    // We return an (unwrapped) union of all augmented types.
    return createType(augmented, opts);
  }
}
658808
private boolean validUnionTypeExpression(Node expr) {
    // The expression must have at least three children: The union keyword and
    // two type expressions
    if (!checkParameterCount(expr, Keywords.UNION)) {
      return false;
    }
    int paramCount = getCallParamCount(expr);
    // Check if each of the members of the union is a valid type expression
    for (int i = 0; i < paramCount; i++) {
      if (!validTypeTransformationExpression(getCallArgument(expr, i))) {
        warnInvalidInside("union type", expr);
        return false;
      }
    }
    return true;
  }
838883
function UnionType(attrs, opts) {
  Type.call(this);

  if (!Array.isArray(attrs)) {
    throw new Error(f('non-array union schema: %j', attrs));
  }
  if (!attrs.length) {
    throw new Error('empty union');
  }
  this._types = attrs.map(function (obj) { return createType(obj, opts); });

  this._branchIndices = {};
  this._types.forEach(function (type, i) {
    if (Type.isType(type, 'union')) {
      throw new Error('unions cannot be directly nested');
    }
    var branch = type.getName(true);
    if (this._branchIndices[branch] !== undefined) {
      throw new Error(f('duplicate union branch name: %j', branch));
    }
    this._branchIndices[branch] = i;
  }, this);
}
814810
def union_q(token):
    
    query = Q()
    operation = 'and'
    negation = False

    for t in token:
        if type(t) is ParseResults:  # See tokens recursively
            query &= union_q(t)
        else:
            if t in ('or', 'and'):  # Set the new op and go to next token
                operation = t
            elif t == '-':  # Next tokens needs to be negated
                negation = True
            else:  # Append to query the token
                if negation:
                    t = ~t
                if operation == 'or':
                    query |= t
                else:
                    query &= t
    return query
1163256
function union(xs, ys) {
  var obj = {};
  for (var i = 0; i < xs.length; i++) {
    obj[xs[i]] = true;
  }
  for (var j = 0; j < ys.length; j++) {
    obj[ys[j]] = true;
  }
  var keys = [];
  for (var k in obj) {
    if ({}.hasOwnProperty.call(obj, k)) {
      keys.push(k);
    }
  }
  keys.sort();
  return keys;
}
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);
  }
245673
public function union(Value $set)
    {
        $union = $this->value;

        /** @var Value $arg */
        foreach (func_get_args() as $arg) {
            /** @var array $convertedArg */
            $convertedArg = $arg->getSet()->getValue();
            $union = array_merge($union, array_diff($convertedArg, $union));
        }

        return new self($union);
    }
1214436
public void union(final HLL other) {
        // TODO: verify HLLs are compatible
        final HLLType otherType = other.getType();

        if(type.equals(otherType)) {
            homogeneousUnion(other);
            return;
        } else {
            heterogenousUnion(other);
            return;
        }
    }
855976
function union(
       /** {me.Rect} */
       r) {
         var x1 = Math.min(this.left, r.left);
         var y1 = Math.min(this.top, r.top);
         this.resize(Math.max(this.right, r.right) - x1, Math.max(this.bottom, r.bottom) - y1);
         this.pos.set(x1, y1);
         return this;
       }
918353
function Union () {
  debug('defining new union "type"')

  function UnionType (arg, data) {
    if (!(this instanceof UnionType)) {
      return new UnionType(arg, data)
    }
    debug('creating new union instance')
    var store
    if (Buffer.isBuffer(arg)) {
      debug('using passed-in Buffer instance to back the union', arg)
      assert(arg.length >= UnionType.size, 'Buffer instance must be at least '
          + UnionType.size + ' bytes to back this untion type')
      store = arg
      arg = data
    } else {
      debug('creating new Buffer instance to back the union (size: %d)', UnionType.size)
      store = new Buffer(UnionType.size)
    }

    // set the backing Buffer store
    store.type = UnionType
    this['ref.buffer'] = store

    // initialise the union with values supplied
    if (arg) {
      //TODO: Sanity check - e.g. (Object.keys(arg).length == 1)
      for (var key in arg) {
        // hopefully hit the union setters
        this[key] = arg[key]
      }
    }
    UnionType._instanceCreated = true
  }

  // make instances inherit from `proto`
  UnionType.prototype = Object.create(proto, {
    constructor: {
        value: UnionType
      , enumerable: false
      , writable: true
      , configurable: true
    }
  })

  UnionType.defineProperty = defineProperty
  UnionType.toString = toString
  UnionType.fields = {}

  // comply with ref's "type" interface
  UnionType.size = 0
  UnionType.alignment = 0
  UnionType.indirection = 1
  UnionType.get = get
  UnionType.set = set

  // Read the fields list
  var arg = arguments[0]
  if (typeof arg === 'object') {
    Object.keys(arg).forEach(function (name) {
      var type = arg[name];
      UnionType.defineProperty(name, type);
    })
  }

  return UnionType
}
192230
function UnionType(schema, opts) {
  Type.call(this);

  if (!Array.isArray(schema)) {
    throw new Error(f('non-array union schema: %j', schema));
  }
  if (!schema.length) {
    throw new Error('empty union');
  }
  this.types = Object.freeze(schema.map(function (obj) {
    return Type.forSchema(obj, opts);
  }));

  this._branchIndices = {};
  this.types.forEach(function (type, i) {
    if (Type.isType(type, 'union')) {
      throw new Error('unions cannot be directly nested');
    }
    var branch = type.branchName;
    if (this._branchIndices[branch] !== undefined) {
      throw new Error(f('duplicate union branch name: %j', branch));
    }
    this._branchIndices[branch] = i;
  }, this);
}
1032926
def union(self, other, ignore_conflicts=False):
        """"""
        result = self.copy()
        result.union_update(other, ignore_conflicts)
        return result
204271
def union(self, i, j):
        '''
        
        '''
        roots = (self.find(i), self.find(j))
        if roots[0] == roots[1]:
            return False
        if self.sizes[roots[0]] <= self.sizes[roots[1]] or not self.optimize:
            self.add_edge(roots[0], roots[1])
            self.sizes[roots[1]] += self.sizes[roots[0]]
            return True
        else:
            self.add_edge(roots[1], roots[0])
            self.sizes[roots[0]] += self.sizes[roots[1]]
            return True
1112609
function union(x, y) {
        var obj = {};
        for (var i = 0; i < x.length; i++)
            obj[x[i]] = x[i];
        for (i = 0; i < y.length; i++)
            obj[y[i]] = y[i];
        var res = [];
        for (var k in obj) {
            if (obj.hasOwnProperty(k))
                res.push(obj[k]);
        }
        return res;
    }
508963
public ScatteredConsistentHash union(ScatteredConsistentHash sch2) {
      checkSameHashAndSegments(sch2);

      List<Address> unionMembers = new ArrayList<>(this.members);
      mergeLists(unionMembers, sch2.getMembers());

      Address[] unionSegmentOwners = new Address[segmentOwners.length];
      for (int i = 0; i < unionSegmentOwners.length; i++) {
         unionSegmentOwners[i] = Optional.ofNullable(sch2.locatePrimaryOwnerForSegment(i)).orElse(locatePrimaryOwnerForSegment(i));
      }

      Map<Address, Float> unionCapacityFactors = unionCapacityFactors(sch2);
      return new ScatteredConsistentHash(hashFunction, unionSegmentOwners.length, unionMembers, unionCapacityFactors, unionSegmentOwners, false);
   }