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.
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 */
jamshid@ut-emx.uucp (Jamshid Afshar) (06/24/91)
In article <13324@aggie.ucdavis.edu> fzjaffe@castor.ucdavis.edu (Rory Jaffe) writes: ... >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 While this deletion works for objects without destructors, you should generally tell operator delete() when you are deleting an array, otherwise it doesn't know to call the destructor for anything but the first object. The syntax is: delete [ARRAY_SIZE] p; In 2.1 compilers (not BC++) you are no longer required to give the size since the implementation is required to maintain that information: delete [] p; This makes me wonder, why then do you have to tell delete() that it's deleting an array?? >... >If the array is greater than 64K, just cast the pointer to huge in the >above example. **DO NOT DO THIS**. operator new() takes a parameter of size_t, which Borland C++ defines as an unsigned int (even in the huge model). This means you can never allocate more than 64K with operator new(). In general, casting, or even using, 'far', 'near' and 'huge' in MS-DOS is just asking for trouble. Save yourself alot of grief and just use the large model and don't put these (non-portable) keywords in your code. If at all possible, don't use objects or arrays larger than 64K since they require you mess with huge pointers and farmalloc/free. There is a Turbo/Borland C++ mailing list. To subscribe, send mail to listserv@ucf1vm.cc.ucf.edu OR listserv@ucf1vm.bitnet Containing the line subscribe tcplus-l Your Name There is also a Turbo/Borland C++ bug list available from sun.soe.clarkson.edu [128.153.12.3] in the file ~ftp/pub/Turbo-C++/bug-report. Jamshid Afshar jamshid@emx.utexas.edu