home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / tlx501.zip / TEMPLATE / PTRARRAY.CPP < prev    next >
C/C++ Source or Header  |  1996-01-05  |  3KB  |  104 lines

  1. /****************************************************************************
  2.     $Id: ptrarray.cpp 501.0 1995/03/07 12:26:58 RON Exp $
  3.  
  4.     Copyright (c) 1991-95 Tarma Software Research. All rights reserved.
  5.  
  6.     Project:    Tarma Library for C++ V5.0
  7.     Author:    Ron van der Wal
  8.  
  9.     Implementation of class TLPtrArray<T>.
  10.  
  11.     $Log: ptrarray.cpp $
  12.     Revision 501.0  1995/03/07 12:26:58  RON
  13.     Updated for TLX 5.01
  14.     Revision 1.5  1995/01/31 16:30:44  RON
  15.     Update for release 012
  16.     Added partial support for SunPro C++ compiler
  17.     Revision 1.4  1994/09/28  14:41:01  ron
  18.     Removed Macintosh-style #include references
  19.  
  20.     Revision 1.3  1994/09/27  20:27:17  ron
  21.     Changed path separator from / to \
  22.  
  23.     Revision 1.2  1994/09/26  15:31:54  ron
  24.     Changed include file references
  25.  
  26.     Revision 1.1  1994/08/16  18:15:26  ron
  27.     Initial revision
  28.  
  29. ****************************************************************************/
  30.  
  31. #ifndef _TLX_PTRARRAY_CPP
  32. #define _TLX_PTRARRAY_CPP
  33.  
  34. //----- System headers
  35.  
  36. //----- Project headers
  37.  
  38. #ifndef _TLX_PTRARRAY_H
  39. #include <tlx\501\ptrarray.h>    // Class declaration
  40. #endif
  41.  
  42. /*-------------------------------------------------------------------------*/
  43.     template<class T> TLPtrArray<T>::TLPtrArray(size_t aSize)
  44.  
  45. /*  Constructor to create array of specified size; also doubles as default
  46.     constructor.
  47. ---------------------------------------------------------------------------*/
  48. : TLVPArray(aSize)
  49. {
  50.     SetDelete(DeleteT);
  51. }
  52.  
  53. /*-------------------------------------------------------------------------*/
  54.     template<class T> TLPtrArray<T>::TLPtrArray(index_t aFrom, index_t aTo)
  55.  
  56. /*  Constructor to create array with specified index limits.
  57. ---------------------------------------------------------------------------*/
  58. : TLVPArray(aFrom, aTo)
  59. {
  60.     SetDelete(DeleteT);
  61. }
  62.  
  63. /*-------------------------------------------------------------------------*/
  64.     template<class T> TLPtrArray<T>::TLPtrArray(T *aPtr)
  65.  
  66. /*  Constructor that initializes an array of 1 element.
  67. ---------------------------------------------------------------------------*/
  68. : TLVPArray(aPtr)
  69. {
  70.     SetDelete(DeleteT);
  71. }
  72.  
  73. /*-------------------------------------------------------------------------*/
  74.     template<class T> TLPtrArray<T>::TLPtrArray(T **aArray, size_t aSize)
  75.  
  76. /*  Constructor that initializes an array from a corresponding C-style
  77.     array.
  78. ---------------------------------------------------------------------------*/
  79. : TLVPArray((void **)aArray, aSize)
  80. {
  81.     SetDelete(DeleteT);
  82. }
  83.  
  84. /*-------------------------------------------------------------------------*/
  85.     template<class T> TLPtrArray<T>::TLPtrArray(const TLPtrArray<T> &aArray)
  86.  
  87. /*  Copy constructor.
  88. ---------------------------------------------------------------------------*/
  89. : TLVPArray(aArray)
  90. {
  91.     SetDelete(DeleteT);
  92. }
  93.  
  94. /*-------------------------------------------------------------------------*/
  95.     template<class T> void TLPtrArray<T>::DeleteT(void *aPtr)
  96.  
  97. /*  Deletes pointed to object, after the appropriate typecast.
  98. ---------------------------------------------------------------------------*/
  99. {
  100.     delete (T *)aPtr;
  101. }
  102.  
  103. #endif    // _TLX_PTRARRAY_CPP
  104.