Show / Hide Table of Contents

Class LambdaSettableMapView<T>

Class designed to make implementing simple ISettableMapViews more convenient, by providing the get/set functionality via a function that is passed in at construction. For a version that implements IMapView<T> as opposed to ISettableMapView<T>, see LambdaMapView<T>.

Inheritance
System.Object
LambdaSettableMapView<T>
Implements
ISettableMapView<T>
IMapView<T>
Inherited Members
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)
Namespace: GoRogue.MapViews
Assembly: GoRogue.dll
Syntax
public sealed class LambdaSettableMapView<T> : ISettableMapView<T>, IMapView<T>
Type Parameters
Name Description
T

The type of value being returned by the indexer functions.

Remarks

See LambdaMapView<T>. Identical in nature, but takes both get and set functionality via functions.

Constructors

| Improve this Doc View Source

LambdaSettableMapView(Func<Int32>, Func<Int32>, Func<Coord, T>, Action<Coord, T>)

Constructor. Takes functions that retrieve the width and height of the map, and the functions used to retrieve/set the value for a location.

Declaration
public LambdaSettableMapView(Func<int> widthGetter, Func<int> heightGetter, Func<Coord, T> valueGetter, Action<Coord, T> valueSetter)
Parameters
Type Name Description
System.Func<System.Int32> widthGetter

A function/lambda that retrieves the width of the map being represented.

System.Func<System.Int32> heightGetter

A function/lambda that retrieves the height of the map being represented.

System.Func<Coord, T> valueGetter

A function/lambda that returns the value of type T associated with the location it is given.

System.Action<Coord, T> valueSetter

A function/lambda that updates the map being represented accordingly, given a type T and position to which it was set.

Remarks

This constructor is useful if the width and height of the map being represented may change -- one can provide functions that retrieve the width and height of the map being represented, and these functions will be called any time the Width and Height properties are retrieved.

| Improve this Doc View Source

LambdaSettableMapView(Int32, Int32, Func<Coord, T>, Action<Coord, T>)

Constructor. Takes the width and height of the map, and the functions to use to retrieve/set the value for a location.

Declaration
public LambdaSettableMapView(int width, int height, Func<Coord, T> valueGetter, Action<Coord, T> valueSetter)
Parameters
Type Name Description
System.Int32 width

The (constant) width of the map.

System.Int32 height

The (constant) height of the map.

System.Func<Coord, T> valueGetter

A function/lambda that returns the value of type T associated with the location it is given.

System.Action<Coord, T> valueSetter

A function/lambda that updates the map being represented accordingly, given a type T and position to which it was set.

Remarks

This constructor is useful if the width and height of the underlying representation do not change, so they can safely be passed in as constants.

Properties

| Improve this Doc View Source

Height

The height of the map being represented.

Declaration
public int Height { get; }
Property Value
Type Description
System.Int32
| Improve this Doc View Source

Item[Coord]

Given a position, returns/sets the "value" associated with that location, by calling the valueGetter/valueSetter functions provided at construction.

Declaration
public T this[Coord pos] { get; set; }
Parameters
Type Name Description
Coord pos

Location to retrieve/set the value for.

Property Value
Type Description
T

The "value" associated with the provided location, according to the valueGetter function provided at construction.

| Improve this Doc View Source

Item[Int32]

Given an 1D-array-style index, determines the position associated with that index, and returns/sets the "value" associated with that location, by calling the valueGetter/valueSetter function passed in at construction.

Declaration
public T this[int index1D] { get; set; }
Parameters
Type Name Description
System.Int32 index1D

1D-array-style index for location to get/set the value for.

Property Value
Type Description
T

The "value" associated with the given location, according to the valueGetter function provided at construction.

| Improve this Doc View Source

Item[Int32, Int32]

Given an X and Y value, returns/sets the "value" associated with that location, by calling the valueGetter/valueSetter functions provided at construction.

Declaration
public T this[int x, int y] { get; set; }
Parameters
Type Name Description
System.Int32 x

X-value of location.

System.Int32 y

Y-value of location.

Property Value
Type Description
T

The "value" associated with that location, according to the valueGetter function provided at construction.

| Improve this Doc View Source

Width

The width of the map being represented.

Declaration
public int Width { get; }
Property Value
Type Description
System.Int32

Methods

| Improve this Doc View Source

ToString()

Returns a string representation of the LambdaSettableMapView.

Declaration
public override string ToString()
Returns
Type Description
System.String

A string representation of the LambdaSettableMapView.

Overrides
System.Object.ToString()
| Improve this Doc View Source

ToString(Func<T, String>)

Returns a string representation of the map view, using elementStringifier to determine what string represents each value.

Declaration
public string ToString(Func<T, string> elementStringifier)
Parameters
Type Name Description
System.Func<T, System.String> elementStringifier

Function determining the string representation of each element.

Returns
Type Description
System.String

A string representation of the LambdaSettableMapView.

Remarks

This could be used, for example, on an LambdaSettableMapView of boolean values, to output '#' for false values, and '.' for true values.

| Improve this Doc View Source

ToString(Int32, Func<T, String>)

Prints the values in the LambdaSettableMapView, using the function specified to turn elements into strings, and using the "field length" specified.

Declaration
public string ToString(int fieldSize, Func<T, string> elementStringifier = null)
Parameters
Type Name Description
System.Int32 fieldSize

The size of the field to give each value. A positive-number right-aligns the text within the field, while a negative number left-aligns the text.

System.Func<T, System.String> elementStringifier

Function to use to convert each element to a string. null defaults to the ToString function of type T.

Returns
Type Description
System.String

A string representation of the LambdaSettableMapView.

Remarks

Each element of type T will have spaces added to cause it to take up exactly fieldSize characters, provided fieldSize is less than the length of the element's string represention.

Implements

ISettableMapView<T>
IMapView<T>

Extension Methods

Utility.Yield<T>(T)
IMapViewExtensions.ApplyOverlay<T>(ISettableMapView<T>, IMapView<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