add Copy to (Array)List #97

Closed
opened 2018-12-16 06:52:53 +00:00 by dvaerum · 5 comments
dvaerum commented 2018-12-16 06:52:53 +00:00 (Migrated from github.com)

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

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
emirpasic commented 2019-01-24 12:21:08 +00:00 (Migrated from github.com)

@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 Clone method?

@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 `Clone` method?
dvaerum commented 2019-01-25 18:54:15 +00:00 (Migrated from github.com)

You can call Clone if 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 Clone instead of Copy , is there any difference in what to expect based on the wording or is it just what one preferes?

You can call `Clone` if 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 `Clone` instead of `Copy` , is there any difference in what to expect based on the wording or is it just what one preferes?
emirpasic commented 2019-01-25 19:06:50 +00:00 (Migrated from github.com)

Clone, at least from my experience in other programming languages, usually creates the identical structure and type as the original.

Copy could 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 Clone name would be sufficiently intuitive for you to know that it does what you are asking for or would you find Copy more intuitive?

`Clone`, at least from my experience in other programming languages, usually creates the identical structure and type as the original. `Copy` could 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 `Clone` name would be sufficiently intuitive for you to know that it does what you are asking for or would you find `Copy` more intuitive?
dvaerum commented 2019-01-28 06:09:26 +00:00 (Migrated from github.com)

I would say it is sufficiently intuitive 😄 so let's stick to what everyone else does 👍

I would say it is sufficiently intuitive :smile: so let's stick to what everyone else does :+1:
AryanAhadinia commented 2021-01-14 09:23:43 +00:00 (Migrated from github.com)

PR #150 implemented Clone for all ArrayList, SinglyLinkedList and DoublyLinkedList.

PR #150 implemented Clone for all ArrayList, SinglyLinkedList and DoublyLinkedList.
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#97
No description provided.