Show / Hide Table of Contents

Class LambdaTranslationMap<T1, T2>

A simple TranslationMap<T1, T2> implementation that allows you to provide a function/lambda at construction to use as the TranslateGet implementation. For a version offering "set" functionality, see LambdaSettableTranslationMap<T1, T2>.

Inheritance
System.Object
TranslationMap<T1, T2>
LambdaTranslationMap<T1, T2>
Implements
IMapView<T2>
Inherited Members
TranslationMap<T1, T2>.BaseMap
TranslationMap<T1, T2>.Height
TranslationMap<T1, T2>.Width
TranslationMap<T1, T2>.Item[Int32]
TranslationMap<T1, T2>.Item[Int32, Int32]
TranslationMap<T1, T2>.Item[Coord]
TranslationMap<T1, T2>.ToString()
TranslationMap<T1, T2>.ToString(Func<T2, String>)
TranslationMap<T1, T2>.ToString(Int32, Func<T2, String>)
TranslationMap<T1, T2>.TranslateGet(T1)
TranslationMap<T1, T2>.TranslateGet(Coord, T1)
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: GoRogue.MapViews
Assembly: GoRogue.dll
Syntax
public sealed class LambdaTranslationMap<T1, T2> : TranslationMap<T1, T2>, IMapView<T2>
Type Parameters
Name Description
T1

The type of your underlying data.

T2

The type of the data being exposed to the algorithm.

Remarks

If you have a view that simply exposes a simple property of your underlying data, it can be tedious to write a TranslationMap<T1, T2> implementation for all of them. This class simplifies that task by letting you just provide the translation method as a function/lambda, without needing to build the rest of the class infrastructure.

Constructors

| Improve this Doc View Source

LambdaTranslationMap(IMapView<T1>, Func<T1, T2>)

Constructor. Takes an existing map view to create a view from and a getter function taking only a value of type T1.

Declaration
public LambdaTranslationMap(IMapView<T1> baseMap, Func<T1, T2> getter)
Parameters
Type Name Description
IMapView<T1> baseMap

Your underlying map data.

System.Func<T1, T2> getter

The TranslateGet implementation.

Remarks

If a position is also needed to perform the translation, an overload is provided taking a corresponding function.

| Improve this Doc View Source

LambdaTranslationMap(IMapView<T1>, Func<Coord, T1, T2>)

Constructor. Takes an existing map view to create a view from and a getter function taking a value of type T1 and its corresponding position.

Declaration
public LambdaTranslationMap(IMapView<T1> baseMap, Func<Coord, T1, T2> getter)
Parameters
Type Name Description
IMapView<T1> baseMap

Your underlying map data.

System.Func<Coord, T1, T2> getter

The TranslateGet implementation.

Methods

| Improve this Doc View Source

TranslateGet(Coord, T1)

Translates your map data into the view type by calling the getter function specified in the class constructor.

Declaration
protected override T2 TranslateGet(Coord position, T1 value)
Parameters
Type Name Description
Coord position

Position corresponding to given data value of your map.

T1 value

The data value from your map.

Returns
Type Description
T2

A value of the mapped data type (via the getter specified in the class constructor).

Overrides
GoRogue.MapViews.TranslationMap<T1, T2>.TranslateGet(GoRogue.Coord, T1)

Implements

IMapView<T>

Extension Methods

Utility.Yield<T>(T)
IMapViewExtensions.Bounds<T>(IMapView<T>)
IMapViewExtensions.Contains<T>(IMapView<T>, Int32, Int32)
IMapViewExtensions.Contains<T>(IMapView<T>, Coord)
IMapViewExtensions.ExtendToString<T>(IMapView<T>, String, String, Func<T, String>, String, String, String, String)
IMapViewExtensions.ExtendToString<T>(IMapView<T>, Int32, String, String, Func<T, String>, String, String, String, String)
IMapViewExtensions.Positions<T>(IMapView<T>)
IMapViewExtensions.RandomItem<T>(IMapView<T>, IGenerator)
IMapViewExtensions.RandomItem<T>(IMapView<T>, Func<Coord, T, Boolean>, IGenerator)
IMapViewExtensions.RandomPosition<T>(IMapView<T>, T, IGenerator)
IMapViewExtensions.RandomPosition<T>(IMapView<T>, IEnumerable<T>, IGenerator)
IMapViewExtensions.RandomPosition<T>(IMapView<T>, HashSet<T>, IGenerator)
IMapViewExtensions.RandomPosition<T>(IMapView<T>, IGenerator, T[])
IMapViewExtensions.RandomPosition<T>(IMapView<T>, Func<Coord, T, Boolean>, IGenerator)
IMapViewExtensions.RandomPosition<T>(IMapView<T>, IGenerator)
  • Improve this Doc
  • View Source
Back to top Generated by DocFX