Question about arraylist #115

Closed
opened 2019-07-05 02:18:11 +00:00 by huangzongzhao · 2 comments
huangzongzhao commented 2019-07-05 02:18:11 +00:00 (Migrated from github.com)

Hi.

I have a question about arraylist. Here.

In go, the slice is already a dynamic array. Is it more appropriate to change it to an array?

Hi. I have a question about arraylist. [Here](https://github.com/emirpasic/gods/blob/master/lists/arraylist/arraylist.go#L26). In go, the slice is already a dynamic array. Is it more appropriate to change it to an array?
emirpasic commented 2019-07-06 13:26:39 +00:00 (Migrated from github.com)

@fakecowboy I think you might have a point. I can't remember my reasoning why I used a slice when I intended to use an array.

@fakecowboy I think you might have a point. I can't remember my reasoning why I used a slice when I intended to use an array.
emirpasic commented 2022-04-12 21:16:38 +00:00 (Migrated from github.com)

@fakecowboy took some time to get back to this question, but the reasoning is that the size of an array in golang is fixed at compiler runtime and can not be dynamically extended. Essentially then ArrayList indeed works in similar fashion to how the native slices work, however the added functionality of ArrayList could be a reason for using GoDS ArrayList rather than slice, e.g. iterators, enumerables, and other list functions.

@fakecowboy took some time to get back to this question, but the reasoning is that the size of an array in golang is fixed at compiler runtime and can not be dynamically extended. Essentially then ArrayList indeed works in similar fashion to how the native slices work, however the added functionality of ArrayList could be a reason for using GoDS ArrayList rather than slice, e.g. iterators, enumerables, and other list functions.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
golibs/gms-gods#115
No description provided.