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 STL-like structures without using void pointer. #1815

Closed
Omnuchka opened this issue Sep 1, 2019 · 15 comments
Closed

Add STL-like structures without using void pointer. #1815

Omnuchka opened this issue Sep 1, 2019 · 15 comments
Labels
Feature Request This issue is made to request a feature.

Comments

@Omnuchka
Copy link

Omnuchka commented Sep 1, 2019

A void pointer can take up a lot of memory and processor takts if the processor is processing large amounts of data. If patterns generation already exist can you add library with basic data structures, pls.

@Omnuchka Omnuchka added the Feature Request This issue is made to request a feature. label Sep 1, 2019
@medvednikov
Copy link
Member

Which data structures are you missing?

@Omnuchka
Copy link
Author

Omnuchka commented Sep 1, 2019

List, arrayList, linkedList, vector, queue and function for it, way for create abstract structures and function with T parameter, and function without void pointer its main goal for it feature because it is make sort more slower.

@medvednikov
Copy link
Member

what's the difference between list, arraylist, and vector?

V already has dynamic arrays: []T

@Delta456
Copy link
Member

Delta456 commented Sep 1, 2019

@medvednikov I think he is comparing it with Java. This can help in comparing them and List is just an interface and its already implemented as arrays.

@Delta456
Copy link
Member

Delta456 commented Sep 1, 2019

@Omnuchka Its hasn't been done yet because V partially support Generics and all containers will hopefully be implemented by it soon.

@medvednikov
Copy link
Member

medvednikov commented Sep 1, 2019

V won't need separate synchronized types, besides Java's vector seems to be deprecated: https://stackoverflow.com/questions/1386275/why-is-java-vector-and-stack-class-considered-obsolete-or-deprecated

Linked lists should never be used: https://www.youtube.com/watch?v=YQs6IC-vgmo

Even if you do want to use one, it's very trivial to implement it yourself.

The upcoming channels can be used as threadsafe queues.

So no extra data structures need to be implemented.

@Omnuchka
Copy link
Author

Omnuchka commented Sep 1, 2019

Sort for dynamic arrays exist? Used void* pointer or not?

@medvednikov
Copy link
Member

yes, there's array.sort()

arrays are implemented with void*

@Omnuchka
Copy link
Author

Omnuchka commented Sep 1, 2019

yes, in this feature i want say, please change it because it is not the best way. It is easy but bad for performance, standard algorithm for it without pointer more effective.

@Omnuchka
Copy link
Author

Omnuchka commented Sep 1, 2019

if you use void* for pointer on any type and it give you way for sort any data(T) it is not good

@medvednikov
Copy link
Member

@Omnuchka I benchmarked a 10 million vector in C++/Go/V, and V is 50 % faster than C++ and 200% faster than Go.

So it's good enough.

@Omnuchka
Copy link
Author

Omnuchka commented Sep 2, 2019

V must have the best sort algorithm, not only good, sort must be a best sort!

@ntrel
Copy link
Contributor

ntrel commented Sep 5, 2019

A balanced binary tree is needed for when you need to iterate in sorted order and insert items quickly too.

V's map should use a hash table for fastest lookup, maps don't need to iterate in sorted order. (If map stays as a tree then we need a library hash table).

@dumblob
Copy link
Contributor

dumblob commented Sep 5, 2019

V's map should use a hash table for fastest lookup, maps don't need to iterate in sorted order. (If map stays as a tree then we need a library hash table).

I wouldn't fully agree with blindly using the fastest hash table. If hash table, then with randomization and with guaranteed predictable linearly scaling behavior disallowing dangerous attack vectors. So the current implementation is actually not that bad (the speed can be even further improved by making it more cache friendly at the expense of lost ordering which would be unfortunate though).

Btw. recent thorough test of hash maps was performed by Martin Ankerl - see https://martin.ankerl.com/2019/04/01/hashmap-benchmarks-01-overview/ and the corresponding github repository (to run the tests on your own HW to verify).

@ntrel
Copy link
Contributor

ntrel commented Sep 5, 2019

I wouldn't fully agree with blindly using the fastest hash table

I just meant that a hash table is faster than a binary tree, O(k) vs O(log n).

the current implementation is actually not that bad

Has it changed recently? Last time I looked it was an unbalanced binary tree.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Feature Request This issue is made to request a feature.
Projects
None yet
Development

No branches or pull requests

5 participants