data type for 2 D data

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Tem

    data type for 2 D data

    What would be the best data type for storing objects in a 2D array.
    the ideal type would be one like generic List but Lists are only 1D. i don't
    think i can have an array of lists.
    The size of either the row or column is given while the size of the other
    dimension can be dynamically changed.

    the data type needs to be optimized for performance, only sequential
    add/remove is nessesary.

    any suggestions?

    Tem

  • =?Utf-8?B?RmFtaWx5IFRyZWUgTWlrZQ==?=

    #2
    RE: data type for 2 D data

    I just wanted to point out that List<List<objec t>is perfectly fine. It may
    not apply to your situation where one dimension is fixed.

    "Tem" wrote:
    What would be the best data type for storing objects in a 2D array.
    the ideal type would be one like generic List but Lists are only 1D. i don't
    think i can have an array of lists.
    >

    Comment

    • Tem

      #3
      Re: data type for 2 D data

      thanks. let me try that.

      how is it performance wise?

      "Family Tree Mike" <FamilyTreeMike @discussions.mi crosoft.comwrot e in
      message news:D9869840-DB01-4CA6-A2A8-B3AE9E10FF95@mi crosoft.com...
      >I just wanted to point out that List<List<objec t>is perfectly fine. It
      >may
      not apply to your situation where one dimension is fixed.
      >
      "Tem" wrote:
      >
      >What would be the best data type for storing objects in a 2D array.
      >the ideal type would be one like generic List but Lists are only 1D. i
      >don't
      >think i can have an array of lists.
      >>

      Comment

      • shahkalpesh77@gmail.com

        #4
        Re: data type for 2 D data

        Pardon me if I do not understand the problem statement
        But, wouldn't jagged array work

        e.g. Person[][] mydata = new Person[9][];
        mydata[0] = new Person[4];
        mydata[1] = new Person[n];

        HTH
        Kalpesh

        On Apr 7, 8:41 pm, "Tem" <tem1...@yahoo. comwrote:
        thanks. let me try that.
        >
        how is it performance wise?
        >
        "Family Tree Mike" <FamilyTreeM... @discussions.mi crosoft.comwrot e in
        messagenews:D98 69840-DB01-4CA6-A2A8-B3AE9E10FF95@mi crosoft.com...
        >
        I just wanted to point out that List<List<objec t>is perfectly fine. It
        may
        not apply to your situation where one dimension is fixed.
        >
        "Tem" wrote:
        >
        What would be the best data type for storing objects in a 2D array.
        the ideal type would be one like generic List but Lists are only 1D. i
        don't
        think i can have an array of lists.

        Comment

        • Tem

          #5
          Re: data type for 2 D data

          I need to be able to change the size of the array as needed. can this be
          done with jagged array?

          <shahkalpesh77@ gmail.comwrote in message
          news:1fc16e47-9300-4fe4-829a-e7b9a6845e25@e1 0g2000prf.googl egroups.com...
          Pardon me if I do not understand the problem statement
          But, wouldn't jagged array work
          >
          e.g. Person[][] mydata = new Person[9][];
          mydata[0] = new Person[4];
          mydata[1] = new Person[n];
          >
          HTH
          Kalpesh
          >
          On Apr 7, 8:41 pm, "Tem" <tem1...@yahoo. comwrote:
          >thanks. let me try that.
          >>
          >how is it performance wise?
          >>
          >"Family Tree Mike" <FamilyTreeM... @discussions.mi crosoft.comwrot e in
          >messagenews:D9 869840-DB01-4CA6-A2A8-B3AE9E10FF95@mi crosoft.com...
          >>
          >I just wanted to point out that List<List<objec t>is perfectly fine.
          >It
          >may
          not apply to your situation where one dimension is fixed.
          >>
          "Tem" wrote:
          >>
          >What would be the best data type for storing objects in a 2D array.
          >the ideal type would be one like generic List but Lists are only 1D. i
          >don't
          >think i can have an array of lists.
          >

          Comment

          • Marc Gravell

            #6
            Re: data type for 2 D data

            That is an array of lists, and is a real pain to resize; you can't
            change the array, and you'd need to change every list individually. If
            you went down this route, a list of arrays (List<T[]>) would be a better
            option - at least then you can just add a new T[] as a new row; it is
            still jagged, however.

            The linearized Matrix<TI posted earlier handles all this in a single
            list, and allows you to have either axis pinned. You could probably
            loser all the ITypedList stuff without too much pain, though ;-p

            Marc

            Comment

            • Janos

              #7
              Re: data type for 2 D data

              Cool, man !

              Thanks for sharing it,

              Comment

              • =?Utf-8?B?RmFtaWx5IFRyZWUgTWlrZQ==?=

                #8
                Re: data type for 2 D data

                Agreed. I posted a response to what the poster had asked, I think, before I
                saw your other post. I wanted the poster to see what was possible. I liked
                (and prefered) your solution!

                "Marc Gravell" wrote:
                That is an array of lists, and is a real pain to resize; you can't
                change the array, and you'd need to change every list individually. If
                you went down this route, a list of arrays (List<T[]>) would be a better
                option - at least then you can just add a new T[] as a new row; it is
                still jagged, however.
                >
                The linearized Matrix<TI posted earlier handles all this in a single
                list, and allows you to have either axis pinned. You could probably
                loser all the ITypedList stuff without too much pain, though ;-p
                >
                Marc
                >

                Comment

                • Tem

                  #9
                  Re: data type for 2 D data

                  wow thanks for sharing!

                  Does anyone know how to limit the capacity of a regular List<>?

                  "Marc Gravell" <marc.gravell@g mail.comwrote in message
                  news:%23GRr1UXm IHA.464@TK2MSFT NGP02.phx.gbl.. .
                  That is an array of lists, and is a real pain to resize; you can't change
                  the array, and you'd need to change every list individually. If you went
                  down this route, a list of arrays (List<T[]>) would be a better option -
                  at least then you can just add a new T[] as a new row; it is still jagged,
                  however.
                  >
                  The linearized Matrix<TI posted earlier handles all this in a single
                  list, and allows you to have either axis pinned. You could probably loser
                  all the ITypedList stuff without too much pain, though ;-p
                  >
                  Marc

                  Comment

                  Working...