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

how to calculate multiset of elements given probability on each element?

let say I have a total number tN = 12 and a set of elements elem = [1,2,3,4] and a prob for each element to be taken prob = [0.0, 0.5, 0.75, 0.25] i need to get a random multiset of these elements, such as the taken elements reflects the…
markzzz
  • 47,390
  • 120
  • 299
  • 507
0
votes
0 answers

Jooq unable to parse multiset result

I have the following mapping @Entity @Table(name = "table_a") data class TableBEntity( @Id @Column(name = "id") val id: Int? = null, @Transient val tableBList: List = listOf() ) @Entity @Table(name =…
inafalcao
  • 1,415
  • 1
  • 11
  • 25
0
votes
3 answers

mapEither inserting both Left and Right

Using the function mapEither for multiset's I can turn a MultiSet into a pair of two multisets. When f is returning Left the element is inserted into the first Multiset of the pair, and if f is returning Right the element is inserted into the second…
Polo
  • 89
  • 1
  • 8
0
votes
0 answers

I need to create a multiset on Java

I have to create a MultiSet in Java and I'm stuck. I need to have it efficient and without superfluous pointers, one pointer and the value, using the Java Collections. The problem is that I have to use Set> that is not a clean solution,…
0
votes
1 answer

Efficient selection of turtle subsets that satisfy given condition on turtle properties

I was wondering if there is an efficient method for selecting subsets of agents that satisfy some conditions on their properties in one shot (i.e., a multi-set of agents). I will try to explain with an example. Let us suppose that we have three…
0
votes
6 answers

Algorithm or solution for selecting possible combinations of menu items within a budget

Using Java 8, I am trying to figure out an algorithm / proper solution to see how to store a List with buyable items within a certain allocated budget. Suppose, a Map which contains the following keys / values: Map
PacificNW_Lover
  • 4,746
  • 31
  • 90
  • 144
0
votes
1 answer

How to make a multiset from multiple sets in R?

I have multiple sets and I would like to build their multiset in R. Is there any solution for that? For example, I have 3 sets: set1 <- c(1,3,6) set2 <- c(1,2,6,7,9) set3 <- c(1,3,7) and I would like to have a multiset like multiset =…
Amin Kaveh
  • 117
  • 6
0
votes
1 answer

Is there a way to compare multiset iterators?

I am wondering if there is a way to compare multiset iterators? I am interested in doing something like the following: std::multiset mt{1,1,1,1,3,4,5}; auto it1 = mt.find(3); auto it2 = mt.find(1); cout << (it1 < it2) << endl;…
24n8
  • 1,898
  • 1
  • 12
  • 25
0
votes
1 answer

polymorphism between set and multiset in c++

Is there a way using polymorphism to have a generic for set and multiset? as follows. Note: but only for sets, (set, multiset) template void foo(parent_set &s) { // do something } // main set s1 = {1, 2, 3, 4,…
0
votes
1 answer

std::multiset intersection compilation error

I'm trying to find the intersection of 2 multisets of objects using std::set_intersection function. #include #include struct Interval { double bottom; double top; }; struct cmp_interval { bool operator()(Interval a,…
Jamāl
  • 121
  • 1
  • 6
0
votes
1 answer

How can I remove all occurrences of a sub-multiset in Isabelle?

So I'd like to define a function (we'll call it applied) that would get rid of all occurrences of a sub-multiset within another multiset and replace each occurrence with a single element. For example, applied {#a,a,c,a,a,c#} ({#a,a,c#}, f) =…
Kookie
  • 328
  • 4
  • 14
0
votes
1 answer

Haskell :How to define an instance of the constructor class Foldable for the constructor

I've just started Haskell and after reading Foldable documentation I'm trying to Define an instance of the constructor class Foldable for the constructor ListBag where : newtype ListBag a = LB [(a,Int)] deriving (Show,Eq) To this aim, I have binary…
0
votes
1 answer

C++: How to create a multiset of objects of a class?

Here is my class declaration: class Person { private: string name; public: void showData() { cout << name << endl; } void insertData() { cin >> name; } bool operator<(Person p) { return…
0
votes
1 answer

Difference between multiset(a[..a.Length]) and multiset(a[..]) in Dafny

I'm trying to figure something out in dafny. Given 2 arrays a and b, my assertions, invariants, post conditions, etc in the form of: multiset(a[..]) == multiset(b[..]); fails but multiset(a[..a.Length]) == multiset(b[..b.Length]) succeeds. I'm…
Jamesyyy
  • 109
  • 1
  • 6
0
votes
1 answer

C++ multiset error C2676: binary '-': 'const _BidIt' does not define this operator or a conversion to a type acceptable to the predefined operator

I have the following C++ classes: class MyClass { private: int _id; unsigned long long _timestamp; public: MyClass(int id, unsigned long long ts) : _id(id), _timestamp(ts) {} bool operator<(const MyClass& other) const { return _timestamp…
Kok How Teh
  • 3,298
  • 6
  • 47
  • 85