Coder Social home page Coder Social logo

Comments (2)

bosconian-dynamics avatar bosconian-dynamics commented on July 26, 2024

Struct arrays are analogous to C arrays - that is, there is no such thing as an array of undetermined length. You must either over-provision the length of your array to start with, or implement logic to expand/replace the arrays on your own. It's unlikely that the library will support such expansion logic moving forward as the means by which an array is expanded is dependent on the application itself.

Usually, expansion of an independent array is implemented by creating a new array of the desired size, copying the contents of the old array into the new one, and freeing the old array for garbage collection. Alternately, you can create a new array separately and use logic to create something of a "virtual index" that maps to the appropriate array - but you'll lose some of the performance benefits of using contiguous memory.

Changing the size of arrays within a struct at runtime is inadvisable as it will invalidate all previous instances of the struct by changing the offsets at which fields reside - so all previous instances of the struct would need to be converted each time any of their array fields grow.

from node-struct.

erakis avatar erakis commented on July 26, 2024

Maybe you'd be better with something like smart-buffer and de-serializing your data as a stream.

from node-struct.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.