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
3
votes
2 answers

Seg Error while erasing from multiset C++

I don't know whats making this code give an error. It's a simple multiset. No compilation errors, but segmentation fault on the machine while executing. g++ version : 4.8.2 Machine : Ubuntu 14.04 #include #include using namespace…
phraniiac
  • 384
  • 1
  • 3
  • 16
3
votes
3 answers

Thread-safe Multiset

I have been googling for awhile and can't believe that I can't find it, but how can I safely implement a Multiset that will be accessed by multiple threads for both reading and writing. The multiset is storing views to certain pages, and will be a…
oberger
  • 1,217
  • 2
  • 16
  • 31
3
votes
1 answer

Json Multiset vs ArrayList

I have Multiset objects, which I am serializing as Json. I am doing this using Gson as follows: Multiset mset = ... ; Gson gson = new Gson(); Files.write(Gson.toJson(mset), new File(abosulte_path_string),…
Chthonic Project
  • 8,216
  • 1
  • 43
  • 92
3
votes
5 answers

Can you encode to less bits when you don't need to preserve order?

Say you have a List of 32-bit Integers and the same collection of 32-bit Integers in a Multiset (a set that allows duplicate members) Since Sets don't preserve order but List do, does this mean we can encode a Multiset in less bits than the List? If…
Pyrolistical
  • 27,624
  • 21
  • 81
  • 106
3
votes
1 answer

How to instantiate an comparison function (functor) when defining a map/set?

I'm using a funciton object to specify a comparison function for map/set: struct CompareObject { bool operator()(Node* const n1, Node* const n2) const; }; As far as I understand defining a set like this will not create any instance of…
msgmaxim
  • 788
  • 2
  • 8
  • 15
3
votes
1 answer

Generate all possible permutations of subsets containing all the element of a set

Let S(w) be a set of words. I want to generate all the possible n-combination of subsets s so that the union of those subsets are always equal to S(w). So you have a set (a, b, c, d, e) and you wan't all the 3-combinations: ((a, b, c), (d),…
Luke Skywalker
  • 1,464
  • 3
  • 17
  • 35
3
votes
2 answers

C++: use own class in a multiset container

at first I'm new here and English isn't my native language so apologize for any grammatical failures but I find this community really nice so I will try to ask my question as precise as I can. I want to add my own class object into a stl container…
tzwickl
  • 1,341
  • 2
  • 15
  • 31
3
votes
1 answer

Distance between multiset iterator

Can we find the distance between two iterator in multiset with a complexity of less than O(n)? I tried to use the std::distance() function provided with iterator header. But its internal implementation is O(n) for multiset iterator.
rohangulati
  • 251
  • 1
  • 4
  • 12
3
votes
1 answer

workaround for ORA-03113: end-of-file on communication channel with CAST MULTISET

The call to TEST_FUNCTION below fails with "ORA-03113: end-of-file on communication channel". A workaround is presented in TEST_FUNCTION2. I boiled down the code as my actual function is far more complex. Tested on Oracle 11G. Anyone have any idea…
Jefferstone
  • 41
  • 1
  • 1
  • 3
2
votes
3 answers

Find disjoint sets in a table with nested table colum sql oracle

these are the sample data : CREATE OR REPLACE TYPE CourseList AS TABLE OF VARCHAR2(64); CREATE TABLE department ( courses CourseList) NESTED TABLE courses STORE AS courses_tab; INSERT INTO department (courses)VALUES…
rafa
  • 21
  • 2
2
votes
1 answer

Is it possible to pass a constructor that takes an argument into a set in C++?

I was wondering if it was at all possible to pass a constructor that takes an argument to a comparison function into a set. For example something like this: class cmp { private: string args_; public: cmp(const string&…
user798774
  • 403
  • 2
  • 8
  • 20
2
votes
2 answers

Std::multiset, keep track of elements' positions inserted

Can I somehow overload any of std::multiset's operators (like you do with '()' to create a custom comapre function) so that when 2 elements in the multiset are swapped, so are another 2 elements from another vector linked to those? I mean, I…
XCS
  • 27,244
  • 26
  • 101
  • 151
2
votes
2 answers

Get first N elements in a C++ multiset

How can I get the first N elements from a multiset structure, without constantly getting the first (.begin()) element and then erasing it? I just want to sum the first N elements without affecting the multiset.
XCS
  • 27,244
  • 26
  • 101
  • 151
2
votes
2 answers

get the number of instances of an element in a guava multiset without iterating

I have a multiset in guava and I would like to retrieve the number of instances of a given element without iterating over this multiset (I don't want to iterate because I assume that iterating takes quite some time, as it looks through all the…
seinecle
  • 10,118
  • 14
  • 61
  • 120
2
votes
1 answer

C++: algorithmic complexity of std::next and std::nth_element for std::multiset

What is the algorithmic (time) complexity of std::next and std::nth_element for a std::multiset in C++? I am interested in the latest gcc implementation, in particular, if it matters. I have a set of numbers in std::multiset and I need to compute…
S.V
  • 2,149
  • 2
  • 18
  • 41