Skip to main content

Mojo package

collections

Core data structures: List, Dict, Set, Optional, plus specialized collections.

The collections package provides fundamental data structures for organizing and managing data in Mojo programs. It includes general-purpose collections like dynamic arrays, hash maps, and sets, along with specialized structures for specific use cases. These types form the foundation for most data manipulation in Mojo and integrate seamlessly with the language's iteration and memory management systems.

Use this package for general data storage and manipulation, implementing algorithms, building custom data structures, or any task requiring collection types beyond basic primitives.

Packages

  • string: Provides comprehensive Unicode string functionality.

Modules

  • bitset: Provides a compact, grow-only set of non-negative integers.
  • counter: Defines the Counter type.
  • deque: Defines the Deque type.
  • dict: Defines Dict, a collection that stores key-value pairs.
  • inline_array: Provides a fixed-size array implementation with compile-time size checking.
  • interval: A self-balancing interval tree is a specialized binary search tree designed to efficiently store and query intervals.
  • linked_list: Implements a doubly-linked list data structure.
  • list: Defines the List type.
  • optional: Defines Optional, a type modeling a value which may or may not be present.
  • set: Implements the Set datatype.

Was this page helpful?