home *** CD-ROM | disk | FTP | other *** search
/ PSION CD 2 / PsionCDVol2.iso / Programs / 720 / PDF090B4-SorceCode / pdf / Array.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  2000-09-30  |  1.3 KB  |  66 lines

  1. //========================================================================
  2. //
  3. // Array.cc
  4. //
  5. // Copyright 1996 Derek B. Noonburg
  6. //
  7. //========================================================================
  8. //
  9. // Ported to EPOC by Sander van der Wal
  10. //
  11. // $Log: Array.cpp $
  12. // Revision 1.2  2000-09-17 13:38:26+02  svdwal
  13. // Ported
  14. //
  15.  
  16. #ifdef __GNUC__
  17. #pragma implementation
  18. #endif
  19.  
  20. #include "Array.h"
  21.  
  22. // --o PdfLib
  23. #include "Object.h"
  24.  
  25.  
  26. #ifndef OOM
  27. static const TInt KArraySizeIncrement = 8;
  28. #else
  29. static const TInt KArraySizeIncrement = 1;
  30. #endif
  31.  
  32. //------------------------------------------------------------------------
  33. // Array
  34. //------------------------------------------------------------------------
  35.  
  36. Array::Array() {
  37.   ref = 1;
  38. }
  39.  
  40. Array::~Array() {
  41.   int i;
  42.  
  43.   if (elems) {
  44.     for (i = 0; i < length; ++i)
  45.       elems[i].free();
  46.   }
  47.   User::Free(elems);
  48. }
  49.  
  50. void Array::addL(Object *elem) {
  51.   if (length + 1 > size) {
  52.     size += KArraySizeIncrement;
  53.     elems = (Object *)User::ReAllocL(elems, size * sizeof(Object));
  54.   }
  55.   elems[length] = *elem;
  56.   ++length;
  57. }
  58.  
  59. Object *Array::getL(int i, Object *obj) {
  60.   return elems[i].fetchL(obj);
  61. }
  62.  
  63. Object *Array::getNFL(int i, Object *obj) {
  64.   return elems[i].copyL(obj);
  65. }
  66.