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").
140
questions
1
vote
1
answer
82
views
Rewriting the java.util.concurrent.ConcurrentSkipListMap to a version without concurrency constructs
I have essentially rewrote the java.util.concurrent.ConcurrentSkipListMap into a version without concurrency constructs (...
2
votes
1
answer
80
views
Compare and merge sets from unstructured variables for automatic differentiation
I have developed an automatic differentiation module for my software. Usually AD comes in two forms; forward mode or reverse mode and very clever approaches, beyond me, might mix both. Typically the ...
2
votes
0
answers
50
views
Set-like Operation in C - Advent of Code 2021 Day 3
I am relatively new to C programming and am currently completeing challenges of Advent of Code 2021 to elevate my skills. I am excited to share my solution for the puzzle on Day 3 and am eager to ...
1
vote
1
answer
79
views
Collection that uses a bitset to store a huge set of unique integers from a given range (rev. 1)
Some (skippable) context:
I'm writing program that minimizes an arbitrary logical function. Such function takes an unsigned integer as an argument and returns either ...
2
votes
4
answers
179
views
Comparison of two excel files ignoring line order
Below is a simple method which compares contents of two excel files ignoring the line order.
This method is working as expected.
But, one of my peers in their code review mentioned that initializing ...
3
votes
3
answers
155
views
IPv4 filter in Java
I have a simple class for representing IPv4-addresses via int values, and a simple IP-address filter that works like a set of IPv4-addresses.
...
8
votes
3
answers
143
views
Compressed output of set in Python
In order to provide a better output of sets with many consecutive elements (a similar class could be written for a list or tuple,...
2
votes
1
answer
190
views
Yet another Wordle Game
This Jupyter Notebook code for the Wordle game works. After a lot of fixes, I have it working as it should. The code is a jumbled mess. I am open to any suggestions and/or criticism of my code. I am ...
1
vote
1
answer
60
views
SortedIntSet: a set of integers that can be iterated in ascending order in O(N) time
I needed a set with the following properties:
can be iterated in ascending or descending order in \$O(N)\$ time
the usual set operations (contains, add, remove, discard) can still be done in \$O(1)\$
...
4
votes
1
answer
892
views
Vectorset, a faster std::set
I decided to implement a vectorset, which is intended to be faster than std::set for the 3 fundamental operations, namely insert,...
2
votes
1
answer
129
views
How many times element of one array occurs in another array?( HackerRank sparse arrays problem)
with basic knowledge of multiset and vectors in c++ I solved the following problem.
How can I improve my code and also handle any input errors?
Problem statement:
There is a collection of input ...
2
votes
2
answers
148
views
Radio with channels
Realize the Radio and Channel classes that represent radio and a radio station. The radio class offers an argumentless constructor and the following methods:
addChannel: stores and returns a new ...
1
vote
1
answer
90
views
A simple Java integer integer hash set - follow-up 2
(See the previous version.)
Now I have this:
com.github.coderodde.util.IntHashSet:
...
1
vote
0
answers
79
views
A simple Java integer hash set - follow-up
(See the previous version.)
(See the next version.)
After incorporating changes in the previous post, I came up with this implementation. However, I left hashing as it is.
...
6
votes
4
answers
1k
views
A simple Java integer hash set
(See the next version.)
The following data structure implements a hash table based set for int values:
...
1
vote
1
answer
278
views
Managing duplicate class instances in a javascript Set
I have a class called Thing. For simplicity, let's say it initializes with a unique id, and that's all that's unique about it:
...
3
votes
1
answer
355
views
Take element of a Set collection depending on the value of another element
I had to populate the fields of a Service object using a Set (HashSet) with any configuration parameters -> ...
2
votes
3
answers
223
views
Sort an array of integers with a hashset
I was trying to make a sorting algorithm for an array of integers. Here's are the steps/theory:
It turns an array into a HashSet, iterates over every integer value ...
5
votes
2
answers
763
views
Filtering a List based on a Suffix and avoid duplicates
I was wondering if there is a better way to solve this issue.
I have a list like this:
...
0
votes
1
answer
165
views
Find a powerset of a set in C
The code below is an implementation of purely recursive solution to find a powerset of any given set. The input set is a string, and the output - array of strings. Both of them are wrapped into a ...
1
vote
0
answers
37
views
Set operations on a tree / Hierarchical set class
Initially, I posted this question on StackOverflow. I wanted to know if there's an existing library that implements the concept I have in mind, which is the following.
I want to define a hierarchy/...
4
votes
2
answers
4k
views
Set<T> data structure in C#
The following data structure is meant for manipulating algebraic/mathematical sets.
I want Set<T> to be compatible and interchangeable with any similar data ...
2
votes
0
answers
110
views
Solving Exact Cover by Three Products in Python
I'm a computer-science hobbyist and found an NP-complete problem that is similar to both subset-product and Exact Cover by 3-sets.
Here is a Reduction of Exact-Cover into my problem. I am multiplying ...
1
vote
1
answer
42
views
Finding data relations of json paths in python
I am kind of new to python, so I am pretty sure there are way better elegant ways to do this.
I have made a function that is able to compare two list of possible json object paths, and detect what ...
5
votes
2
answers
132
views
Bloom Filter in Haskell
I recently implemented a Bloom Filter in Haskell and, although I am not new to functional programming, I am a beginner when it comes to Haskell itself.
I'll gladly take any feedback regarding the ...
6
votes
1
answer
430
views
Remove elements compared with other elements in a Set based on a condition
Simplified the actual problem to focus on comparing/removing performance.
Given a set S with n elements , find the most optimal way to compare each element to all others until a condition is met that ...
4
votes
2
answers
185
views
Finding which items have at least one common value with other items
I have the following collection :
...
4
votes
1
answer
101
views
Immutable Keyed Set
Description
An immutable keyed set is a readonly collection of elements without
duplicates or null values having each of the elements linked to
exactly one key.
Example
This simple example ...
4
votes
2
answers
115
views
Ensure difference between sets
An endpoint that my application interacts with allows you to specify which fields are returned in the JSON result. My application will then map the JSON to a POJO using Jackson. Quite often I add more ...
2
votes
2
answers
220
views
Python set based solution to Subset Sum
Working on the 2 element subset sum problem (finding two numbers in a list that sum to a given value), I came up with a relatively short solution code-wise.
The code could fit on a single line but I'...