Page MenuHome

Generic array data structure
ClosedPublic

Authored by Hans Goudey (HooglyBoogly) on Apr 28 2021, 12:24 AM.

Details

Summary

Sometimes it's useful to pass around a set of values with a generic type.
The virtual array data structures allow this, but they don't have logical
ownership. My initial use case for this is as a return type for the functions
that interpolate curve attributes to evaluated points, but a need for this data
structure has come up in a few other places, and it seems generally useful
and non-problematic.

Diff Detail

Repository
rB Blender

Event Timeline

Hans Goudey (HooglyBoogly) requested review of this revision.Apr 28 2021, 12:24 AM
Hans Goudey (HooglyBoogly) created this revision.

Various improvements

  • Add copy and move constructors (and the assign versions)
  • Add many comments
  • Add more tests
  • Remove move constructor from blender::Array (wasn't feasable with the current methods exposed in Array
  • Lots of fixes

There are two remaining things:

  • I'd like to be able to this: Array<GArray> arrays, currently it doesn't compile.
  • I have to case the size argument to int64_t or it tries to interpret it as an allocator..
  • Merge branch 'master' into generic-array
  • Add newline
Hans Goudey (HooglyBoogly) retitled this revision from Generic array data structure (WIP) to Generic array data structure.Aug 23 2021, 11:35 PM
Hans Goudey (HooglyBoogly) edited the summary of this revision. (Show Details)
source/blender/functions/FN_generic_array.hh
150

This expects that there is a NoExceptConstructor constructor.

source/blender/functions/tests/FN_generic_array_test.cc
110

You have to use GArray<> here.

Hans Goudey (HooglyBoogly) marked 2 inline comments as done.Sep 3 2021, 11:32 PM

Thanks, that seems to do it!

Hans Goudey (HooglyBoogly) edited the summary of this revision. (Show Details)
  • Merge branch 'master' into generic-array
  • Fixes suggested by Jacques
  • Merge branch 'master' into generic-array
  • Fix comment, default variable values
  • Add GVArray_For_GArray based on GVArray_For_GSpan
Jacques Lucke (JacquesLucke) requested changes to this revision.Oct 14 2021, 3:51 PM
Jacques Lucke (JacquesLucke) added inline comments.
source/blender/functions/FN_generic_virtual_array.hh
409

This constructor still has to set data_.

This revision now requires changes to proceed.Oct 14 2021, 3:51 PM
Hans Goudey (HooglyBoogly) marked an inline comment as done.
  • Add NOLINT to use after move
  • Fix GVArray_For_GArray constructor
source/blender/functions/FN_generic_virtual_array.hh
409

Eek, thanks! The GSpan constructor seems to work better here anyway.

Jacques Lucke (JacquesLucke) added inline comments.
source/blender/functions/FN_generic_array.hh
30

Not sure if this comment really belongs here, seems unrelated to the entire file.

source/blender/functions/FN_generic_virtual_array.hh
409

Right. Note, if GArray would support small-object-optimization, then the GSpan constructor could not be used.

This revision is now accepted and ready to land.Oct 14 2021, 4:24 PM
  • Fix constructor
  • Use copy assign instead of copy construct
Hans Goudey (HooglyBoogly) marked 2 inline comments as done.Oct 14 2021, 5:54 PM