In set theory, the union (denoted by ∪) of a collection of sets is the set of all distinct elements in the collection. It is one of the fundamental operations through which sets can be combined and related to each other. In C++, set_union() constructs a sorted range consisting of all elements present in one or both sorted input ranges.
Questions tagged [set-union]
90 questions
2
votes
2 answers
Form the sequence of a union of two sets efficiently
Dear Reader of this post,
do you have an idea how to form the sequence of a union of two lists efficiently in Python? Suppose there are the two following lists:
list_a = [['a','b'],['a','c'],['b','c']]
list_b = ['h','i']
and I want to calculate:
…

fabian
- 1,413
- 1
- 13
- 24
1
vote
0 answers
How to append all list or union all set in a map's image in Isabelle
Assume that p is a map defined as nat ⇒ string list or nat ⇀ string list and I want to append all string list in p's image
As the similar question, if p is a map defined as nat ⇒ string set or nat ⇀ string set and I want to union all string list…

Huan Sun
- 147
- 6
1
vote
1 answer
Excel VBA Can't delete entire row when part of row is a table
I'm trying to loop through my data and Union certain row numbers that I need to delete later on. The code below stores the correct rows, but I can't delete them. I believe it's because my data is arranged in a table, since I'm able to delete the…

DirtyDeffy
- 497
- 7
- 18
1
vote
4 answers
Joining two sets of tuples at a common value
Given:
setA = [(1, 25), (2, 24), (3, 23), (4, 22), (5, 21), (6, 20),
(7, 19), (8, 18), (9, 17), (10, 16), (11, 15), (12, 14),
(13, 13),(14, 12), (15, 11), (16, 10), (17, 9), (18, 8),
(19, 7),(20, 6), (21, 5), (22, 4),…

Integration
- 195
- 10
1
vote
1 answer
Compare elements in two lists in python
I have two lists as below:
a = ['abc','def', 'ghi'], b=['ZYX','WVU']
and want to confirm whether union of both lists is equal to superset
c = ['ZYX', 'def', 'WVU', 'ghi', 'abc']
I have tried following:
>>> print (c == list(set(b).union(c)))
>>>…

abhi1610
- 721
- 13
- 28
1
vote
2 answers
How to get union of TreeMaps with Sets as values?
I have several temporary TreeMaps which I would like to combine into one Super TreeMap, a union of the smaller TreeMaps.
The generic type of my TreeMaps is
TreeMap>
When I try to call
SuperTreeMap.addALL(temp)
I received the…

zach
- 759
- 1
- 9
- 21
1
vote
0 answers
Union of several sets very efficiently in Java?
I want to find the union of several sets very efficiently because its time has an important effect on the full system.
Let's think our sets are like below:
s1 - 1, 2, 3, 4, 5, 6
s2 - 1, 2, 4, 8, 10, 12, 15, 18, 21
s3 - 1, 23, 25, 26, 27, 28, 29,…

rsc
- 13
- 6
1
vote
2 answers
Clojure: how to use compare with set/union
For the sake of example, let's assume I have two sets:
(def set-a #{{:id 1 :name "ABC" :zip 78759} {:id 2 :name "DEF" :zip 78759}})
(def set-b #{{:id 1 :name "ABC" :zip 78753} {:id 3 :name "XYZ" :zip 78704}})
I would like to find an union between…

sakh1979
- 119
- 8
1
vote
1 answer
Finding the Intersection and Union of two graphs given their adjacency matrices?
Given two adjacency matrices:
graph1 = [[0, 1, 2, 1, 9], [1, 0, 0, 6, 0], [2, 0, 0, 15, 2], [1, 6, 15, 0, 7], [9, 0, 2, 7, 0]]
graph2 = [[0, 19, 1, 0, 12, 0], [19, 0, 2, 0, 0, 0], [1, 2, 0, 0, 2, 0], [0, 0, 0, 0, 3, 5], [12, 0, 2, 3, 0, 2], [0, 0,…

Sook Yee Lim
- 101
- 1
- 9
1
vote
2 answers
find size of union of two sets?
Is there any way to find size of union of two sets.
I know can do this
vector < int > s3( s1.size() , s2.size() );
auto it=set_union( s1.begin() , s1.end() , s2.begin() ,s2.end(), s3.begin());
int size = it - s3.begin();
print size
example
s1 =…

Shaurya Uppal
- 3,410
- 31
- 31
1
vote
0 answers
Python Union of the datasets Sets gives key error
I am trying to implement the union of two sets (with their labels) but apparently it gives a 'keyerror' for 'Survived' column. It should be fairly simple but i don't know what's causing the error
the train_df has 12 columns, while the test_df has…

Sereph
- 61
- 5
1
vote
3 answers
Fast union building of multiple vectors in C++
I’m searching for a fast way to build a union of multiple vectors in C++.
More specifically: I have a collection of vectors (usually 15-20 vectors with several thousand unsigned integers; always sorted and unique so they could also be an std::set).…

Flauer
- 11
- 3
1
vote
1 answer
OWL intersection vs union
Given the following triples, are the domain and range a union or intersection or something else?
rdfs:domain .
…

jaco0646
- 15,303
- 7
- 59
- 83
1
vote
1 answer
Union and intersection of 2 deque (unusual segmentation fault)
5,10,15,20,25 // first deque
50,40,30,20,10 // second deque
v is union vector while intersec is intersection vector. Below is the code for finding union and intersection. In case if anyone have more easy solution, pl do share. Finally I want union…

Mohit Kumar
- 500
- 6
- 24
1
vote
1 answer
Union, intersect, difference large IntSet in O(m+n) times
From my question
Insert element to ArrayList with ascending order and no duplicate elements
I've done my insert method.
Now I try to find out how to build union, intersection, and difference methods to operate on 2 IntSets.
Notice that the number…

Giffary
- 3,060
- 12
- 50
- 71