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

Multiset is shown empty on Android

On my Android app I'm using Multiset: Multiset multiset = HashMultiset.create(); I want to convert it to a String using toString() method. The problem is that when it's a single item from every String then it looks OK, but when there are…
Ido Naveh
  • 2,442
  • 3
  • 26
  • 57
0
votes
1 answer

How to insert/remove some elements of same value in a multiset?

Suppose I have a multiset of integers and I want to insert 3, n times into the multiset. I can obviously do it using a for loop but is there any other way to do it using some function in the stl?
aroma
  • 1,370
  • 1
  • 15
  • 30
0
votes
2 answers

Just greater element or just smaller element in a multiset

How do I find just greater or just smaller element than a particular element in a multiset? For example, I have inserted some elements in a multiset, now I want to find the elements just smaller and just greater than some element that I have already…
aroma
  • 1,370
  • 1
  • 15
  • 30
0
votes
2 answers

C++ Multiset count()

So the problem is the following, I have a multiset where I use the std::equal_to operator for comparing the elements, but when I use the count() method it says all 4 elements in my multiset are equal_to my counts parameter. std::multiset<…
Bako
  • 313
  • 1
  • 15
0
votes
1 answer

setting container size in multset

Why there is no constructor to initialize container size in multiset in C++? for example for vector we can initialize container size as vector a(n);
Jay
  • 59
  • 1
  • 8
0
votes
0 answers

Random Selection From Multiset

I have a hashmap with string to integer mappings, and I'm trying to select a random entry from it, weighted on the integer associated with each. The code I'm currently using generates the cumulative sums for all the entries. However, this is…
takra
  • 457
  • 5
  • 15
0
votes
1 answer

SPOJ: 26914 Collecting Mango TLE

Problem statement is available here: http://www.spoj.com/problems/CMG/ My solution doesn't takes more than 0.2 seconds even when I perform 100000 operations but SPOJ gives TLE. SPOJ uses g++ 5.1. I am running code in SunOS - g++ (GCC) 3.4.3. Below…
Dignesh P R
  • 317
  • 3
  • 4
0
votes
0 answers

Combine tuples of tuples if share some elements

I had two tuple of tuples ("one" and "two") and I need to join them. If the subelements of the first tuple(for example, one[0]) in the positions 1, 2, 3, 4 and 5 are equal to the first five elements in the tuple two (for example if one[0][0] ==…
eduzen
  • 131
  • 6
0
votes
1 answer

How to do binary search in a std::multiset without constructing a key_type object?

I have a container like this: // Sort functor struct SortByTime : std::binary_function { bool operator()(const TimeSortableData & a, const TimeSortableData & b) const { …
foraidt
  • 5,519
  • 5
  • 52
  • 80
0
votes
1 answer

vector version of slow multiset

I want to sort my objects according to some criteria (according to how big the items are) My funcSort in multiset slows down calculations and makes the solution does not scale. How can I make it faster? To avoid it I tried to use vector, sort it…
beginh
  • 1,133
  • 3
  • 26
  • 36
0
votes
4 answers

Ensure multiset is reordered when objects change

I have a multiset with a custom predicate function, e.g multiset where MyCompFunc looks at an attribute on the MyClass objects. During the progress of the application, the objects might change in a way that should cause them to…
Mr. Boy
  • 60,845
  • 93
  • 320
  • 589
0
votes
0 answers

Implement multiset using sorted linkedList

Hello I implemented a multiset using a linkedlist and I want to implement the multiset using sorted linkedlist. This is multiset abstract class. import java.io.PrintStream; public abstract class Multiset { /** * Delimiter string for…
John Sick
  • 427
  • 6
  • 15
0
votes
1 answer

Performance of Local PL/SQL Array Vs SQL Call

If I'm using oracle sql and plsql to do computations on an employee, and then selecting more data based on the result of those computations... will it be faster to select the all the data I may need all at once when selecting the employee (assume…
Coat
  • 697
  • 7
  • 18
0
votes
3 answers

Python: zip 2 lists into a dictonary, del the duplicated keys but keep the values

I'm new to Python. I'm trying to zip 2 lists into a dictionary without losing the values of the duplicated keys and keep values as a list in the dictionary. Example: list1 = [0.43, -1.2, 50, -60.5, 50] list2 = ['tree', 'cat', 'cat', 'tree',…
0
votes
1 answer

C++ about multisets and arrays

I have had the displeasure of being saddled with a textbook that isn't written very well. As it stands, I went from enjoying C++ to being physically ill just thinking about it. However, I refuse to quit the class. So the long and short of it is I…
kiddsupreme
  • 115
  • 1
  • 3
  • 13