8.12

4 Collections🔗ℹ

 (require rebellion/collection) package: rebellion

Rebellion provides several different types of collections. A collection is a container for values, like a list or a hash table. Different types of collections have different properties, for example sets are unordered and have no duplicate elements. For advice on how to choose the right collection type, see Choosing Collections.

Collections may be mutable, immutable, or unmodifiable. A mutable collection can be changed and updated by clients. Immutable collections never change: instead, operations on immutable collections return modified copies of the original collection. Unmodifiable collections lie between these two extremes. An unmodifiable collection cannot be changed by clients, but does not promise that it will not change on its own.

Different collections need not necessarily have different state. A collection view is a collection whose implementation defers to the state of some other collection. Collection views can be used for a wide variety of purposes, including efficiently operating on a subset of a collection, constructing a thread-safe wrapper around a collection meant to be shared between threads, or adapting one collection to the interface of another. Collection views come in a few main varieties:

    4.1 Choosing Collections

      4.1.1 To Key or Not to Key

      4.1.2 Collection Cheat Sheet

    4.2 Entries

    4.3 Lists

    4.4 Vectors

    4.5 Vector Builders

      4.5.1 Legacy APIs

    4.6 Immutable Vectors

    4.7 Sets

    4.8 Hash Tables

    4.9 Multisets

      4.9.1 Querying Multisets

      4.9.2 Persistently Updating Multisets

      4.9.3 Multiset Iteration and Comprehension

      4.9.4 Multiset Conversions

    4.10 Multidicts

      4.10.1 Persistently Updating Multidicts

      4.10.2 Querying Multidicts

      4.10.3 Multidict Conversions

      4.10.4 Multidict Iterations and Comprehensions

    4.11 Association Lists

    4.12 Sorted Sets

      4.12.1 Constructing Sorted Sets

      4.12.2 Querying Sorted Sets

      4.12.3 Sorted Set Views

        4.12.3.1 Synchronized Sorted Sets

      4.12.4 Modifying Sorted Sets

      4.12.5 Sorted Set Builders

    4.13 Sorted Maps

      4.13.1 Constructing Sorted Maps

      4.13.2 Iterating Sorted Maps

      4.13.3 Querying Sorted Maps

      4.13.4 Sorted Map Views

      4.13.5 Modifying Sorted Maps

      4.13.6 Sorted Map Builders

    4.14 Range Sets

      4.14.1 Constructing Range Sets

      4.14.2 Iterating Range Sets

      4.14.3 Querying Range Sets

      4.14.4 Range Set Views

      4.14.5 Modifying Range Sets

    4.15 Keysets

    4.16 Records

      4.16.1 Record Fields

    4.17 Tables

      4.17.1 Table Iteration and Comprehensions