📦

Collections

CategoryTypes

Overview

Collections or containers are used to create and manage groups of related objects.

Fixed containers have a fixed capacity. They are useful for creating and working with a fixed number of objects.

Dynamic containers are more flexible. They are used for creating and working with a dynamic number of objects.

Associative containers use keys to uniquely identify objects.

In C++, the standard library provides several types of containers.

In C#, the Collections.Generic namespace provides various collections of objects.

Containers

Array

An array is a static collection of elements.

It's implemented as a fixed single block of memory.

Advantages

Disadvantages

Use cases

C++

C++/CX

C#

Vector

A vector is a dynamic collection of elements.

It's implemented as a single block of memory.

Advantages

Disadvantages

Use cases

C++

C++/CX

C#

List

A list is a dynamic collection of elements.

It's implemented as a double-linked list.

Advantages

Disadvantages

Use cases

C++

C#

Intrusive List

An intrusive list is a dynamic collection of elements.

It's implemented as a double-linked list that does not contain any data.

Decouples memory allocation from the container itself.

The list can be implemented as a circular list.

Advantages

Disadvantages

https://www.gamasutra.com/view/news/128568/InDepth_Intrusive_Lists.php

https://github.com/Edgarins29/Doom3/blob/master/neo/idlib/containers/LinkList.h

Set

A set is a dynamic collection of unique elements.

It's typically implemented as a binary search tree.

Advantages

Disadvantages

Use cases

C++

C#

Vector Set

A vector set is a set implemented like an ordered vector.

Advantages

Disadvantages

Use cases

C#

Map

A map is a dynamic collection of key / value elements.

It's typically implemented as a binary search tree.

Advantages

Disadvantages

Use cases

C++

C++/CX

C#

Vector Map

A vector map is a map implemented like an ordered vector.

It's implemented as either a vector of key / value pairs or as separate vectors of keys and values.

Advantages

Disadvantages

Use cases