There is a double linked list in godots source code (core/list.h).
It would be nice if that would be exposed as there are some cases where a double linked list performs way better as a vector based.
Especially when it comes to inserting/removing elements at any position except the end.
I could do some work on this, but am not sure how to handle locking and registering it (Although i could try to mirror the behavior of the Array class).
Basically exposing the list
Implementing it as iterable should also work similar to how Array does it.
Additionally (and if requested i could open another issue for this) exposing the core/ring_buffer.h as queue would also be nice for queue needs.
It should perform better as a queue using a double linked list (and def. better as a vector based list) with the limitation that it has a "fixed" size and potential allocates unused memory ofc.
But there are cases where exactly this behavior is needed.
Still reproducible/relevant in 3.1 master 9e7cee2 : such data stucture isn't exposed yet.
Was about to post on reddit asking if there's a proper linked-list implementation I can use.
I need a fast FIFO list, and array isn't doing the job.
Just wrote this as an array replacement, and got significant speed improvements:
extends Node
var front_space = 0
var array_len = 0
var array_data = []
func push_back(val):
if array_data.size() < front_space+array_len+1:
enlarge()
array_len += 1
array_data[front_space+array_len-1] = val
func pop_back():
if array_data.size() > array_len*8:
reseat()
array_len -= 1
return array_data[front_space+array_len]
func back():
return array_data[front_space+array_len-1]
func pop_front():
if front_space > array_len:
reseat()
if array_data.size() > array_len*8:
reseat()
front_space += 1
array_len -= 1
return array_data[front_space-1]
func front():
return array_data[front_space]
func size():
return array_len
func enlarge():
array_data.resize(front_space+array_len*2+1)
func reseat():
var new_array = []
new_array.resize(array_len*2)
for i in range(array_len):
new_array[i] = array_data[i+front_space]
front_space = 0
array_data = new_array
func print_debug():
print("front: ", front_space,", len: ",arr
Feature and improvement proposals for the Godot Engine are now being discussed and reviewed in a dedicated Godot Improvement Proposals (GIP) (godotengine/godot-proposals) issue tracker. The GIP tracker has a detailed issue template designed so that proposals include all the relevant information to start a productive discussion and help the community assess the validity of the proposal for the engine.
The main (godotengine/godot) tracker is now solely dedicated to bug reports and Pull Requests, enabling contributors to have a better focus on bug fixing work. Therefore, we are now closing all older feature proposals on the main issue tracker.
If you are interested in this feature proposal, please open a new proposal on the GIP tracker following the given issue template (after checking that it doesn't exist already). Be sure to reference this closed issue if it includes any relevant discussion (which you are also encouraged to summarize in the new proposal). Thanks in advance!
Most helpful comment
Still reproducible/relevant in 3.1 master 9e7cee2 : such data stucture isn't exposed yet.