Results 1 to 6 of 6

Thread: Blasted Arrays

  1. #1

    Thread Starter
    Fanatic Member coox's Avatar
    Join Date
    Oct 1999
    Posts
    550

    Post

    I have a two-dimensional array of around 300 records, each with 24 fields, which I am sorting. Can anyone tell me if it's possible to move an entire record (ie, all 24 fields) to another array (this time a one dimensional) in one line, without using pigging loops all the time? The sort function is taking several seconds to do, and I'm sure it's just because of the way I'm swapping records around...

  2. #2
    Lively Member
    Join Date
    Jan 2000
    Location
    North Yorkshire
    Posts
    102

    Post

    Hi,
    Why bother physically sorting the list ? Create a linked list. Have a field / column which is a pointer to the next record. Then you only need change this to point to the next record, rather than trying to actually swap the records themseleves.

    cheers

    Andy

  3. #3
    Hyperactive Member
    Join Date
    Jan 1999
    Location
    Rotterdam, Netherlands
    Posts
    386

    Post

    Yeah, but a slight problem... no pointers in VB...

  4. #4
    Fanatic Member
    Join Date
    Feb 2000
    Location
    Japan
    Posts
    840

    Post

    No pointers in VB????? Well not in a literal defining sense but what do you thing Pass-by-refernce means?.

    you can use the MemCopy(could have the name wrong) API to dump the array somewhere or make the array dynamic an just assign it but to be honest I think you shouldn't be using a 2D array rather a UDT.

    They are much more flexible and allow you to access their parts for better use of the API copy and array assignments. There are very few situations that I've found multi-dimensional array superior the User-Defined-Types with arrays in them and of them. Even in 3D and 2D graphics programming.


    Oh, and I think what andymac meant was linked list pointer not mem-alloc C pointer. A linked list (also created with a struct/class or UDT) holds a reverence to the next or previous (or both) record of the list -in the list itself.

    Have a good one

    [This message has been edited by Paul282 (edited 02-04-2000).]

  5. #5
    Addicted Member
    Join Date
    Jan 2000
    Location
    Oshkosh, WI
    Posts
    163

    Post

    You could have a second array (1 dimensional)that acts like an index for the data array. That way when you swap two values all you have to do is swap their index values in the smaller index array. When you whish to loop through the array in sorted order just follow the values in the index array.

  6. #6
    Addicted Member
    Join Date
    Jan 2000
    Location
    Fresno, California, USA
    Posts
    195

    Post

    Being an old COBOL programmer, this inability was something I had to get around. It wasn't too hard when I learned about the 'Type' statement. You can define a group of fields within the type and treat them as a single object. Look at Type Statement in you online help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width