liveBook · Manning

Bag

A bag, or multiset, is an unordered collection that permits duplicate elements and preserves their multiplicities.

How 2 Manning books explain it

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.

Read how Grokking Data Structures explains bag →

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

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.