Questions tagged [multiset]

Anything related to multisets (a.k.a. bags), i.e. data structures that are generalizations of sets and in which an element can be present more than once. This tag applies to questions about multisets implementations, regardless of the specific programming language involved.

Anything related to multisets (a.k.a. bags), i.e. data structures that are generalizations of sets and in which an element can be present more than once. This tag applies to questions about multisets implementations, regardless of the specific programming language involved.

See Wikipedia page on multisets.

344 questions
0
votes
2 answers

Assign vector to multiset

Is there any good way for assigning std::vector to std::multiset? Other than iteration of course. I see that in C++11 there is something like initializer list, maybe it can be used somehow?
user1873947
  • 1,781
  • 3
  • 27
  • 47
0
votes
2 answers

Erase elements from STL multiset with iterator

I am maintaining a set of iterators of a multiset container in a separate data structure. After a while I pick one iterator from this data structure and then erase the associated element to that iterator from multiset. I use this some thing like…
ARH
  • 1,355
  • 3
  • 18
  • 32
0
votes
1 answer

c++ multiset iterator sorting

I have a multiset mymulti where I sort according to a class member m_a. I want then to check for all sorted elements, if the difference in m_a for neighbour fields of mymulti is less than my given threshold, say 0.001. If so, then I want to prefer…
josh130
  • 305
  • 1
  • 5
  • 12
0
votes
1 answer

Does a multiset or bag offer better time complexity than a simple hash that keeps the counts of keys?

Java has multiset, and SmallTalk has a Bag class, and they are said to be the same function: keep a set of values but allow multiple values (with a count for each). But seems like multiset can be implemented by a hash table that keeps counts on the…
nonopolarity
  • 146,324
  • 131
  • 460
  • 740
0
votes
1 answer

Multiset of objects

I have multiset < Class1 > myset; so I create a new object: Class1* c1 = new Class1(); I was expecting to be able to myset.insert(c1) or myset.insert(new Class1()); but none of them work. class Class1{ int time; public: CLass1(int t) : time(t)…
user1078719
  • 195
  • 2
  • 3
  • 15
0
votes
3 answers

In Guava, how to create a Multiset with a single element and n occurrences

I'd like to create an (immutable) Multiset in Guava that has a single entry element with occurrences occurrences, both of which are not known at compile time. What I've come up with is this: ImmutableMultiset.builder().addCopies(element,…
Sean Patrick Floyd
  • 292,901
  • 67
  • 465
  • 588
-1
votes
1 answer

Why are frozen multisets in python not considering repeated elements?

I am working with expression trees which are equivalent to each other considering commutativity. To bring about this equivalence, I thought I will use frozen multisets for holding the operands as they are hashable (unlike dicts), unordered (unlike…
Josh
  • 21
  • 5
-1
votes
1 answer

How do I declare a Multi-set that contains arrays of a certain size?

I'm relatively new to C++. I'm trying to declare a multiset that contains arrays of size 2. I've tried the following but I don't think it does what I want it to do: multiset nameOfSet[2]; Can someone please tell me what this line does? If this…
discovery
  • 43
  • 6
-1
votes
1 answer

How to use multiset in C++?

Why is my code giving a compilation error? I want to have a multiset that can contain 3 items in a sorted order of the first item, if there is a tie then the second item, if there is again a tie then the third item. Please suggest me a solution or…
-1
votes
1 answer

std::mutiset vs std::vector.Getting TLE in one code but AC in another

Problem Link: https://cses.fi/problemset/task/1091/ I am assuming there is some kind of issue relating to time complexity but I am unable to identify what I am doing wrong here. Getting Time Limit Exceeded verdict in this…
-1
votes
2 answers

Why multiset uses operator< of the object it stores?

On storing My custom objects on multisets the object's class requires to have a operator< . I want an explaination of the internal workings of multiset, so that I can understand why operator< is required. Because, some of objects cannot be compared…
Artaza Sameen
  • 519
  • 1
  • 5
  • 13
-1
votes
1 answer

inserting a multiset in one class from another class

so I have a class Data which has a multiset container and I have a class Item which has "erscheidatum" as one of the constructor parameters,so I want this parameter escheidatum to be inserted in the multiset in the data class i tried to do that in…
Dr.Noob
  • 319
  • 6
  • 17
-1
votes
1 answer

std::prev issue with set or multiset

I have below two pieces of code: // multiset::begin/end #include #include #include int main () { int myints[] = {42,71,12}; std::set mymultiset (myints,myints+2); std::set mymultiset1 (myints,myints+2); …
-1
votes
1 answer

How to write an implementation class for a Bag (or Multiset) ADT?

I have an assignment in which I need to write an implementation class for a Bag (or Multiset) ADT. Problem is, the assignment is worded in a way that's hard to follow and I'm not sure what exactly I need to do. Here is the assignment description and…
-1
votes
2 answers

I want to perform a multi-set intersection using C++

I am using std::set and multi-set classes std::multiset to perform some set operations - union, intersection etc. The problem is that I have to perform intersection between two multi-sets such that I also get the duplicate values. The…
1 2 3
22
23