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
4
votes
1 answer

Why is guava's AbstractMultiset not public?

I tried to write a class that extends guava's AbstractMultiset but I saw that it isn't a public class. Why is that? Is there a different class that I should be extending? The other similar classes that I know (AbstractCollection, AbstractSet, etc)…
Eyal
  • 5,728
  • 7
  • 43
  • 70
4
votes
1 answer

How to insert a pair using multiset in C++

I want to insert an integer value and a pair in a multiset. So I declared it as: multiset < int, pair < int, int> > mp; int m,n,p; To insert in multiset I tried this : mp.insert(make_pair(m, make_pair(n,p))); // Compile time error But its giving…
Rishabh
  • 730
  • 2
  • 11
  • 25
4
votes
2 answers

A red black tree with the same key multiple times: store collections in the nodes or store them as multiple nodes?

Apparently you could do either, but the former is more common. Why would you choose the latter and how does it work? I read this: http://www.drdobbs.com/cpp/stls-red-black-trees/184410531; which made me think that they did it. It…
3
votes
3 answers

How to find all combinations of a multiset in a string in linear time?

I am given a bag B (multiset) of characters with the size m and a string text S of size n. Is it possible to find all substrings that can be created by B (4!=24 combinations) in S in linear time O(n)? Example: S = abdcdbcdadcdcbbcadc (n=19) B = {b,…
3
votes
1 answer

Faster way to find the size of the intersection of any two corresponding multisets from two 3D arrays of multisets

I have two uint16 3D (GPU) arrays A and B in MATLAB, which have the same 2nd and 3rd dimension. For instance, size(A,1) = 300 000, size(B,1) = 2000, size(A,2) = size(B,2) = 20, and size(A,3) = size(B,3) = 100, to give an idea about the orders of…
M.G.
  • 293
  • 1
  • 13
3
votes
1 answer

SQL Informix 12.10FC6 - Cast multiple columns of multiset at once, but without creating a user defined type

I'll show what I got working and what I need help, as follows [works] - Here I'm creating a multiset on the fly, without needing to create a user defined type. SELECT * FROM TABLE(MULTISET{ ROW(100, 'Kline'), ROW(101, 'Smith'), ROW(102, 'Jones'),…
Gabz
  • 391
  • 5
  • 11
3
votes
2 answers

Inserting in a multiset: before the first occurence of that value instead of after the last occurence

As the title says multiset inserts a value at the end of the range of all the same values. (Ex: Inserting 2 in a multiset 1,2,2,3 makes it 1,2,2,/*new*/ 2,3). How do I get the new value inserted at the start of the range of all the same values? (Ex:…
gst1502
  • 306
  • 1
  • 10
3
votes
4 answers

Python3 find how many differences are in 2 lists in order to be equal

Assuming we got 2 lists, always with the same length and always containing strings. list1 = ['sot', 'sot', 'ts', 'gg', 'gg', 'gg'] list2 = ['gg', 'gg', 'gg', 'gg', 'gg', 'sot'] we need to find: How many items of the list2 should change, in order…
GeorgeGeorgitsis
  • 1,262
  • 13
  • 29
3
votes
1 answer

Creating all multisets of subsets of NON DISTINCT values, in Java

Given an array of objects, i need to find, as efficiently as possible, all different sets of subsets of the given array, that include all values, when the values in the array may repeat. for example: if the array is 1, 2, 1, 2 then i need to create…
Eytan Rath
  • 33
  • 2
3
votes
2 answers

C++ operations on values given by multiset::equal_range

I'm trying to write a program that is taking 1000 random numbers from 0 to 9 and then counting how many times each number appeared: srand(time(NULL)); multiset M;//multiset that contains 1000 random numbers from 0 to 9 for (int i =…
Ania
  • 450
  • 4
  • 14
3
votes
3 answers

About set container

std::set> myset = {1,1,7,8,2,2}; myset.insert(99); myset.insert(99); for(const int & val : myset) std::cout << val << " "; output: 1 1 2 2 7 8 99 99 Hello, while i was studying on containers. i realized that when i…
3
votes
2 answers

LowerBound in multiset stl

I was trying to find how many element are less than a certain X in a multiset by using: mset.lower_bound(X) - mset.begin() But it didn't work. Any workarounds?
Swatak
  • 33
  • 2
3
votes
0 answers

Efficient sampling without replacement from a multiset

Suppose I have a list of pairs of items and counts, such as {("a", 500), ("b", 200), ("c", 2), ("d", 300)} I'm interested in cases when the list is relatively short but the sum of counts is large; the specific case I'm looking at now has less than…
Kodiologist
  • 2,984
  • 18
  • 33
3
votes
1 answer

"Don't Care" fields in multiset keys

I have a compound data type like: struct Key { optional a; optional b; optional c; }; I also have a multiset, multiset. For example, it contains {1, 2, 3} {1, NULL, 3} {NULL, 2, 3} {NULL, NULL, 3} I want to get all…
Sadjad
  • 1,661
  • 2
  • 13
  • 20
3
votes
3 answers

Error in Accessing Multiset element C++

I get the error ../src/internet-stack/mp-tcp-socket-impl.cc: In member function ‘void ns3::MpTcpSocketImpl::OpenCWND(uint8_t, uint32_t)’: ../src/internet-stack/mp-tcp-socket-impl.cc:2471: error: no match for ‘operator-’ in…