Bag
A bag, or multiset, is an unordered collection that permits duplicate elements and preserves their multiplicities.
Grokking Data Structures
Bag is the book's class that wraps an underlying linked list and exposes operations for inserting and traversing bag elements.
- How it is used
- Collects elements for tasks such as counting totals or categories when processing order does not matter.
- How deep it goes
- Defines the two-operation interface and shows a Python linked-list wrapper, without requiring a particular iteration order.
- Examples
- Uses marbles to show insertion, traversal, and counts that remain valid despite a change in iteration order.
- What you can do after
- Build it from scratch as a Python class backed by a singly linked list, with insertion and traversal methods.
Java Persistence with Spring Data and Hibernate epub
A persistent unordered collection that permits duplicate element values and does not assign a collection index to them.
- How it is used
- Maps unordered persistent collections whose duplicate values are meaningful or whose one-to-many insertion path should avoid loading existing elements.
- How deep it goes
- Explains Java mappings, surrogate collection keys, duplicate handling, lazy insertion, and multiple-bag fetch limits.
- Examples
- Uses bags of strings, embeddable images, and bidirectional Item-to-Bid associations with duplicate-addition and SQL-loading tests.
- What you can do after
- Apply it via Hibernate annotations to map duplicate-capable collections and assess their loading, fetching, and schema consequences.
Read how Java Persistence with Spring Data and Hibernate epub explains bag →
Related concepts
- linked listuses · A linked list is an ordered sequence of nodes connected by links or references rather than stored as one contiguous sequence.
- associative containerkind of · An associative container is a data structure that organizes elements for retrieval by keys rather than solely by positional order.
- abstract data typekind of · An abstract data type specifies values, operations, and behavior independently of a particular representation or implementation.
- containerkind of · A container is a structure or entity that holds, groups, or packages other data or elements.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.

