So I've been using C for almost a year now but decided to give Python a chance. Python and many high level languages don't have pointers like C. Without pointers how do you implement dynamic data structures like lists and trees? (I know that Python has these built in but what if I want to use a more specific structure not built in)
this.add = function(data) {
var node = new Node(data);
if (!head) {
head = node;
} else {
current = head;
while (current.next !== null) {
current = current.next;
}
current.next = node;
}
length++;
return this;
};
this.get = function(index) {
if (index < 0 || index > length) {
return null;
}
var current = head;
for (var i = 0; i < index; i++) {
current = current.next;
}
return current.data;
};
this.remove = function(index) {
if (index < 0 || index > length) {
throw new Error("index " + index + " out of bounds");
}
if (index == 0) {
head = head.next;
}
else {
var before = head;
for (var i = 1; i < index; i++) {
before = before.next;
}
before.next = before.next.next;
}