Questions tagged [bag]

An unordered collection that can contain duplicates

Contrast with the Set data structure.

Typically, a bag can count the number of a particular item that it contains. For example, 5 apples, 2 oranges, 1 banana.

153 questions
515
votes
16 answers

Hibernate throws MultipleBagFetchException - cannot simultaneously fetch multiple bags

Hibernate throws this exception during SessionFactory creation: org.hibernate.loader.MultipleBagFetchException: cannot simultaneously fetch multiple bags This is my test case: Parent.java @Entity public Parent { @Id …
blow
  • 11,391
  • 23
  • 66
  • 104
28
votes
3 answers

Are there any implementations of multiset for .Net?

I'm looking for a .Net implementation of a multiset. Can anyone recommend a good one? (A multiset, or bag, is a set that can have duplicate values, and on which you can do set operations: intersection, difference, etc. A shopping cart for instance…
dan-gph
  • 14,921
  • 12
  • 55
  • 75
21
votes
7 answers

org.hibernate.loader.MultipleBagFetchException: cannot simultaneously fetch multiple bags

Following is my code Here I am using multiple lists to fetch data from database. On fetching data from hql query it is showing exception. Pojo Class public class BillDetails implements java.io.Serializable { private Long billNo; // other…
xrcwrn
  • 4,867
  • 17
  • 58
  • 117
12
votes
5 answers

How might a class like .NET's ConcurrentBag be implemented?

I find myself very intrigued by the existence of a ConcurrentBag class in the upcoming .NET 4.0 framework: Bags are useful for storing objects when ordering doesn't matter, and unlike sets, bags support duplicates. My question is: how might…
Dan Tao
  • 119,009
  • 50
  • 280
  • 431
11
votes
3 answers

hibernate empty collection in component

I have a component mapped using Hibernate. If all fields in the component in the database are null, the component itself is set to null by hibernate. This is the expected behavior and also what I need. The problem I have, is that when I add a bag to…
Jurgen Hannaert
  • 943
  • 8
  • 22
9
votes
1 answer

Reasons for using a Bag in Java

I am currently studying about Algorithms & Data Structures and while I was reading over the Book of Algorithms 4th edition, I discovered the Bag data-structure together with the Stack and Queue. After reading the the explanation of it, it is still…
Flika205
  • 404
  • 3
  • 14
8
votes
2 answers

total method and the sigil of a Bag variable in Perl 6

We can use the total method to know the sum of all the weights in a Bag. > my $b = (1,2,1).Bag Bag(1(2), 2) > $b.total 3 But if we use the % sigil instead of $ for our Bag, we get an error message. > my %b = (1,2,1).Bag {1 => 2, 2 => 1} >…
Eugene Barsky
  • 5,332
  • 11
  • 32
8
votes
4 answers

What are the advantages of using a Bag data structure over others like Set or Linkedlist for a graph implementation API

Here is the sample code to go with the question. This API is trying to implement a graph with an adjacency-list representation as an array of Bags indexed by each of vertices in the graph. public class Graph{ private final int V; //no. of…
deepak
  • 365
  • 1
  • 2
  • 8
7
votes
4 answers

Apply CountVectorizer to column with list of words in rows in Python

I made a preprocessing part for text analysis and after removing stopwords and stemming like this: test[col] = test[col].apply( lambda x: [ps.stem(item) for item in re.findall(r"[\w']+", x) if ps.stem(item) not in stop_words]) train[col] =…
Yury Wallet
  • 972
  • 10
  • 17
7
votes
1 answer

How do I convert a video or a sequence of images to a bag file?

I am new to ROS. I need to convert a preexisting video file, or a large amount of images that can be concatenated into a video stream, into a .bag file in ROS. I found this code online:…
ksivakumar
  • 438
  • 1
  • 5
  • 16
6
votes
1 answer

Truly unordered foldable bag

I want a Bag container which hides its 'real' order from its clients. It also must be fully polymorphic, that is shouldn't require any constraints over its element type. I found at least three implementations of bags: Bag module from ghc package,…
nponeccop
  • 13,141
  • 1
  • 39
  • 101
5
votes
2 answers

Is there a bag implementation in Ruby?

Is there an implementation of the bag collection (a collection like a set, that kept count of how many times an object is inserted)?
Guillaume Coté
  • 2,551
  • 2
  • 17
  • 28
5
votes
0 answers

Bag Of Words For Text C#

Is there any tool for creating a Bag of Words model and computing features vector for strings in C#? Something like pythons CountVectorizer: vectorizer = CountVectorizer(analyzer = "word", tokenizer = None, …
Kostya
  • 109
  • 6
5
votes
4 answers

Is it considered bad form to convert between collection types?

I hope that this question is specific enough to be deemed fit for StackOverflow. I checked the FAQ and I think this qualifies, since it is specific and related to programming. I'm implementing a complex data mining algorithm (FP-growth) in Java. …
The111
  • 5,459
  • 4
  • 33
  • 54
5
votes
1 answer

Exploring an algorithm to find minimum chain containing certain items

Sorry, I cannot come up with the name of an algorithm or problem for the following algorithm. I will state the problem and then what I have tried and perhaps someone can point me in the right direction. Imagine you have a bag of items (unordered,…
demongolem
  • 8,796
  • 36
  • 82
  • 101
1
2 3
10 11