home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 4 / AACD04.ISO / AACD / Programming / lsEstuff / docs / dynamic_array.doc < prev    next >
Encoding:
Text File  |  1999-08-15  |  1.6 KB  |  69 lines

  1. dynamic_array.m by Leif Salomonsson '99
  2.  
  3. /* this module contains 1464 bytes of code! */
  4.  
  5. /* ... and 41 reloc entries */
  6.  
  7. (----) OBJECT dynamic_array
  8.          dynamic_array(a,b)
  9.            /* the constructor. a = valuetype (DAVS_CHAR/DAVS_INT/DAVS_LONG)    */
  10.            /*                  b = nr of values to put in one chunk of memory, */
  11.            /*                  gets mul'ed with 4. 8-1024 should be good values   */
  12.  
  13.          end()
  14.            /* destructor */
  15.  
  16.          set(a,b)
  17.            /* set element. a = x, b = value */
  18.  
  19.          unset(a)
  20.             /* unset element. sets it to NIL and frees its memory (if possible*)
  21.             /* gets slower the bigger allocvalue ! */
  22.  
  23.          get(a)
  24.             /* get element. a = x  */
  25.             /* not already set element will return NIL ! */
  26.  
  27.          count()
  28.             /* counts elements with value different from NIL ! */
  29.  
  30.          clear()
  31.            /* free/unset all elements and the memory they use */
  32. (----) ENDOBJECT     /* SIZEOF=14 */
  33.  
  34. CONST DAVS_INT=2,
  35.       DAVS_LONG=4,
  36.       DAVS_CHAR=1
  37.  
  38. /*
  39.   code from module "xl.m" used:
  40.   OBJECT xli [1 acc]
  41. */
  42.  
  43. simple testproggy
  44. sets 50 000 elements[0-49999] to values 0-49999
  45. results with A1200 1230/50 :
  46.  
  47. >test
  48.  
  49. dynamic ARRAY OF INT, allocval=256 (1024 bytes)
  50.  13:59:53
  51. getting 50 000 empty points
  52.  13:59:54
  53. setting 50 000 points
  54.  13:59:57
  55. counting points : 49999 -> the first point was set to NIL, so theres no error :)*
  56.  13:59:58
  57. setting the same 50 000 points again
  58.  14:00:01
  59. getting 50 000 points
  60.  14:00:04
  61. memory available now : 1976888
  62.  14:00:04
  63. unsetting 50 000 points
  64.  14:00:19
  65. memory available now : 2077672
  66. counting values (should be 0) : 0
  67. finnished!
  68.  
  69.