home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / os / msdos / programm / 11759 < prev    next >
Encoding:
Text File  |  1993-01-03  |  1.7 KB  |  51 lines

  1. Path: sparky!uunet!zaphod.mps.ohio-state.edu!news.acns.nwu.edu!uicvm.uic.edu!u16244
  2. Organization: University of Illinois at Chicago
  3. Date: Sunday, 3 Jan 1993 04:05:16 CST
  4. From: David James Alexander Hanley <U16244@uicvm.uic.edu>
  5. Message-ID: <93003.040516U16244@uicvm.uic.edu>
  6. Newsgroups: comp.os.msdos.programmer
  7. Subject: Simulating virtual RAM in c++
  8. Lines: 41
  9.  
  10.   There is a project I have had in mind to try for some time but have not
  11. started on it quite yet.  It would give you virtual arrays for data and
  12. objects in c++ under plain ole MSDOS.  Here is the basic idea:
  13.  
  14.   There are some disk memory allocation functions.  They can be called on
  15. to allocate, store, retreive, and free memory off a "disk heap".  There is
  16. a cache that provides the possibility that some of this data will never
  17. be written to the disk, and will just be allocated and freed.  This is
  18. important.
  19.  
  20.   There are several templates for creating arrays and pointers.
  21.  
  22.   The arrays would work by overloading of the [] operator.  Writes to the
  23. array would be written to the disk.  Reads would be read, and forked over.
  24. I think this could be implemented for arrays, arrays of objects, and
  25. to a lesser degree, pointers.
  26.  
  27. example:
  28.  
  29. #include "diskaray.h>
  30.  
  31. ...
  32.  
  33. DISK_ARRAY<CUSTOMER_RECORD> records[ 10000 ];
  34. CUSTOMER_RECORD record;
  35. ..
  36.  
  37. get_new_record( &record )
  38.  
  39. records[ x ] = record;
  40. ....
  41. record = records[ y ];
  42.  
  43. Unfortunately, you can't access the array directly :
  44. records[ a ].name;
  45.  
  46.   It isn't as pretty as pure virtual RAM, but this WILL work under ms-dos
  47. in c++.  A similar trick could be written in C, pascal, or other languages,
  48. I guess, but it (probably) wouldn't be as pretty.
  49.  
  50.   Ya know, this is a good idea.  I should do this.  When I have time...
  51.