Collections
MonoGame.Extended
contains Collections
extensions to the C# collections that are useful for game programming.
Installation
Collections
is part of MonoGame.Extended and is distributed via a NuGet package. You can add the NuGet package to your C# project through your IDE of choice (Visual Studio, Xamarin Studio, Rider, etc) or through the Command Line Interface (CLI) using the dotnet command.
Bag
A Bag
is an un-ordered array of items with fast Add
and Remove
properties.
It is much faster than an array when removing items, and takes less space than a linked list.
Bag will resize itself only when it needs to.
Deque
Represents a collection of objects in which elements can be added to or removed either from the front or back. See double ended queue.
Result
keyedCollection
KeyedCollection
is a wrapper around the Dictionary
class where the key is obtained by a delegate.
Object Pooling
An ObjectPool<T>
allows reuse of memory for a group of items to avoid Garbage Collection.
More information is in the Object Pooling documentation.
ObservableCollection
ObservableCollection<T>
manages an IList<T>
of items firing ItemAdded
, ItemRemoved
, Clearing
, and Cleared
events when the collection is changed.
ListExtensions
Adds Shuffle(Random)
to all IList<>
classes.
DictionaryExtensions
Extends all Dictionary<>
classes with GetValueOrDefault(key, default)
.