tomr@maccs.dcss.mcmaster.ca (Rickey Thomas Tom) (06/16/91)
I have a simple question. I sort some data. The easiest way to do this is to decalre a large array to sotre this data and then sort the array. However, it apopears that in a DOS environment, I am only allowed an array up to 64 K in size. Is there a way to declare larger arrays than this for sort. Is there another way that I could store a large quantity of data for sorting. Any comments would be appreciated. Thanks in advance. Rick
henry@zoo.toronto.edu (Henry Spencer) (06/19/91)
In article <285B94A3.25253@maccs.dcss.mcmaster.ca> tomr@maccs.dcss.mcmaster.ca (Rickey Thomas Tom) writes: >... in a DOS environment, I am only allowed an array up to 64 K in size... Asking about this in comp.os.msdos.programmer would be much more useful than asking about it here. -- "We're thinking about upgrading from | Henry Spencer @ U of Toronto Zoology SunOS 4.1.1 to SunOS 3.5." | henry@zoo.toronto.edu utzoo!henry
gordon@osiris.cso.uiuc.edu (John Gordon) (06/19/91)
tomr@maccs.dcss.mcmaster.ca (Rickey Thomas Tom) writes: >I have a simple question. I sort some data. The easiest way to do this is to >decalre a large array to sotre this data and then sort the array. However, >it apopears that in a DOS environment, I am only allowed an array up to 64 K in size. Is there a way to declare larger arrays than this for sort. Is there another way that I could store a large quantity of data for sorting. Don't declare it as an array. Declare it as a pointer and malloc() it in the program.
sorrow@oak.circa.ufl.edu (06/19/91)
In article <1991Jun18.205921.20757@ux1.cso.uiuc.edu>, gordon@osiris.cso.uiuc.edu (John Gordon) writes: |>tomr@maccs.dcss.mcmaster.ca (Rickey Thomas Tom) writes: |> |>>I have a simple question. I sort some data. The easiest way to do this is to |>>decalre a large array to sotre this data and then sort the array. However, |>>it apopears that in a DOS environment, I am only allowed an array up to 64 K in size. Is there a way to declare larger arrays than this for sort. Is there another way that I could store a large quantity of data for sorting. |> |> Don't declare it as an array. Declare it as a pointer and malloc() |>it in the program. Sounds fair. However, in a DOS environment, you may have to use fmalloc() or farmalloc() depending on the memory model and compiler. Actually, this MAY be legal (never tried it, but what the hell): void main ( void ) { char *TheArray=(char *)malloc(BIG_NUMBER); char TheArrayAgain[]=TheArray; // Is this legal? } /* Brian Hook -- MS-DOS Programmer for Contract ----------------------------------------------------------------- "Seamus, that's my dog...I saw her today at the reception...sorry, sixTEEN inches....better save the women and children first...but this one goes to 11! ..anymore of that plutonium nyborg?....there can be only ONE!....like a finger pointing to the moon....ease the seat back...one day closer to death */
darcy@druid.uucp (D'Arcy J.M. Cain) (06/19/91)
In <0094A521.858B9BC0@MAPLE.CIRCA.UFL.EDU> sorrow@oak.circa.ufl.edu writes: >Actually, this MAY be legal (never tried it, but what the hell): >void main ( void ) >{ >char *TheArray=(char *)malloc(BIG_NUMBER); >char TheArrayAgain[]=TheArray; // Is this legal? >} Have you been following the discussion about stupid answers to FAQs? Please don't post code you haven't tried. This is so wrong it is ludicrous and a run through any compiler would have told you so. -- D'Arcy J.M. Cain (darcy@druid) | D'Arcy Cain Consulting | There's no government Toronto, Ontario, Canada | like no government! +1 416 424 2871 |
jos@and.nl (J. Horsmeier) (06/19/91)
In article <1991Jun18.205921.20757@ux1.cso.uiuc.edu> gordon@osiris.cso.uiuc.edu (John Gordon) writes: >tomr@maccs.dcss.mcmaster.ca (Rickey Thomas Tom) writes: > >>I have a simple question. I sort some data. The easiest way to do this is to >>decalre a large array to sotre this data and then sort the array. However, >>it apopears that in a DOS environment, I am only allowed an array up to 64 K in size. Is there a way to declare larger arrays than this for sort. Is there another way that I could store a large quantity of data for sorting. > > Don't declare it as an array. Declare it as a pointer and malloc() >it in the program. It won't work either, I think the poor soul is working on a PC (64K lims). size_t is defined as an int there. An int is 16 bits on these kinda machines. If I'm not mistaken, MSC has a function called halloc(). The 'h' stands for 'huge'. Maybe that helps ... Our sun is not the only star in the universe. Our planet is not the only planet spinning 'round a star. Our planet is not the only planet with 'intelligent' life forms on it in the universe. But our planet *IS* the only planet in the universe where they use MSDOS! Jos |O J.A. Horsmeier AND Software B.V. phone : +31 10 4367100 O| |O Westersingel 106/108 fax : +31 10 4367110 O| |O 3015 LD Rotterdam NL e-mail: jos@and.nl O|
s874330@minyos.xx.rmit.oz.au (Martin Peter Howell) (06/19/91)
tomr@maccs.dcss.mcmaster.ca (Rickey Thomas Tom) writes: >I have a simple question. I sort some data. The easiest way to do this is to >decalre a large array to sotre this data and then sort the array. However, >it apopears that in a DOS environment, I am only allowed an array up to 64 K in size. Is there a way to declare larger arrays than this for sort. Is there another way that I could store a large quantity of data for sorting. >Any comments would be appreciated. Thanks in advance. A good way to do this is to define a series of small arrays and then use a macro to index them transparently #define SIZE 30000 #define Index(i) Arrays[i/SIZE][i % SIZE] int Array1[SIZE]; int Array2[SIZE]; int Array3[SIZE]; int *Arrays[3] = { Array1, Array2, Array3 }; This simulates an array of 90000 ints that can be indexed in the (almost) normal way eg., for (i = 0; i < 90000L; ++i) Index(i) = i; In practice you would probably want to malloc() each of the small arrays and change the Index macro to do bit fiddling to speed it up. --- s874330@minyos.xx.rmit.oz.au This sentance has threee errors.
etxmesa@eos.ericsson.se (Michael Salmon) (06/20/91)
In article <285B94A3.25253@maccs.dcss.mcmaster.ca> Rickey Thomas Tom writes: > I have a simple question. I sort some data. The easiest way to do this is to > decalre a large array to sotre this data and then sort the array. However, > it apopears that in a DOS environment, I am only allowed an array up to 64 K in size. Is there a way to > declare larger arrays than this for sort. Is there another way that I could store a large quantity of data > for sorting. > You don't mention whether you want to sort a large number of small objects or a number of large objects. The later case can be solved by declaring an array of pointers as others heve mentioned but the limit is 16K (64K / sizeof far void *). If instead you want sort integers then you are perhaps better off investigating multiple file sorting algorithms or if it must be in memory you can use a 16K array of pointers to 16K arrays of pointers to integers. The problem here of course is that most published sort algorithms only work for single dimensional arrays. I hope that this has been some help. Michael Salmon L.M.Ericsson Stockholm Standard disclaimer.
fzjaffe@castor (Rory Jaffe) (06/21/91)
In article <285B94A3.25253@maccs.dcss.mcmaster.ca> tomr@maccs.dcss.mcmaster.ca (Rickey Thomas Tom) writes: >I have a simple question. I sort some data. The easiest way to do this is to >decalre a large array to sotre this data and then sort the array. However, >it apopears that in a DOS environment, I am only allowed an array up to 64 K in size. Is there a way to declare larger arrays than this for sort. Is there another way that I could store a large quantity of data for sorting. Since this is the c++ group, here is a C++ suggestion: I had a problem where I had to allocate a multidimensional large array. I went crazy figuring out how to cast the pointer until I contacted Borland: to allocate a 20 X 40 X 30 array: float (* arrayname)[40][30] = new float[20][40][30] ; to delete it delete arrayname ; // BC++ doesn't care to be told it's an array here to use it: arrayname[a][b][c] If the array is greater than 64K, just cast the pointer to huge in the above example.
Dave.Harris@f14.n15.z1.fidonet.org (Dave Harris) (06/21/91)
In a message of <Jun 18 20:32>, Rickey Thomas Tom (1:114/15) writes: >I have a simple question. I sort some data. The easiest way to do this is >to >decalre a large array to sotre this data and then sort the array. >However, >it apopears that in a DOS environment, I am only allowed an array up to >64 K in size. Is there a way to declare larger arrays than this for sort. >Is there another way that I could store a large quantity of data for >sorting. >Any comments would be appreciated. Thanks in advance. Some of the Dos implementations allow for the huge modifier which will allow for larger arrays. After 128K though you are stuck with powers of 2, ie 256K and 512K (should you be that lucky) are the only other legal sizes as near as I can gather. Assuming that your array isn't just raw integers but rather a struct of size say 20 or larger, then allocate these, have an array of pointers pointing to the allocated memory spots, and sort the array containing the pointers. Assuming you don't need much more than 64K, you can hold 2 64K arrays with data, qsort each 64K block then merge/shuffle sort the 2 blocks. -- Uucp: ...{gatech,ames,rutgers}!ncar!asuvax!stjhmc!15!14!Dave.Harris Internet: Dave.Harris@f14.n15.z1.fidonet.org
jdp@engr.uark.edu (Dalton Porter) (06/24/91)
tomr@maccs.dcss.mcmaster.ca (Rickey Thomas Tom) writes: >I have a simple question. I sort some data. The easiest way to do this is to >decalre a large array to sotre this data and then sort the array. However, >it apopears that in a DOS environment, I am only allowed an array up to 64 K in size. Is there a way to declare larger arrays than this for sort. Is there another way that I could store a large quantity of data for sorting. > >Any comments would be appreciated. Thanks in advance. > >Rick I have used this ugly solution.... char huge *data; unsigned long size=DATASIZE; ..... .... data=(char huge *)farcalloc(size,sizeof(char)); /*access like this*/ *(data+i)=whatever; /* Dalton Porter, University of Arkansas, Fayetteville Dept. of Electrical Engineering E-Mail -> jdp@engr.uark.edu "I would get up but the boy crippled me." -Homer Simpson */
Martin_Gaeckler@m.maus.de (Martin Gaeckler) (06/24/91)
Hi, > void main ( void ) > { > char *TheArray=(char *)malloc(BIG_NUMBER); > char TheArrayAgain[]=TheArray; // Is this legal? > } No, it is NOT allowed to initialize an array with another array. The object TheArrayAgain is in fact an array and not a POINTER, what you need. You have to declare TheArrayAgain as char *TheArrayAgain = TheArray; and you may use it like an array (what you probably want). greetings from bavaria Martin