I need to create a field for simple game. In first version the field was like Point[,]
- two dimensional array.
Now i need use System.Collections.Immutable (it's important condition). I trying to google and can't find anything, that can help me. I don't understand how i can create two-dimensional ImmutableArray (or ImmutableList)?
C programming language is a machine-independent programming language that is mainly used to create many types of applications and operating systems such as Windows, and other complicated programs such as the Oracle database, Git, Python interpreter, and games and is considered a programming foundation in the process of ...
Compared to other languages—like Java, PHP, or C#—C is a relatively simple language to learn for anyone just starting to learn computer programming because of its limited number of keywords.
In the real sense it has no meaning or full form. It was developed by Dennis Ritchie and Ken Thompson at AT&T bell Lab. First, they used to call it as B language then later they made some improvement into it and renamed it as C and its superscript as C++ which was invented by Dr.
Because a and b and c , so it's name is C. C came out of Ken Thompson's Unix project at AT&T. He originally wrote Unix in assembly language. He wrote a language in assembly called B that ran on Unix, and was a subset of an existing language called BCPL.
There isn't the equivalent of a rectangular array as far as I'm aware, but you could:
ImmutableList<ImmutableList<Point>>
ImmutableList<Point>
in your own class to provide access across two dimensions.The latter would be something like:
// TODO: Implement interfaces if you want
public class ImmutableRectangularList<T>
{
private readonly int Width { get; }
private readonly int Height { get; }
private readonly IImmutableList<T> list;
public ImmutableRectangularList(IImmutableList<T> list, int width, int height)
{
// TODO: Validation of list != null, height >= 0, width >= 0
if (list.Count != width * height)
{
throw new ArgumentException("...");
}
Width = width;
Height = height;
this.list = list;
}
public T this[int x, int y]
{
get
{
if (x < 0 || x >= width)
{
throw new ArgumentOutOfRangeException(...);
}
if (y < 0 || y >= height)
{
throw new ArgumentOutOfRangeException(...);
}
return list[y * width + x];
}
}
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With