Singly-linked list/Element definition: Difference between revisions

Content added Content deleted
(Add task to ARM assembly Raspberry pi)
(→‎{{header|C sharp|C#}}: Renamed members to follow .NET convention; added generic version and unsafe version)
Line 343: Line 343:


=={{header|C sharp|C#}}==
=={{header|C sharp|C#}}==

<lang csharp>class Link
<lang csharp>class LinkedListNode
{
{
public int Item { get; set; }
public int Value { get; set; }
public Link Next { get; set; }
public LinkedListNode Next { get; set; }


//A constructor is not neccessary, but could be useful
// A constructor is not necessary, but could be useful.
public Link(int item, Link next = null) {
public Link(int value, LinkedListNode next = null)
{
Item = item;
Item = value;
Next = next;
Next = next;
}
}
}</lang>
}</lang>

A generic version:
<lang csharp>class LinkedListNode<T>
{
public T Value { get; set; }
public LinkedListNode Next { get; set; }

public Link(T value, LinkedListNode next = null)
{
Item = value;
Next = next;
}
}</lang>

The most C-like possible version is basically C, but is somewhat limited in use by the fact that it is a ref struct.
<lang csharp>unsafe ref struct link {
public link* next;
public int data;
};</lang>


=={{header|Clojure}}==
=={{header|Clojure}}==