Collections - bali-nebula/go-component-framework GitHub Wiki

⚠️ This project is still under development and is for reference purposes only. If you are interested in this project or have suggestions on how to improve it feel free to contact us at [email protected].

Overview

A collection is a type of mutable entity that consists of a sequence of zero or more component values that may be iterated over. The component values can be added and removed from a collection. In fact, a value may be contained in multiple collections at the same time. The lifetime of a component value is not necessarily tied to the lifetime of the collection that contains it. Different types of collections serve different purposes, the following flow chart shows how to choose the right collection type for your needs.

Flow Chart

Click on a specific collection type heading below to get design and implementation details for that collection type.

Catalogs

A catalog maintains a sequence of associations between primitive keys and component values. The order of the associations within the catalog will be the same order in which they were added to the catalog, but the associations can be sorted into their natural order if desired.

Click here for the Bali representation of catalogs.

Lists

A list maintains a sequence of component values. The order of the values within the list will be the same order in which they were added to the list, but again the component values can be sorted into their natural order if desired.

Click here for the Bali representation of lists.

Queues

A queue maintains a sequence of component values that are added to and removed from the queue using first-in-first-out (FIFO) semantics. It behaves like a line of people waiting to be served. The first person in line is served first.

Click here for the Bali representation of queues.

Sets

A set maintains an ordered sequence of component values that are automatically placed in their natural order by the set. A set does not allow duplicate component values to be added.

Click here for the Bali representation of sets.

Stacks

A stack maintains a sequence of component values that are added to and removed from the stack using last-in-first-out (LIFO) semantics. It behaves like a dish stack in a cafeteria where all dishes are added and removed from the top of the stack.

Click here for the Bali representation of stacks.