Constructs a coreset of size k from the union of setA and setB
162353
void unionTreeCoreset(int k,int n_1,int n_2,int d, Point[] setA,Point[] setB, Point[] centres, MTRandom clustererRandom) {
		//printf("Computing coreset...\n");
		//total number of points
		int n = n_1+n_2;

		//choose the first centre (each point has the same probability of being choosen)
		
		//stores, how many centres have been choosen yet
		int choosenPoints = 0; 
		
		//only choose from the n-i points not already choosen
		int j = clustererRandom.nextInt(n-choosenPoints); 

		//copy the choosen point
		if(j < n_1){
			//copyPointWithoutInit(&setA[j],&centres[choosenPoints]);
			centres[choosenPoints] = setA[j].clone();
		} else {
			j = j - n_1;
			//copyPointWithoutInit(&setB[j],&centres[choosenPoints]);
			centres[choosenPoints] = setB[j].clone();
		}
		treeNode root = new treeNode(setA,setB,n_1,n_2, centres[choosenPoints],choosenPoints); //??
		choosenPoints = 1;
		
		//choose the remaining points
		while(choosenPoints < k){
			if(root.cost > 0.0){
				treeNode leaf = selectNode(root, clustererRandom);
				Point centre = chooseCentre(leaf, clustererRandom);
				split(leaf,centre,choosenPoints);
				//copyPointWithoutInit(centre,&centres[choosenPoints]);
				centres[choosenPoints] = centre;
			} else {
				//create a dummy point
				//copyPointWithoutInit(root.centre,&centres[choosenPoints]);
				centres[choosenPoints] = root.centre;
				int l;
				for(l=0;l<root.centre.dimension;l++){
					centres[choosenPoints].coordinates[l] = -1 * 1000000;
				}
				centres[choosenPoints].id = -1;
				centres[choosenPoints].weight = 0.0;
				centres[choosenPoints].squareSum = 0.0;
			}
			
			choosenPoints++;
		}

		//free the tree
		freeTree(root);

		//recalculate clustering features
		int i;
		for(i=0;i<n;i++){
				
			if(i < n_1) {
				
				int index = setA[i].centreIndex;
				if(centres[index].id != setA[i].id){
					centres[index].weight += setA[i].weight;
					centres[index].squareSum += setA[i].squareSum;
					int l;
					for(l=0;l<centres[index].dimension;l++){
						if(setA[i].weight != 0.0){
							centres[index].coordinates[l] += setA[i].coordinates[l];
						}
					}
				}
			} else {
				
				int index = setB[i-n_1].centreIndex;
				if(centres[index].id != setB[i-n_1].id){
					centres[index].weight += setB[i-n_1].weight;
					centres[index].squareSum += setB[i-n_1].squareSum;
					int l;
					for(l=0;l<centres[index].dimension;l++){
						if(setB[i-n_1].weight != 0.0){
							centres[index].coordinates[l] += setB[i-n_1].coordinates[l];
						}
					}
				}
			}
		}
	}
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);
            }
        };
    }
36003
public static <E> Set<E> union(Set<E> s1, Set<E> s2) {
    Set<E> s = new HashSet<E>();
    s.addAll(s1);
    s.addAll(s2);
    return s;
  }
461857
public static long[] toBitset(Itemset i, long[] bits) {
    for(int it = i.iter(); i.iterValid(it); it = i.iterAdvance(it)) {
      BitsUtil.setI(bits, i.iterDim(it));
    }
    return bits;
  }
740891
private static final void core(byte[] Px, byte[] s, byte[] k, byte[] Gx) {
		long10 
		    dx=new long10(),
		    t1=new long10(),
		    t2=new long10(),
		    t3=new long10(),
		    t4=new long10();
	    long10[] 
	        x=new long10[]{new long10(),new long10()},
	    	z=new long10[]{new long10(),new long10()};
		int i, j;

		/* unpack the base */
		if (Gx!=null)
			unpack(dx, Gx);
		else
			set(dx, 9);

		/* 0G = point-at-infinity */
		set(x[0], 1);
		set(z[0], 0);

		/* 1G = G */
		cpy(x[1], dx);
		set(z[1], 1);

		for (i = 32; i--!=0; ) {
			if (i==0) {
				i=0;
			}
			for (j = 8; j--!=0; ) {
				/* swap arguments depending on bit */
				int bit1 = (k[i] & 0xFF) >> j & 1;
				int bit0 = ~(k[i] & 0xFF) >> j & 1;
				long10 ax = x[bit0];
				long10 az = z[bit0];
				long10 bx = x[bit1];
				long10 bz = z[bit1];

				/* a' = a + b	*/
				/* b' = 2 b	*/
				mont_prep(t1, t2, ax, az);
				mont_prep(t3, t4, bx, bz);
				mont_add(t1, t2, t3, t4, ax, az, dx);
				mont_dbl(t1, t2, t3, t4, bx, bz);
			}
		}

		recip(t1, z[0], 0);
		mul(dx, x[0], t1);
		pack(dx, Px);

		/* calculate s such that s abs(P) = G  .. assumes G is std base point */
		if (s!=null) {
			x_to_y2(t2, t1, dx);	/* t1 = Py^2  */
			recip(t3, z[1], 0);	/* where Q=P+G ... */
			mul(t2, x[1], t3);	/* t2 = Qx  */
			add(t2, t2, dx);	/* t2 = Qx + Px  */
			t2._0 += 9 + 486662;	/* t2 = Qx + Px + Gx + 486662  */
			dx._0 -= 9;		/* dx = Px - Gx  */
			sqr(t3, dx);	/* t3 = (Px - Gx)^2  */
			mul(dx, t2, t3);	/* dx = t2 (Px - Gx)^2  */
			sub(dx, dx, t1);	/* dx = t2 (Px - Gx)^2 - Py^2  */
			dx._0 -= 39420360;	/* dx = t2 (Px - Gx)^2 - Py^2 - Gy^2  */
			mul(t1, dx, BASE_R2Y);	/* t1 = -Py  */
			if (is_negative(t1)!=0)	/* sign is 1, so just copy  */
				cpy32(s, k);
			else			/* sign is -1, so negate  */
				mula_small(s, ORDER_TIMES_8, 0, k, 32, -1);

			/* reduce s mod q
			 * (is this needed?  do it just in case, it's fast anyway) */
			//divmod((dstptr) t1, s, 32, order25519, 32);

			/* take reciprocal of s mod q */
			byte[] temp1=new byte[32];
			byte[] temp2=new byte[64];
			byte[] temp3=new byte[64];
			cpy32(temp1, ORDER);
			cpy32(s, egcd32(temp2, temp3, s, temp1));
			if ((s[31] & 0x80)!=0)
				mula_small(s, s, 0, ORDER, 32, 1);
		}
	}
871825
def frombools(cls, bools):
        """"""
        return cls.frombitsets(map(cls.BitSet.frombools, bools))
116519
function(_set1, _set2) {
        var hash = {}, uniq = [],
            fullSet = _set1.concat(_set2);

        for (var i = 0; i < fullSet.length; i++) {
            if (fullSet[i] !== undefined) hash[fullSet[i].toString()] = fullSet[i];
        }

        for (var key in hash) {
            uniq.push(hash[key]);
        }
        return uniq;
    }
626413
def k_subsets(set_, k):
    
    ensure_countable(set_)

    if not isinstance(k, Integral):
        raise TypeError("subset cardinality must be a number")
    if not (k >= 0):
        raise ValueError("subset cardinality must be positive")
    if not (k <= len(set_)):
        raise ValueError("subset cardinality must not exceed set cardinality")

    result = combinations(set_, k)
    return _harmonize_subset_types(set_, result)
325073
def union(self, key, *others):
        """"""
        if not isinstance(key, str):
            raise ValueError("String expected.")
        self.db.sunionstore(key, [self.key] + [o.key for o in others])
        return Set(key)
168219
public static long unionCount(OpenBitSet a, OpenBitSet b) {
        long tot = BitUtil.pop_union( a.bits, b.bits, 0, Math.min( a.wlen, b.wlen ) );
        if (a.wlen < b.wlen) {
            tot += BitUtil.pop_array( b.bits, a.wlen, b.wlen - a.wlen );
        } else if (a.wlen > b.wlen) {
            tot += BitUtil.pop_array( a.bits, b.wlen, a.wlen - b.wlen );
        }
        return tot;
    }
665874
private Node[][][] initialLatticeWithSegs(Instance inst) {
		int[][][] data = (int[][][]) inst.getData();
		int[] tags = (int[]) inst.getTempData();
		length = inst.length();

		Node[][][] lattice = new Node[2][length][];
		for (int i = 0; i < length; i++) {
			lattice[0][i] = new Node[ysize[0]];
			lattice[0][i][tags[i]] = new Node(ysize[0], ysize[1]);
			initialClique(lattice[0][i], data[0][i], orders[0], ysize[0],
					ysize[1]);

			lattice[1][i] = new Node[ysize[1]];
			for (int j = 0; j < ysize[1]; j++) {
				lattice[1][i][j] = new Node(ysize[1], ysize[0]);
			}
			initialClique(lattice[1][i], data[1][i], orders[1], ysize[1],
					ysize[0]);
		}

		return lattice;
	}
454436
def traverse_core(core_area, world_size=(60, 60),
                  neighbor_func=get_moore_neighbors_toroidal):
    

    if not core_area:
        return []
    core_area = [tuple(i) for i in core_area]
    curr = core_area[0]
    core_area = set(core_area[1:])
    to_explore = []
    cores = [[curr]]

    while core_area:
        neighbors = neighbor_func(curr, world_size)

        for n in neighbors:
            if n in core_area:
                core_area.remove(n)
                to_explore.append(n)
                cores[-1].append(n)

        if to_explore:
            curr = to_explore.pop()
        else:
            curr = core_area.pop()
            cores.append([curr])

    return cores
805449
@SafeVarargs
  /* #end */
  public static <KType> KTypeHashSet<KType> from(KType... elements) {
    final KTypeHashSet<KType> set = new KTypeHashSet<KType>(elements.length);
    set.addAll(elements);
    return set;
  }
499800
def _mappingGetValueSet(mapping, keys):
    
    setUnion = set()
    for k in keys:
        setUnion = setUnion.union(mapping[k])
    return setUnion
865483
public static <K, V extends Comparable> SortedSetMultimap<K, V> createSortedSetMultiValueMap() {
		return MultimapBuilder.hashKeys().treeSetValues().build();
	}
1031815
def convert_to_set(unit):
    
    w = WordSegmentation()
    set_unit = set(w.segment(unit))
    set_unit = [i for i in set_unit]
    return set_unit
790443
def powerset(self, start=None, excludestart=False):
        """"""
        if start is None:
            start = self.infimum
            other = self.atoms()
        else:
            if self | start != self:
                raise ValueError('%r is no subset of %r' % (start, self))
            other = self.fromint(self & ~start).atoms()
        return map(self.frombitset, combos.shortlex(start, list(other)))