Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add Copy to (Array)List #97

Open
dvaerum opened this issue Dec 16, 2018 · 5 comments
Open

add Copy to (Array)List #97

dvaerum opened this issue Dec 16, 2018 · 5 comments

Comments

@dvaerum
Copy link

dvaerum commented Dec 16, 2018

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
Copy link
Owner

@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
Copy link
Author

dvaerum commented Jan 25, 2019

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
Copy link
Owner

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
Copy link
Author

dvaerum commented Jan 28, 2019

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

@AryanAhadinia
Copy link
Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants