Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

What are some scenarios where you would choose one over the other when programming in AssemblyScript?

In my case I am trying to build a K-d tree from a list of tuples of floating point numbers. Because I need to rearrange and sort the incoming list of tuples, my first go-to is using Array<Array<f64>> since I can easily add and remove data from it.[

Your intuition is correct, the standard array is the most flexible.

In Assemblyscript there are three array types.

Array

let a:f32[] = [0,1,2]

  • Resizable
  • Can hold references
  • The least performant
  • Static Array

    let a:StaticArray<f32> = [0,1,2]

  • Fixed size
  • Can hold references
  • Great performance
  • Typed Array

    let a:Float32Array = new Float32Array(3)

  • Fixed size
  • Can hold numeric values only
  • Great performance
  • Buffer access for shared views etc
  • Note - it is not currently possible to initialize a typed array with values, ie

    new Float32Array([0,1,2])

    Thanks for contributing an answer to Stack Overflow!

    • Please be sure to answer the question . Provide details and share your research!

    But avoid

    • Asking for help, clarification, or responding to other answers.
    • Making statements based on opinion; back them up with references or personal experience.

    To learn more, see our tips on writing great answers .