Questions tagged [set]
A set is a collection in which no element is repeated, which may be able to enumerate its elements according to an ordering criterion (an "ordered set") or retain no order (an "unordered set").
12,110
questions
1
vote
2
answers
55
views
How to find duplicates in a text file in python and create a new text file with out them
I am trying to remove duplicates from text files to make a current process more efficient
Example input:
1 1
1 1
2 1
3 1
4 1
Example Output:
1 1
2 1
3 1
4 1
my issue is when ...
0
votes
2
answers
51
views
Why it Kotlin's Set implementation mutable under the hood?
I just noticed something interesting about Kotlin's Set data structure and its interaction with Java.
Consider a List object first. If I have this code in Kotlin:
private val aList = listOf(1,2,3)
...
-3
votes
0
answers
32
views
Counting OTPs by Sender, Missing first four OTPs from Senders(first) even if the sender has more than 5 Counts
import re, csv
import pandas as pd
class OTPAnalysis:
def __init__(self) -> None:
self.total_otp = []
self.count = 0
self.df = None
self.sender_count = {}
...
-3
votes
0
answers
33
views
JavaScript Set not working correctly locally? [closed]
I'm writing a little tool in NodeJS v20.13.0 and I'm using Sets to avoid handling directly duplicate data.
When using the difference method between two set I got the following error:
Code example
...
1
vote
1
answer
39
views
How do You Convert a List of Strings into a Frozenset and Add it to a Set of Frozensets?
I have a variable with n words, separated by whitespaces. str.split() returns a list of these words, which is then converted to a tuple with tuple(), which is finally converted to a frozenset and ...
0
votes
1
answer
83
views
reference_wrapper in c++ containers
Consider following snippet:
#include <bits/stdc++.h>
using namespace std;
int main() {
int x=3;
int y=1;
int z=2;
cout<<(&x)<<' '<<(&y)<<' '<&...
0
votes
1
answer
26
views
Data rolled back after 5-7 minutes of running the update on table successfully
I ran an update on the SQL table using the below code, and it updated the table correctly. But after 5-7 minutes, the data rolls back. Why does this happen? I don't see any logs or errors in the SQL ...
-2
votes
1
answer
51
views
Why could I allow a duplicate on Kotlin's sets? [closed]
It is known that the set in Kotlin prohibits the content of duplicates. But I was able to create such a set:
var c = Card2.`2c`
var cards3: Set<Card2> = setOf(c, c)
Why is this acceptable? Or ...
0
votes
0
answers
57
views
set c++ own comparator function find could not find an already inserted element [duplicate]
I wrote an comparator function for my set which will store an vector of 3 elememts.
Those 3 elements will be sorted always.
Now i insert the 2 elements in the set. But when i try to find the 2nd ...
0
votes
1
answer
34
views
Conditional Classname with Tailwind React Not Updating Style
selectedTopics.has(topic) is not returning True when it should in this case to display the conditional styling. When I replace selectedTopics.has(topic) with true, the conditional styling is applied ...
3
votes
3
answers
85
views
searching performance in list is better than in set
Searching an element in a set takes O(1) time complexity while searching in a list takes O(n) time complexity. The n is the number of elements in a set or list.
In my test on the real searching time ...
0
votes
3
answers
59
views
TypeError: unhashable type: 'numpy.ndarray' in array to set
in this def i get TypeError: unhashable type: 'numpy.ndarray' in line retrieved_indices_set = set(retrieved_indices)
def evaluate_retrieval(query_idx, retrieved_indices, relevant_indices):
# ...
1
vote
1
answer
105
views
Julia equivalent for MatLab ismembertol
I have two different datasets, say A of dimension (N1,3) and B(N2,3).
I want to identify the rows in A which are approximately equal to some rows in B with tolerances tol = [tol1, tol2, tol3].
In ...
0
votes
0
answers
38
views
How to add/remove an element from a set in Java while iterating [duplicate]
I know there's a way to do it with ListIterator, but I can't find a SetIterator. Is doing something like this even possible?
1
vote
1
answer
59
views
Overloading Set in Swift
Some background
I am very new to Swift and MacOS and trying to learn the Swift way to do things. This started because I realized that tuples are not hashable so I rolled my own:
struct XY: Hashable
{
...