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.

164 questions
2
votes
1 answer

Bag Class Implementation in Java/Using Array

I am having some difficulty understanding my assignment and I just want to make sure I am doing it correctly and would like to get another pair of eyes on my code. My assignment is as follows: Implement a Bag class using an Array as the base data…
sealsix
  • 73
  • 1
  • 2
  • 9
2
votes
1 answer

Maybe bag in golang (mismatched types string and string)

Don't ask me why I'm doing this, just tell me how it's possible: gopls error: mismatched types string and string type Mapsi2[T string | int | float32 | float64] struct { Keys []string Values []T } func (mapsi Mapsi2[string]) SetValue(key…
Ruslan
  • 31
  • 5
2
votes
1 answer

Why are bags considered unordered?

Bags are stored in arrays. I do understand that we can change the size of bags as we want etc.. However, since it is stored in array, it basically has an index number isn't it? In this case, why do we still say that it is unordered?
Yuan
  • 65
  • 7
2
votes
1 answer

how to extract camera info and images from ros bag?

I have a ros bag and its information as following path: zed.bag version: 2.0 duration: 3:55s (235s) start: Nov 12 2014 04:28:20.90 (1415737700.90) end: Nov 12 2014 04:32:16.65 (1415737936.65) size: 668.3…
Xinjun.Ma
  • 41
  • 3
2
votes
3 answers

Why would I want to put my objects in a bag?

I just saw an SO question about the System.Collections.ConcurrentBag class, and I've seen the ViewBag property of the Controller in ASP.NET MVC. In my experience, I've learned that it's easier to use people's code if you understand what exactly…
smartcaveman
  • 41,281
  • 29
  • 127
  • 212
2
votes
2 answers

Bag remove() method

I was given Bag class like this import java.util.Iterator; import java.util.NoSuchElementException; public class Bag implements Iterable { private int N; // number of elements in bag private…
efedoganay
  • 133
  • 2
  • 11
2
votes
1 answer

XACML Bags operations

Assume we have a bag of booleans. Is there a function that can tell whether the number of "true" values is larger than some constant (e.g., 5)? I came across "n-of" function, but it requires multiple separate attributes as an input and not a bag...…
Michael
  • 357
  • 2
  • 12
2
votes
3 answers

O(n) list subtraction

When working on an AoC puzzle, I found I wanted to subtract lists (preserving ordering): def bag_sub(list_big, sublist): result = list_big[:] for n in sublist: result.remove(n) return result I didn't like the way the list.remove…
wim
  • 338,267
  • 99
  • 616
  • 750
2
votes
2 answers

Bag implementation as array in Java

I'm supposed to implement a bag data structure (also called a multiset), an unordered collection of homogeneous values (any Java object, excluding null) that may have duplicates, for a project. I've done extensive searching on the internet but have…
user481211
  • 37
  • 1
  • 1
  • 7
2
votes
1 answer

Fluent Nhibernate - How do I set the name attribute of a set or bag collection?

This is a set collection: How do I set the name attribute?
Rookian
  • 19,841
  • 28
  • 110
  • 180
2
votes
1 answer

Apache Pig - Not able to read the bag

I am trying to read the comma separated data using PIG as below: grunt> cat script/pig/emp_tuple1.txt 1,kirti,250000,{(100),(200)} 2,kk,240000,{(100),(300)} 3,kumar,200000,{(200),(400)} 4,shinde,290000,{(200),(500),(300),(100)} 5,shinde k…
Kirti
  • 31
  • 2
2
votes
1 answer

Nhibernate custom loader for collection

Im really hoping someone can help with this, have been trying various combinations for a day and a half now.... Basically I have a some hierarchical data stored in a single table, the usual parentID maps to a row id scenario. I have modelled a…
kmoo01
  • 85
  • 7
2
votes
0 answers

Dense SIFT Bag of Features

I am trying to do dense SIFT feature extraction with bag of features (BoF) using OpenCV. The idea is to follow this tutorial but just a little change to use dense SIFT features instead. As you know, the first part in the BoF paradigm, we create the…
tarmizi
  • 173
  • 3
  • 18
2
votes
1 answer

The use of Bags for Adjacency Lists in Graphs

What is the purpose of using a bag object for the entries of an adjacency list in a graph? Why not use a data structure like a stack or a queue?
Paul Warnick
  • 903
  • 2
  • 13
  • 26
2
votes
1 answer

NHibernate mapping - self referencing: parent and children

I am trying to have this kind of Model: public class Activity { public virtual int ID { get; set; } public virtual int? ParentID { get; set; } public virtual int? RootID { get; set; } public virtual Activity Parent { get; set; } …
1 2
3
10 11