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
26
votes
6
answers
3k
views
HashSet and TreeSet
I got some homework in which I had to take the novel War and Peace and put it into a HashSet and TreeSet respectively. I had to time it, to check differences and my question is whether my ...
14
votes
1
answer
3k
views
Nested Sets in JavaScript
I created a procedural implementation of the nested set model in JavaScript.
The use case for this small library was that the front-end(presented as an MVC) needs to traverse hierarchical data from ...
12
votes
1
answer
378
views
Chack miy spellang pleez
For my CS2 project, I am supposed to implement a spell-checker. It is
supposed to follow the following:
Prompt the user for the name of the file containing the dictionary
of correctly ...
12
votes
1
answer
967
views
Implementing a generic and covariant Set in Scala
I'm struggling with manually implementing a simple purely functional Set that's also generic and covariant on its type parameter:
...
11
votes
1
answer
9k
views
Concurrent HashSet
I've recently been using HashSet and locking on each method, I found this to not only be a lot of work (was using it in a lot of places) but I started to see inconsistency in my code.
I later decided ...
11
votes
3
answers
484
views
"AI" chat program
I've thrown together this simple chat program, and while it works. I think it could certainly use some improvement. Here's how it works.
Obtain user input by removing all punctuation from the input ...
10
votes
2
answers
2k
views
boost::unordered_set intersection using templates
I wrote this function to do unordered_set intersection using templates. I have seen this answer but I thought that it was overkill. I would like the method to take ...
10
votes
4
answers
7k
views
Powerset (all subsets of a set) in Java
I am trying to get a powerset (all subsets of a set) in Java. So my logic for that is:
A given set is one subset, so add so it as it is to result.
Remove each element of set from given set and we ...
8
votes
7
answers
3k
views
An ordered set in C#
I need a generic data structure that ensures that its elements are unique. C# has HashSet<T>, great!
As it turns out, the elements have to stay in the order ...
8
votes
3
answers
3k
views
Two sets came to an intersection
Challenge:
Print set intersections.
Specifications:
Your program should accept as its first argument a path to a filename.
Each line in the file is a test case.
Each test case contain two ...
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,...
8
votes
2
answers
4k
views
Is there a better way to insert an enum into a set without macros?
I created an enum for a class and in the constructor I inserted all the enum values into a set. I am wondering if there is a ...
8
votes
3
answers
3k
views
7
votes
1
answer
3k
views
Sort int array by frequency then value
Problem
Take an array of ints as input and run a special sorting algorithm on it. This algorithm must first sort by int frequency, less frequent first, then sort by value.
For example ...
7
votes
4
answers
3k
views
Faster Way of Comparing Generic Sets
The following extension method is the limiting factor in the performance of an application I am developing, according to Visual Studio 2012 Performance Analysis profiler.
Is there a faster way to ...