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

  1. /****************************************************************************
  2.     $Id: ptrqueue.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 TLPtrQueue<T>.
  10.  
  11.     $Log: ptrqueue.cpp $
  12.     Revision 501.0  1995/03/07 12:26:58  RON
  13.     Updated for TLX 5.01
  14.     Revision 1.6  1995/01/31 16:30:46  RON
  15.     Update for release 012
  16.     Added partial support for SunPro C++ compiler
  17.     Revision 1.5  1994/10/05  18:49:09  ron
  18.     Added constructor that accepts an iterator
  19.  
  20.     Revision 1.4  1994/09/28  14:41:10  ron
  21.     Removed Macintosh-style #include references
  22.  
  23.     Revision 1.3  1994/09/27  20:27:21  ron
  24.     Changed path separator from / to \
  25.  
  26.     Revision 1.2  1994/09/26  15:32:20  ron
  27.     Changed include file references
  28.  
  29.     Revision 1.1  1994/08/16  18:15:27  ron
  30.     Initial revision
  31.  
  32. ****************************************************************************/
  33.  
  34. #ifndef _TLX_PTRQUEUE_CPP
  35. #define _TLX_PTRQUEUE_CPP
  36.  
  37. //----- System headers
  38.  
  39. //----- Project headers
  40.  
  41. #ifndef _TLX_PTRARRAY_H
  42. #include <tlx\501\ptrarray.h>    // Class declaration
  43. #endif
  44.  
  45. /*-------------------------------------------------------------------------*/
  46.     template<class T> TLPtrQueue<T>::TLPtrQueue(size_t aSize, size_t aDelta)
  47.  
  48. /*  Constructor to create queue of specified size; also doubles as default
  49.     constructor.
  50. ---------------------------------------------------------------------------*/
  51. : TLVPQueue(aSize, aDelta)
  52. {
  53.     SetDelete(DeleteT);
  54. }
  55.  
  56. /*-------------------------------------------------------------------------*/
  57.     template<class T> TLPtrQueue<T>::TLPtrQueue(T *aPtr)
  58.  
  59. /*  Constructor that initializes a queue of 1 element.
  60. ---------------------------------------------------------------------------*/
  61. : TLVPQueue(aPtr)
  62. {
  63.     SetDelete(DeleteT);
  64. }
  65.  
  66. /*-------------------------------------------------------------------------*/
  67.     template<class T> TLPtrQueue<T>::TLPtrQueue(T **aQueue, size_t aSize)
  68.  
  69. /*  Constructor that initializes a queue from a corresponding C-style
  70.     vector.
  71. ---------------------------------------------------------------------------*/
  72. : TLVPQueue((void **)aQueue, aSize)
  73. {
  74.     SetDelete(DeleteT);
  75. }
  76.  
  77. /*-------------------------------------------------------------------------*/
  78.     template<class T> TLPtrQueue<T>::TLPtrQueue(const TLPtrQueue<T> &aQueue)
  79.  
  80. /*  Copy constructor.
  81. ---------------------------------------------------------------------------*/
  82. : TLVPQueue(aQueue)
  83. {
  84.     SetDelete(DeleteT);
  85. }
  86.  
  87. /*-------------------------------------------------------------------------*/
  88.     template<class T> TLPtrQueue<T>::TLPtrQueue(TLPtrIter<T> &aIter)
  89.  
  90. /*  Constructor that initializes the queue from an iterator.
  91. ---------------------------------------------------------------------------*/
  92. : TLVPQueue(aIter.Count())
  93. {
  94.     SetDelete(DeleteT);
  95.     for (aIter.Reset(); aIter.Next(); )
  96.     Enqueue(aIter.Peek());
  97. }
  98.  
  99. /*-------------------------------------------------------------------------*/
  100.     template<class T> void TLPtrQueue<T>::DeleteT(void *aPtr)
  101.  
  102. /*  Deletes pointed to object, after the appropriate typecast.
  103. ---------------------------------------------------------------------------*/
  104. {
  105.     delete (T *)aPtr;
  106. }
  107.  
  108. #endif    // _TLX_PTRQUEUE_CPP
  109.