stotko / stdgpu

stdgpu: Efficient STL-like Data Structures on the GPU
https://stotko.github.io/stdgpu/
Apache License 2.0
1.15k stars 81 forks source link

Docs on size parameters #418

Closed david-tingdahl-nvidia closed 3 months ago

david-tingdahl-nvidia commented 3 months ago

Is your feature request related to a problem? Please describe. Thanks for an awesome library! I have a question/suggestion on a doc update to clarify how capacity, max_size and bucket_count are defined.

I'm using max_load_factor=1 and my interpretation is as follows:

When I calculate the current load factor, should I use "size/bucket_count" or "size/max_size"?

Describe the solution you'd like Updated docs to better describe these variables

stotko commented 3 months ago

For calculating the current load factor, you can use size() / bucket_count() or alternatively directly call load_factor() which does the same thing. This matches the respective definition in the C++ standard library.

Concerning the meaning of the different functions, you are right about capacity and bucket_count. max_size denotes the total number of elements the container can hold which is bucket_count + excess_count (implementation detail, i.e. an extra space allocated to handle collisions). So max_size > bucket_count >= capacity.

david-tingdahl-nvidia commented 3 months ago

Thanks for the clarifications!