Skip to main content

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").

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 ...
OmniOwl's user avatar
  • 445
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 ...
nand's user avatar
  • 161
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 ...
syb0rg's user avatar
  • 21.8k
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: ...
Nicolas Rinaudo's user avatar
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 ...
Adam Jones's user avatar
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 ...
Ethan Bierlein's user avatar
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 ...
pbible's user avatar
  • 419
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 ...
Satyen Shimpi's user avatar
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 ...
I'll add comments tomorrow's user avatar
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 ...
Legato's user avatar
  • 9,829
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,...
Looser User's user avatar
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 ...
Aaron's user avatar
  • 955
8 votes
3 answers
3k views

Generate all elements of a power set

...
CodeYogi's user avatar
  • 5,107
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 ...
greg's user avatar
  • 1,017
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 ...
Chris Shouts's user avatar

15 30 50 per page
1
2 3 4 5
10