282 questions
1
vote
2
answers
105
views
error compiling ranges::set_intersection with projection
The code:
#include <algorithm>
#include <ranges>
#include <vector>
#include <tuple>
#include <generator>
#include <cstdio>
#include <iostream>
using ...
2
votes
3
answers
141
views
How to use output iterators without a container: Set intersection without storage
The C++ reference has this example for printing the intersection of two sets (or sorted containers):
#include <algorithm>
#include <iostream>
#include <iterator>
#include <vector&...
1
vote
1
answer
154
views
Is this an efficient way to find overlap of two string columns
I have a table with columns name and full name, and am interested in knowing whether one is part of the other (but they are not equal).
Example:
name | full name | is_subset
-------------...
0
votes
2
answers
115
views
Fast intersection of two N^4 sets
I'm looking for an algorithm that returns (the length of) the intersection of two given N^4 lists / sets (more precisely in [|0;7|]^4). I'm not expecting an answer in a specific programming language (...
2
votes
0
answers
59
views
How do you order a list of sets such that sets with common elements are as far as possible from each other?
Basically a problem I've been thinking about for the past couple weeks...
Initially thought of making each set in the list a node in a graph, and connecting nodes which do not have any common elements....
1
vote
0
answers
214
views
Algorithm to find minimal subsets that intersect with list of sets
Problem statement:
Given a list L of sets, find every set X of elements such that:
for all Y in L, the intersection of X and Y is non-empty
the set X is minimal in the sense that no element in X ...
2
votes
3
answers
151
views
How Fast Can We Approximate Set Jaccard Scores?
I'm trying to compute about 1 trillion different pairwise jaccard scores on a laptop. I'm also not very patient.
Each set tends to contain about 200-800 unique, pseudorandom 32-bit hashes. I've ...
0
votes
1
answer
56
views
How to get intersection data of a field from multiple Mongodb document's field's data. Want a Mongo aggregate Query which I can add in my query
I am already using a Mongo db Aggregate Query to get a array of output.
email will be the array of emails as input in the query.
**aggregateQuery** = [
{
'$match': {
'email': {
...
0
votes
1
answer
955
views
Make column of all matching substrings from a list that are found within a Polars string column
How do I return a column of all matching terms or substrings found within a string? I suspect there's a way to do it with pl.any_horizontal() as suggested in these comments but I can't quite piece it ...
5
votes
2
answers
177
views
How to find intersection between all possible pairs of sets in a 2-column table?
I want to calculate an overlap coefficient between sets. My data comes as a 2-column table, such as:
df_example <-
tibble::tribble(~my_group, ~cities,
"foo", "...
0
votes
0
answers
105
views
what is faster, std::sort then set_intersection, or std::unordered_map with double for-loop find?
what is a faster?
sort two vectors and then do set_intersection... or
auto intersection = std::make_shared<MediaItems>();
std::sort(m_currentSearchResults->begin(), m_currentSearchResults->...
-4
votes
1
answer
344
views
Intersection of two BTreeSet objects in Rust
I can't figure out how to take two BTreeSet objects and create a new, owned, BTreeSet from the intersection operation.
Here is a Minimal Example:
use std::collections::BTreeSet;
fn test() -> ...
2
votes
1
answer
65
views
Finding intersections between a large number of sets with unique elements each
The following is an interesting algorithmic problem.
Inputs:
The set of elements S (say, non-negative integers).
A mapping N that maps some elements from S to a subset S_k \subset S. (not all ...
-5
votes
1
answer
836
views
Why does "set(a) and set(b)" vs "set(a) & set(b)" give different results in python?
I understand that one is bitwise operation while the other is not, but how does this bitwise property affect the results of given expression.
As both should simply compare the elements in both sets ...
0
votes
2
answers
63
views
Python find all non-repeat combinations and get both the values they have in common and their unique values
I have an array of sets [setA, setB, setC, setD, ..., setX] and I want to find a way to get the intersection of each combination (without repeat combos), so:
AB = setA.intersect(setB)
AC = setA....
1
vote
2
answers
61
views
Is there a way to check set disjointness probabilistically and efficiently, similar to a Bloom filter?
Is there an algorithm similar to the bloom filter, that allows you to:
Compactly represent two (large) sets independently of each other and
probabilistically check for disjointness between them using ...
0
votes
1
answer
173
views
Generics Resolve into Intersection Type
Why typeof body is resolve as Intersection Type SignRequest & {}.
export interface HttpResponse<T> {
statusCode: number;
body: T | Error;
}
export interface HttpRequest<T> {
...
1
vote
2
answers
59
views
Demonstration of sets being faster than arrays?
The goal is to find the intersection of 2 arrays. I know you're supposed to use sets to get a faster runtime. However, in my notebook I was surprised to find that my runtime is not faster with the ...
0
votes
3
answers
985
views
BigQuery array intersection across all rows
I have the following data:
col1
[1,2,3]
[1,2]
[2,3]
I want the following output
ans
[2]
In other words, I want the intersection of arrays in all rows.
Any pointers?
0
votes
1
answer
176
views
Preserve list order that comes from the intersection of more than two lists
I have the following dictionary
di = {
'A': [['A1', 'A1a'], ['A1', 'A1a'], ['A1', 'A1a'], ['A1', 'A1a'], ['A1', 'A1a']],
'B': [['A1', 'BT', 'B2', 'B2a', 'B2a1a']],
'G': [['A1', 'BT', '...
0
votes
2
answers
102
views
use C++ range set_intersection() as SQL Join
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
struct Item1{int id; int data;};
vector<Item1> v1 = {{.id=1,.data=42},{.id=2,.data=69}};
struct ...
0
votes
3
answers
227
views
Pythonic way of "inner join" of list of lists with arbitrary lengths?
I have an arbitrary list of lists, for example
x = [
[5, 1, 2, 3, 4],
[5, 6, 7, 8, 9],
[5, 10, 11, 12]
]
There is only one element which is a member of all three lists in ...
0
votes
2
answers
195
views
Interesting problem with VBA error 91, protection and intersetcion
Please, could anyone help with error 91, I can't find a solution. Firstly the related code part:
.......
Application.EnableEvents = False
PrUpr.UJournal 'Protection code for sheet is located in ...
2
votes
3
answers
766
views
PowerShell: Intersection of more than two arrays
Using PowerShell, I have 14 arrays of strings. Some of the arrays are empty. How would I get the intersection (all elements that exist in all of the arrays) of these arrays (excluding the arrays that ...
6
votes
2
answers
285
views
Efficient code to do set operations with bigz-class values?
The current release of the package gmp does not support set operations such as intersect, setdiff , etc. I'm doing some work with number sequences (see OEIS for examples) and need to handle large ...
0
votes
1
answer
70
views
Find common values in i number of lists
I wish to do what is described in this previous question but instead of lists a,b,c I have i number of lists (that is set based on user input):
Find common values in multiple lists
How can I change ...
0
votes
1
answer
394
views
How to determine if lists have at least one same element
Product table contains tags columns:
create table product(
product char(20) primary key,
tag1 char(100),
tag2 char(100) )
tag columns contain tags separated by semicolon like
AB;AC;AD
RXX;AC;...
2
votes
0
answers
78
views
Database optimised for set operations
I want to know the database or platform that will be most suitable for performing heavy set operations.
Especially INTERSECTION, DIFFERENCE over millions of values in sets.
1
vote
0
answers
221
views
fast pairwise intersection of lists of sets
I have a list of sets a and another list of sets b.
I want to intersect each set in a against every set in b, and if the result is not empty, then report the index positions of the matched sets, and ...
1
vote
1
answer
90
views
how to create custom intersected container from 2 distinct container types
Using the following containers:
std::vector<std::pair<std::string, int>> keyVals = {
{"A", 1}, {"B", 2}, {"C", 3}
};
std::vector<std::string> keys ...
2
votes
1
answer
3k
views
Select if array contains an element of another array
I have a table which has a JSON type field where I save a number array like [1, 2, 3, 4].
I want to select records in which its array set contains at least one element of another array I have in a php ...
1
vote
3
answers
348
views
Length of the intersections between a list an list of list
Note : almost duplicate of Numpy vectorization: Find intersection between list and list of lists
Differences :
I am focused on efficiently when the lists are large
I'm searching for the largest ...
0
votes
1
answer
80
views
How to query all spatial trajectories that go from one region to another
Consider a mongo db where each document corresponds to a spatial trajectory. That is, there is a field that contains an array for each document. Each array is a sequence of latitude/longitude pairs ...
0
votes
2
answers
98
views
Is it possible to improve this array intersection code
This is the minimum code to obtain arrays intersection without any repetition in the final array. Can it be improved ?
I think it can't because it uses the minimum number of iteration thanks to the ...
1
vote
2
answers
2k
views
How to find common items in two Laravel collection objects
I'm trying to compare 2 collections, and put all values present in both into another collection.
So given these collections:
$text1 = collect('burger', 'cheese', 'bread', 'ham');
$text2 = collect('...
0
votes
2
answers
960
views
Write a program that reads two sets of integer elements (10 elements for each set) and finds the intersection of two sets
How can I finish my code below? Where should I add isEmpty? And how to just print "The Intersected Elements of Set A and B are:" once only?
#include <iostream>
using namespace std;
...
0
votes
1
answer
106
views
Why is this below code giving heap overflow Error by just changing the comparison operator from &&(AND) to ||(OR)?
I was trying to solve below problem:
Given two integer arrays nums1 and nums2, return an array of their intersection. Each element in the result must appear as many times as it shows in both arrays ...
0
votes
1
answer
479
views
Pair-wise intersection set operation between column values in a data frame
I have a data frame with one column. Each value in this column is a list. For example,
A
0 [1, 3, 4]
1 [43, 1, 42]
2 [50, 3]
I want to perform the set intersection operation between each ...
2
votes
0
answers
740
views
SIMD vector intersection of two sets using AVX-512: need a speed up
I currently need to intersect two sorted vectors.
Here are my implementations:
#include <immintrin.h>
#include <stdint.h>
#include <algorithm>
#include <bit>
#include <...
1
vote
1
answer
362
views
CoreData fetch predicate using a set intersection
My core data model has an entity with an attribute setOfStrings of type Transformable.
The corresponding class has a property @NSManaged var setOfStrings: Set<String>?.
I want to fetch objects ...
2
votes
1
answer
2k
views
EF Core Intersect between List and Property of child element returns "ArgumentNullException"
I am currently trying to intersect a list of IDs with a child property of my Database Entity.
The intent of doing so is to find all "Form" records that that have all of the list Ids matching ...
0
votes
1
answer
238
views
How to automatize intersect function in r?
I have a task in which i have to find the "degree of intersection" in various dataframes containing the Top 50 Spotify Charts of multiples countries. In order to do this, im intersecting ...
-2
votes
2
answers
465
views
More efficient way to get the intersection between 2 or more nested ArrayLists [closed]
If I had, say separate 3 nested ArrayLists of Strings, i.e., ArrayList<ArrayList<String>>:
What is the most efficient way of finding their intersection (common elements)?
Are there other ...
0
votes
1
answer
81
views
My program returning the set_intersection value of two text files containing 479k words each is really slow. Is it my code?
I wrote a program to compare two text files containing all of the words in the dictionary (one forwards and one backwards). The idea is that when the text file containing all of the backwards words is ...
0
votes
1
answer
311
views
The intersection of all combinations of n lists
Given an ArrayList of ArrayLists with size larger than 3
ArrayList<ArrayList<Integer>> lists = new ArrayLists<ArrayList<Integer>>();
I want to take 3 unique sub-lists, find ...
0
votes
0
answers
154
views
Why is the algorithm set_intersection only returning matching strings from two text files when they are listed in the same exact order?
I am a C++ novice, so bear with me if my formatting isn't perfect. I am writing a program called palindrome's cousin that finds all the words in the dictionary that spell another word backwards (i.e. ...
0
votes
1
answer
39
views
Dictate that elements have intersected each other
Am working on a JavaScript simple game (game like one google chrome shows on no network presence).
I would like to dictate that the incoming span is in contact with the first span. (trouble ...
0
votes
1
answer
183
views
std::multiset intersection compilation error
I'm trying to find the intersection of 2 multisets of objects using std::set_intersection function.
#include <algorithm>
#include <set>
struct Interval
{
double bottom;
double top;
};
...
2
votes
3
answers
930
views
how to intersect elements of one column along with group_by in R [duplicate]
Lets assume, my data is like
group_id col1
1 1 A,B
2 1 B,C
3 2 A,C
4 2 B,D
5 3 A,D
6 3 A,B,C,D
I would like to summarise/mutate col1 ...
1
vote
1
answer
425
views
Is intersection of a subtype and its supertype the same as the subtype?
Given the following TypeScript code:
interface A { /* ... */ }
interface B extends A { /* ... */ }
type Mystery = A & B;
Objects of the Mystery type should have all the properties of A and all ...