Use it like:
const LinkedList = preload("LinkedList.gd")
func _ready():
var ll = LinkedList.new()
ll.push_back(-1)
ll.push_back(5)
ll.push_front(1)
ll.push_front(2)
print(ll.size()) # 4
print(ll.pop_best(funcref(self, "comp"))) # 5
print(ll.pop_back()) # -1
print(ll.pop_front()) # 2
print(ll.size()) # 1
func comp(a,b):
return a > b
You're welcome!
And then just making other the new head, I see, but that's what I mean by it only supporting stacking. I think it worth noting that link doesn't support
link()
-ing at an arbitrary point in the list. Truly not what you intended to do given the single argument tolink
, but anywho...