Class ItemList<TItem>
A generic list of items added by map generation steps, that tracks what generation step added what item.
Inherited Members
Namespace: GoRogue.MapGeneration.ContextComponents
Assembly: GoRogue.dll
Syntax
[DataContract]
public class ItemList<TItem> : IEnumerable<ItemStepPair<TItem>>, IEnumerable where TItem : notnull
Type Parameters
| Name | Description |
|---|---|
| TItem | Type of item being stored. |
Constructors
View SourceItemList()
Creates an empty item list.
Declaration
public ItemList()
ItemList(IEnumerable<ItemStepPair<TItem>>)
Creates a new item list and adds the given items to it.
Declaration
public ItemList(IEnumerable<ItemStepPair<TItem>> initialItems)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<ItemStepPair<TItem>> | initialItems | Initial item/step pairs to add to the list. |
ItemList(int)
Creates an empty item list with the specified initial capacity for items.
Declaration
public ItemList(int initialItemCapacity)
Parameters
| Type | Name | Description |
|---|---|---|
| int | initialItemCapacity |
Properties
View SourceItemToStepMapping
A mapping of each item to the Name of the generation step that created the item.
Declaration
public IReadOnlyDictionary<TItem, string> ItemToStepMapping { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyDictionary<TItem, string> |
Items
The list of items added.
Declaration
public IReadOnlyList<TItem> Items { get; }
Property Value
| Type | Description |
|---|---|
| IReadOnlyList<TItem> |
Methods
View SourceAdd(TItem, string)
Adds an item to to the list.
Declaration
public void Add(TItem item, string generationStepName)
Parameters
| Type | Name | Description |
|---|---|---|
| TItem | item | The item to add. |
| string | generationStepName | The Name of the generation step that created the item. |
AddRange(IEnumerable<TItem>, string)
Adds the given items to the list.
Declaration
public void AddRange(IEnumerable<TItem> items, string generationStepName)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<TItem> | items | The items to add. |
| string | generationStepName | The Name of the generation step that created the items. |
GetEnumerator()
Gets an enumerator of all items and the step that added them.
Declaration
public IEnumerator<ItemStepPair<TItem>> GetEnumerator()
Returns
| Type | Description |
|---|---|
| IEnumerator<ItemStepPair<TItem>> |
Remove(IEnumerable<TItem>)
Removes the given items from the list.
Declaration
public void Remove(IEnumerable<TItem> items)
Parameters
| Type | Name | Description |
|---|---|---|
| IEnumerable<TItem> | items | Items to remove. |
Remove(Func<TItem, bool>)
Removes all items from the list for which the given function returns true.
Declaration
public void Remove(Func<TItem, bool> predicate)
Parameters
| Type | Name | Description |
|---|---|---|
| Func<TItem, bool> | predicate | Predicate to determine which elements to remove. |
Remove(TItem)
Removes the given item from the list.
Declaration
public void Remove(TItem item)
Parameters
| Type | Name | Description |
|---|---|---|
| TItem | item | Item to remove. |