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 |
<lang csharp>class LinkedListNode |
||
{ |
{ |
||
public int |
public int Value { get; set; } |
||
public |
public LinkedListNode Next { get; set; } |
||
//A constructor is not |
// A constructor is not necessary, but could be useful. |
||
public Link(int |
public Link(int value, LinkedListNode next = null) |
||
{ |
|||
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}}== |