Set
A set is a collection of distinct elements in which membership, rather than order or duplicate occurrences, defines the collection.
Python How-To
A set is a Python collection of distinct elements without a defined positional order.
- How it is used
- Uses sets to store unique values, test membership, and compare collections such as lists.
- How deep it goes
- Explains hashability and hash-table lookup, then demonstrates relationship operations and method-versus-operator trade-offs.
- Examples
- Compares recommended and client stock lists, combines task sets, and converts repeated numbers into unique values.
- What you can do after
- Apply Python set methods and operators to check membership, compare collections, and select unique or shared values.
Get Programming with JavaScript Next: New features of ECMAScript 2015, 2016, and beyond
A JavaScript collection type that stores unique values and provides iterable traversal over its elements.
- How it is used
- Keeps unique values for membership-driven tasks, such as tracking rendered tiles or building a card deck.
- How deep it goes
- Works through construction, membership updates, array conversion, and shuffling; stops short of implementing Set internals.
- Examples
- Uses duplicate colors, a tile-rendering loop, and a shuffled card deck.
- What you can do after
- Build it from scratch to maintain unique values, update membership, and convert through an array when ordering operations require one.
Julia as a Second Language
A set is a collection that stores distinct elements without relying on positional order.
- How it is used
- Uses sets to organize overlapping categories and search products or bug reports by multiple criteria.
- How deep it goes
- Explains construction, membership, iteration, set operations, and array search tradeoffs through worked examples.
- Examples
- Works through screw catalog categories and bug tracker attributes, with photo albums as another organizing problem.
- What you can do after
- Apply it via Julia’s Set constructor, membership tests, and set operations to select distinct items by overlapping criteria.
The Well-Grounded Data Analyst
A set is an unordered collection of distinct elements that supports membership testing and set operations.
- How it is used
- Uses sets to validate schemas and compare cleaned reference lists during exploratory data analysis.
- How deep it goes
- Demonstrates intersection and difference through short Python expressions, stopping short of set internals or formal operation details.
- Examples
- Compares survey columns with dictionary question names and cities with customer city labels.
- What you can do after
- Apply it via Python to identify shared or unmatched values in analytical datasets.
Data-Oriented Programming in Java
A set is a collection that represents distinct elements without treating duplicate occurrences as separate members.
- How it is used
- Expresses that cart members should be unique while exposing the limits of Java’s whole-object equality.
- How deep it goes
- Develops a worked Java design comparison, stopping short of treating Set as sufficient for attribute-subset identity.
- Examples
- Uses active and saved cart item sets, duplicate identifiers, differing prices, and a ProductSeller-keyed map.
- What you can do after
- Evaluate whether Set expresses a domain’s uniqueness rule or whether Map better captures identity based on selected attributes.
Fast Python: High performance techniques for large datasets
- How it is used
- Uses sets to speed repeated membership searches where duplicate occurrences are unnecessary.
- How deep it goes
- Explains duplicate reduction and approximate hash-lookup complexity, but defers hash-function design details.
- Examples
- Benchmarks weather-station temperatures and equal-size collections of distinct integers, including present and absent searches.
- What you can do after
- Apply Python sets to repeated membership checks and evaluate the trade-off against ordered lists for interval searches.
Read how Fast Python: High performance techniques for large datasets explains set →
Python Workout, Second Edition
A set is an unordered collection of distinct hashable values in Python.
- How it is used
- Deploys sets for uniqueness, membership lookup, dictionary-key comparison, and sequence-based data-cleaning exercises.
- How deep it goes
- Works through construction, mutation, set operators, subset testing, and list-hashability mistakes without descending into implementation internals.
- Examples
- Uses duplicate numbers, dictionary-key diffs, unique words in files, server logs, directory extensions, and vowel detection.
- What you can do after
- Apply it via Python's built-in set operations to deduplicate sequences, compare collections, and count distinct values.
100 Java Mistakes and How to Avoid Them
A set is a collection abstraction that stores distinct elements without duplicate membership.
- How it is used
- Uses sets to expose equality, null-search, and mutation mistakes in Java collection code.
- How deep it goes
- Explains equality contracts, null dispositions, and hash-bucket lookup consequences through focused failure cases.
- Examples
- Demonstrates Set.of() migration and a mutated List<String> that HashSet can no longer find.
- What you can do after
- Diagnose/debug with it by guarding null lookups and identifying mutated hash-based set elements.
Read how 100 Java Mistakes and How to Avoid Them explains set →
ScyllaDB in Action
A set is a collection data type that stores distinct elements without associating them with keys.
- How it is used
- Models a restaurant article’s gallery as a collection of distinct image values.
- How deep it goes
- Explains declaration, literals, queries, addition, removal, and idempotency, while deferring large or unbounded collections to tables.
- Examples
- Demonstrates text sets {'a', 'b', 'c'} and an article image gallery typed SET<FROZEN<image>>.
- What you can do after
- Apply CQL set literals and + or - updates to store distinct, repeat-safe collection values.
Python Workout: 50 ten-minute exercises
A set is a Python collection of distinct, unordered elements.
- How it is used
- Uses sets to enforce uniqueness, perform membership lookups, compare dictionary keys, and summarize repeated input values.
- How deep it goes
- Explains construction, mutation, uniqueness, hashability, key union, and practical use, without descending into implementation internals.
- Examples
- Demonstrates duplicate-number removal, dictionary-key differences, unique-word counting, log analysis, file extensions, and vowel-based word filtering.
- What you can do after
- Apply it via Python's set, add, update, union, and length operations to deduplicate data and compare collections.
Read how Python Workout: 50 ten-minute exercises explains set →
Grokking Algorithms, Second Edition
A set is a collection that stores distinct elements without assigning significance to their insertion order.
- How it is used
- Tracks unique items and prevents repeated processing in graph searches, shortest-path algorithms, and greedy coverage selection.
- How deep it goes
- Defines uniqueness and demonstrates union, intersection, difference, and algorithmic tracking without examining set internals.
- Examples
- Uses duplicate numbers, fruit and vegetable collections, graph-processing records, and radio-station coverage sets.
- What you can do after
- Apply it via Python to remove duplicates, compare collections, and record items or nodes already handled.
The Well-Grounded Rubyist, Fourth Edition
A set is a collection data structure that stores distinct values without representing them as an indexed sequence.
- How it is used
- Organizes unique values and supports membership relationships and set algebra within Ruby’s collection toolkit.
- How deep it goes
- Explains construction, transformation, mutation, algebra, and subset testing, while deferring deeper Enumerable behavior.
- Examples
- Uses state names, transformed personal names, duplicate insertion, set algebra, merging, and subset comparisons.
- What you can do after
- Apply it via Ruby’s Set class to create unique collections, mutate membership, compare sets, and perform set algebra.
Read how The Well-Grounded Rubyist, Fourth Edition explains set →
Secrets of the JavaScript Ninja, Third Edition
A collection of unique items with no duplicate membership.
- How it is used
- Stores distinct items for membership checks and avoids duplicate callbacks in event-related collections.
- How deep it goes
- Defines Set construction, membership, duplicate handling, reference identity, and set operations without detailing implementation internals.
- Examples
- Uses duplicate ninja names, callback deduplication, and ninja-samurai intersection to demonstrate Set behavior.
- What you can do after
- Apply the built-in Set API to deduplicate items, check membership, and combine or compare collections.
Read how Secrets of the JavaScript Ninja, Third Edition explains set →
JavaScript in Depth
A JavaScript collection that stores unique values and retains its entries until they are removed or otherwise released.
- How it is used
- Explains how property assignment is implemented through accessor setters or controlled data-property updates.
- How deep it goes
- Distinguishes descriptor attributes and assignment modes, but stops short of broader runtime implementation details.
- Examples
- Uses drawer.contents to demonstrate getter and setter functions, descriptor inspection, and private backing storage.
- What you can do after
- Diagnose assignment behavior by inspecting descriptors and distinguishing setters from writable data properties.
Secrets of the JavaScript Ninja, Second Edition
A JavaScript collection of unique values.
- How it is used
- Uses sets to represent collections of distinct items and avoid duplicate entries.
- How deep it goes
- Defines object-based imitations and demonstrates Set creation, membership, insertion, size, and iteration, while only foreshadowing set operations.
- Examples
- Demonstrates a set of ninja names, repeated entries, membership checks, additions, size, and insertion-order iteration.
- What you can do after
- Apply the built-in Set constructor to retain unique values, check membership, add items, inspect size, and iterate.
Read how Secrets of the JavaScript Ninja, Second Edition explains set →
Tiny Python Projects: Learn coding and testing with puzzles and games
A set is a collection that contains distinct elements without assigning significance to their order.
- How it is used
- Uses sets to collect unique words while generating passwords from one or more input files.
- How deep it goes
- Explains creation, insertion, deduplication, display, and intersection, while deferring the wider set API to documentation.
- Examples
- Demonstrates unique words from files and shared numbers from overlapping integer ranges.
- What you can do after
- Apply it via Python to deduplicate processed data and find shared values between collections.
Read how Tiny Python Projects: Learn coding and testing with puzzles and games explains set →
Spring in Action, Sixth Edition
A set is a collection that stores distinct elements without permitting duplicates.
- How it is used
- Uses sets to guarantee unique ingredient references in reactive Taco persistence.
- How deep it goes
- Explains uniqueness, HashSet initialization, ID references, and array persistence, but does not develop set internals.
- Examples
- Demonstrates Set<Long> ingredient IDs in Taco and an ingredient_ids database array.
- What you can do after
- Apply sets via Java HashSet to prevent duplicate ingredient IDs in a Spring Data R2DBC entity.
Software Engineering for Data Scientists
A set is an unordered collection of distinct elements that supports efficient membership testing and set operations.
- How it is used
- Speeds repeated membership checks in large or static collections.
- How deep it goes
- Explains list-versus-set lookup behavior, O(1) and O(n) runtimes, benchmark results, and duplicate limits.
- Examples
- Uses 100-million-integer timing listings and an artist-name exercise comparing list and set searches.
- What you can do after
- Apply Python sets to accelerate repeated membership checks and compare their runtime with lists.
Read how Software Engineering for Data Scientists explains set →
Coding with AI
A set is an unordered collection data structure that stores unique elements and supports efficient membership operations.
- How it is used
- Uses uniqueness to generate a randomized collection of question IDs for an application workflow.
- How deep it goes
- Explains uniqueness through a repeated-selection implementation but stops short of detailed set internals.
- Examples
- Demonstrates selecting 35 unique question IDs from database results and updating an application call.
- What you can do after
- Apply via Python to collect unique values while checking input availability and returned data shape.
Also covered in
- Natural Language Processing in Action, Second Edition
- The Quick Python Book, Fourth Edition
- Terraform in Depth: Infrastructure as Code with Terraform and OpenTofu
- Java Persistence with Spring Data and Hibernate epub
- 100 Go Mistakes and How to Avoid Them
- React Hooks in Action: With Suspense and Concurrent Mode
- Learn AI-Assisted Python Programming, Second Edition
- Grokking Data Structures
- Go in Action, Second Edition
- Kotlin in Action, 2E
- Essential TypeScript 5, Third Edition
- Software Design for Python Programmers
What to know first
- MapA map is an associative data structure that stores key-value associations and supports retrieving values by key.
- listA list is an ordered collection of elements arranged in a sequence.
- arrayAn array is an ordered collection of elements organized in one or more dimensions and accessible by position or index.
- PythonPython is a high-level, general-purpose, dynamically typed programming language with readable syntax and support for multiple programming paradigms.
Related concepts
- set unionproduced by · Set union is the operation that produces a set containing every element belonging to at least one of its operand sets.
- MapSetincludes · MapSet is an Elixir collection implementing a set of unique values of any type.
Questions about set
What is set?
A set is a collection of distinct elements in which membership, rather than order or duplicate occurrences, defines the collection.
Which Manning books explain set?
Python How-To, Get Programming with JavaScript Next: New features of ECMAScript 2015, 2016, and beyond, Julia as a Second Language, The Well-Grounded Data Analyst, Data-Oriented Programming in Java, Fast Python: High performance techniques for large datasets, Python Workout, Second Edition, 100 Java Mistakes and How to Avoid Them and 11 more.
What should I know before learning set?
Manning books that teach set usually introduce Map, list, array and Python first.
What kinds of set are there?
Kinds of set include frozenset and MapSet.
What is set a kind of?
Set is a kind of MongoDB collection. A MongoDB collection is a grouping of documents within a database that does not require a fixed relational schema.
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.


















