G
gwainguard
Hello I am studying the ECMA specs and was doing wonderfully until just
now. They have just broached the topic of AMM and given some example
code which seems to be demanding a greater understanding from the
reader than the previous examples.
I include the code following, would someone please be kind enough to
comment it as thouroughly as possible so I can understand exactly how
it is operating and what it is doing.
I have used wikipedia to explore nodes and linked lists. And my
understanding at the moment is that a node is a unit of data, and a
linked list is a fundamental data structure.
Most of this code goes over my head so please assume as little
knowledge as possible.
Many Thanks,
GM.
Code:
public class Stack
{
private Node first = null ;
public bool Empty {
get {
return (first == null);
}
}
public object Pop() {
if (first == null)
throw new Exception("Can't Pop from an empty Stack.");
else {
object temp = first.Value;
first = first.Next;
return temp;
}
}
public void Push(object o) {
first = new Node(o, first);
}
class Node
{
public Node Next;
public object Value;
public Node(object value): this(value, null) {}
public Node(object value, Node next) {
Next = next;
Value = value;
}
}
}
now. They have just broached the topic of AMM and given some example
code which seems to be demanding a greater understanding from the
reader than the previous examples.
I include the code following, would someone please be kind enough to
comment it as thouroughly as possible so I can understand exactly how
it is operating and what it is doing.
I have used wikipedia to explore nodes and linked lists. And my
understanding at the moment is that a node is a unit of data, and a
linked list is a fundamental data structure.
Most of this code goes over my head so please assume as little
knowledge as possible.
Many Thanks,
GM.
Code:
public class Stack
{
private Node first = null ;
public bool Empty {
get {
return (first == null);
}
}
public object Pop() {
if (first == null)
throw new Exception("Can't Pop from an empty Stack.");
else {
object temp = first.Value;
first = first.Next;
return temp;
}
}
public void Push(object o) {
first = new Node(o, first);
}
class Node
{
public Node Next;
public object Value;
public Node(object value): this(value, null) {}
public Node(object value, Node next) {
Next = next;
Value = value;
}
}
}