Announcement

Collapse
No announcement yet.

Find in Struct Array ?

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

    Find in Struct Array ?

    I need to create an array with each item having multiple properties e.g. actor + float, so I started to use a Struct which works fine. However as the float may differ each time I can't just use array find because of the change. I don't really want to create a second array with maybe a name or something to ID it and then get the index, also without looping through each item just to find a specific one that has a matching variable.

    Any suggestions ?

    #2
    you have to iterate over each item.

    Comment


      #3
      What if there's lots of items ?

      Comment


        #4
        Then you have lots of stuff to iterate through ^^

        Struct holds many variables, but isnĀ“t an array by itself.

        Comment


          #5
          Try utilise the array index to store as a named ref.

          Alternatively if there's too much looping/iteration and you really want to use a variable in your struct as a key to find(); you can create a dictionary.
          Initialise the new Dictionary variable first with key : struct
          where key = Name
          and struct = YourStructure

          I would create a function mapArrayOfStructToDictionary(struct, StructVarAsKey).
          You need to ensure every value is unique else the dictionary item will be removed. Now decide if a data table is better where you enforce unique keys
          Attached Files

          Comment

          Working...
          X