add Copy to (Array)List #97
Labels
No labels
bug
discussion
documentation
duplicate
ignore
new feature
question
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
golibs/gms-gods#97
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
I could really use the function Copy on ArrayList, but it would probably also make sense to add it to the other lists. I can see that the function Values (on ArrayList) returns an copy of the internal array, but I would like to keep interface ArrayList
@dvaerum sounds reasonable, let me mediate on this. if implemented, you are right, it should be for all structures. not sure if this would be able to copy a linked-list into array-list, so perhaps what you need is a
Clonemethod?You can call
Cloneif you want 😉 as long that I get the function to dublicate all the data and still have it accessible from the same lovely interface that I dublicated from 😃But since you want to call it
Cloneinstead ofCopy, is there any difference in what to expect based on the wording or is it just what one preferes?Clone, at least from my experience in other programming languages, usually creates the identical structure and type as the original.Copycould be the same, not sure what the difference is, but in C++ you get the copy-constructor which might behave differently, e.g. overloaded copy constructor that can accept different data structure types.Frankly I am not sure if there is much difference, so it's best to ask you if
Clonename would be sufficiently intuitive for you to know that it does what you are asking for or would you findCopymore intuitive?I would say it is sufficiently intuitive 😄 so let's stick to what everyone else does 👍
PR #150 implemented Clone for all ArrayList, SinglyLinkedList and DoublyLinkedList.