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
0 answers

Error from assignment of read-only location when modifying std::multiset key

I am getting this error on compiling : prog.cpp:40:17: error: assignment of read-only location ‘p.std::_Rb_tree_const_iterator<_Tp>::operator*()’ *p=-1; It has something to do with assignment of a numerical constant to an…
0
votes
2 answers

c++ 2 pointers to find pair of numbers that sum to a certain value using multiset

I want to use 2 pointers technique to find a pair of numbers that sum to a certain value using the c++ multiset container. However why is it that the while loop doesn't stop when iterator l and iterator r in the my program reach the same…
Deus Ex
  • 117
  • 1
  • 8
0
votes
1 answer

Multiset declaration with comparator using function pointers

This is an extension of the question asked and answered here: How to define a multiset using a function pointer? Unfortunately I do not have enough reputation to ask the user with the accepted answer my question as a comment (9 more to go ...), so…
Tom
  • 355
  • 4
  • 11
0
votes
1 answer

Can I use count function on PBDS ordered set after changing it to muliset by changing one of the template less to less_equal

In my code it's showing some kind of error , if there is any other way please let me know.
0
votes
1 answer

Deriving associative containers from map

There is Map type (associative array) in Data.Map.Lazy module in containers package: data Map k a = ... I could derive Set from this type: import qualified Data.Map.Lazy as Map newtype Set a = Set (Map.Map a ()) But the Data.Set module in the same…
Dannyu NDos
  • 2,458
  • 13
  • 32
0
votes
1 answer

Find words beginning with 's' using set/multiset

The issue I'm having with this code stems from the last block of code for the get_words_beginning_s function. /* Name: xx Date: xx Purpose:Read text from file, count number of words, unique words, word frequency, & number of words that…
0
votes
2 answers

Strange behaviour of multiset of pairs in c++

Using Cmp I'm sorting the multiset by a second value of a pair. Problem 1: I did not used set because I can't store both {5,3} and {6,3} and I don't know why since they are different. using pair_type = std::pair; struct Cmp { bool…
Hansie
  • 39
  • 7
0
votes
2 answers

Swift how to make a set with multiplicity (multiset)

I am substracting two Array of Integers. I did the substraction using sets : let numbersA = [1, 2, 3] let numbersB = [3, 4, 5] Set(numbersA).subtracting(numbersB) but I then realized that I have multiplicity in my arrays, and I should take it into…
Jeremy Cochoy
  • 2,480
  • 2
  • 24
  • 39
0
votes
1 answer

Why isn't the iterator not identifying the datatype of the multi-set in the called function?

I'm trying to find an optimized way to this problem- https://www.codechef.com/KJCS2019/problems/TSHACK int findanswer(int k,const multiset >&a2) { int freq=0; while(k>0) …
Shreyas Shetty
  • 618
  • 6
  • 13
0
votes
2 answers

find the non intersection between 2 list, including duplicate

I tried to look up this question before asking but could not find any satisfactory. so I have 2 list like this a=[1,2,3,4,4] b=[1,1,2,3,4] I tried this: set(a) - set(b) but got this set() what I want is this [1,4] Since set a has 2 4s and set b…
FARRAF
  • 205
  • 2
  • 8
0
votes
1 answer

Can't understand the problem with iterator?

The problem states that we have to find the min no of students to remove so that the ith student can pass the exam. So I am basically adding the students in a multiset as it stores sorted values and while the sorted sum is greater than required…
Hardik Mehta
  • 111
  • 7
0
votes
1 answer

Oracle - How to add a Record to a Collection of the same Type (Multiset Union)

I have used MULTISET UNION in order to load a collection into another collection of the same type however I am now working with Records and want to add a Record into a Collection of the same Type. For whatever reason I just can't figure out the…
Code Novice
  • 2,043
  • 1
  • 20
  • 44
0
votes
1 answer

Decorrelate a query using semi join

I am new to query optimization,how to use semi join while implementing decorrelation I can't totally understand. Consider the query SELECT A, B FROM r WHERE r.B < SOME ( SELECT B FROM s …
0
votes
1 answer

Copy contents of a vector into a multiset

I've tried copying the contents of a std::vector into a std::multiset like this: std::vector v(32768); std::generate(v.begin(), v.end(), rand); std::multiset m(v.begin(), v.end()); However, that only copies over the indexes…
Matthewj
  • 1,932
  • 6
  • 26
  • 37
0
votes
1 answer

binding of reference to a value of type drops qualifiers MULTISET

CHotel& hotel = *it; I have problem on this row . When i'm trying to compile all code i get error binding of reference to a value of type drops qualifiers. void addHotel(CHotel & hotel) { m_veriga.insert(hotel); …
vlladislav45
  • 63
  • 2
  • 9