Answer the question
In order to leave comments, you need to log in
How to make your own Array class (generic) (for laba)?
How it's done?
In a couple of minutes, I whipped up a singly-linked list, in haste without strapping like square brackets, etc. it looks something like this (just for logic, the way I imagine it):
class Node
{
public string value;
public Node next;
}
class LinkedList
{
public Node root;
public LinkedList(string value)
{
var n = new Node();
n.value = value;
root = n;
}
public void Add(string value)
{
var n = new Node();
n.value = value;
getLast(root).next = n;
}
private Node getLast(Node n)
{
if (n.next != null)
return getLast(n.next);
else
return n;
}
}
...
var l = new LinkedList("0");
l.Add("1");
l.Add("2");
l.Add("3");
MessageBox.Show(l.root.next.next.next.value);
Answer the question
In order to leave comments, you need to log in
Well, there is the development of generics.
And forward to implementation.
UPD:
1) in my opinion, setting the task in the form of a "Linked List" is a little about nothing. Without a bypass method, it is not clear what you will implement (LIFO or FIFO or some other beast). There are also singly and doubly linked lists, XOR lists, cyclic lists, and so on. Which one are you implementing?
2) I see a method for adding new elements, but where is the get method? Although without a bypass method it is not clear how to implement it.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question