home *** CD-ROM | disk | FTP | other *** search
/ QBasic & Borland Pascal & C / Delphi5.iso / C / BC_502 / CLASSINC.PAK / ARRAYS.H < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-06  |  26.0 KB  |  847 lines

  1. //----------------------------------------------------------------------------
  2. // Borland BIDS Container Library
  3. // Copyright (c) 1991, 1997 by Borland International, All Rights Reserved
  4. //
  5. //$Revision:   5.8  $
  6. //
  7. //----------------------------------------------------------------------------
  8. #if !defined( CLASSLIB_ARRAYS_H )
  9. #define CLASSLIB_ARRAYS_H
  10.  
  11. //#define TEMPLATES
  12.  
  13. #if !defined( CLASSLIB_DEFS_H )
  14. # include <classlib/defs.h>
  15. #endif
  16. #if !defined( CLASSLIB_SHDDEL_H )
  17. # include <classlib/shddel.h>
  18. #endif
  19. #if !defined( CLASSLIB_ALLOCTR_H )
  20. # include <classlib/alloctr.h>
  21. #endif
  22. #if !defined( CLASSLIB_VECTIMP_H )
  23. # include <classlib/vectimp.h>
  24. #endif
  25.  
  26. #pragma option -Vo-
  27. #if defined( BI_CLASSLIB_NO_po )
  28. # pragma option -po-
  29. #endif
  30.  
  31. #if defined(BI_NAMESPACE)
  32. namespace ClassLib {
  33. #endif
  34.  
  35. /*------------------------------------------------------------------------*/
  36. /*                                                                        */
  37. /*  [INTERNAL USE ONLY]                                                   */
  38. /*                                                                        */
  39. /*  template <class Vect, class T> class TArrayAsVectorImp                */
  40. /*                                                                        */
  41. /*  Implements the type-independent array operations, using a vector      */
  42. /*  as the underlying implementation.  The type Vect specifies the        */
  43. /*  form of the vector, either a TCVectorImp<T0>, a TSVectorImp<T0>, a    */
  44. /*  TICVectorImp<T0>, or a TISVectorImp<T0>.  The type T specifies the    */
  45. /*  type of the objects to be put in the array.  When using               */
  46. /*  TCVectorImp<T0> or a TSVectorImp<T0> T should be the same as T0. When */
  47. /*  using TICVectorImp<T0> or TISVectorImp<T0> T should be of type        */
  48. /*  pointer to T0.  See TArrayAsVector and                                */
  49. /*  TIArrayAsVector for examples.                                         */
  50. /*                                                                        */
  51. /*------------------------------------------------------------------------*/
  52.  
  53. template <class Vect, class T> class TArrayAsVectorImp
  54. {
  55.  
  56. public:
  57.  
  58.     TArrayAsVectorImp( int upper, int lower, int delta ) :
  59.         Data( upper-lower+1,delta ),
  60.         Lowerbound( lower )
  61.         {
  62.         }
  63.  
  64.     int LowerBound() const
  65.         {
  66.         return Lowerbound;
  67.         }
  68.  
  69.     int UpperBound() const
  70.         {
  71.         return BoundBase( Data.Limit() )-1;
  72.         }
  73.  
  74.     unsigned ArraySize() const
  75.         {
  76.         return Data.Limit();
  77.         }
  78.  
  79.     int IsFull() const
  80.         {
  81.         return Data.GetDelta() == 0 && Data.Count() >= Data.Limit();
  82.         }
  83.  
  84.     int IsEmpty() const
  85.         {
  86.         return Data.Count() == 0;
  87.         }
  88.  
  89.     unsigned GetItemsInContainer() const
  90.         {
  91.         return Data.Count();
  92.         }
  93.  
  94. #if defined( BI_OLDNAMES )
  95.     int lowerBound() const { return LowerBound(); }
  96.     int upperBound() const { return UpperBound(); }
  97.     unsigned arraySize() const { return ArraySize(); }
  98.     int isFull() const { return IsFull(); }
  99.     int isEmpty() const { return IsEmpty(); }
  100.     unsigned getItemsInContainer() const { return GetItemsInContainer(); }
  101. #endif
  102.  
  103.     void Reallocate( unsigned sz, unsigned offset = 0 )
  104.         {
  105.         Data.Resize( sz, offset );
  106.         }
  107.  
  108.  
  109.     void SetData( int loc, const T& t )
  110.         {
  111.         PRECONDITION( loc >= Lowerbound && loc <= UpperBound() );
  112.         Data[ ZeroBase(loc) ] = t;
  113.         }
  114.  
  115.     void RemoveEntry( int loc )
  116.         {
  117.         SqueezeEntry( ZeroBase(loc) );
  118.         }
  119.  
  120.     void SqueezeEntry( unsigned loc )
  121.         {
  122.         PRECONDITION( loc < Data.Count() );
  123.         Data.Detach( loc );
  124.         }
  125.  
  126.     unsigned ZeroBase( int loc ) const
  127.         {
  128.         return loc - Lowerbound;
  129.         }
  130.  
  131.     int BoundBase( unsigned loc ) const
  132.         {
  133.         return loc == UINT_MAX ? INT_MAX : loc + Lowerbound;
  134.         }
  135.  
  136.     void Grow( int loc )
  137.         {
  138.         if( loc < LowerBound() )
  139.             Reallocate( ArraySize() + (loc - Lowerbound) );
  140.         else if( loc >= BoundBase( Data.Limit()) )
  141.             Reallocate( ZeroBase(loc) );
  142.         }
  143.  
  144.     int Lowerbound;
  145.  
  146.     Vect Data;
  147.  
  148. };
  149.  
  150. /*------------------------------------------------------------------------*/
  151. /*                                                                        */
  152. /*  [INTERNAL USE ONLY]                                                   */
  153. /*                                                                        */
  154. /*  template <class Vect, class T> class TDArrayAsVectorImp               */
  155. /*                                                                        */
  156. /*  Implements the fundamental array operations for direct arrays, using  */
  157. /*  a vector as the underlying implementation.                            */
  158. /*                                                                        */
  159. /*------------------------------------------------------------------------*/
  160.  
  161. template <class Vect, class T> class TDArrayAsVectorImp :
  162.     public TArrayAsVectorImp<Vect,T>
  163. {
  164.  
  165. public:
  166.  
  167.     typedef void (*IterFunc)(T&, void *);
  168.     typedef int  (*CondFunc)(const T&, void *);
  169.  
  170.     TDArrayAsVectorImp( int upper, int lower, int delta ) :
  171.         TArrayAsVectorImp<Vect,T>( upper, lower, delta )
  172.         {
  173.         }
  174.  
  175.     int Add( const T& t )
  176.         {
  177.         return Data.Add(t);
  178.         }
  179.  
  180.     int Detach( const T& t )
  181.         {
  182.         return Data.Detach(t);
  183.         }
  184.  
  185.     int Detach( int loc )
  186.         {
  187.         return Data.Detach( ZeroBase(loc) );
  188.         }
  189.  
  190.     int Destroy( const T& t )
  191.         {
  192.         return Detach(t);
  193.         }
  194.  
  195.     int Destroy( int loc )
  196.         {
  197.         return Detach(loc);
  198.         }
  199.  
  200.     int HasMember( const T& t ) const
  201.         {
  202.         return Data.Find(t) != UINT_MAX;
  203.         }
  204.  
  205.     int Find( const T& t ) const
  206.         {
  207.         return BoundBase( Data.Find( t ) );
  208.         }
  209.  
  210.     T& operator []( int loc )
  211.         {
  212.         Grow( loc+1 );
  213.         return Data[ZeroBase(loc)];
  214.         }
  215.  
  216.     T& operator []( int loc ) const
  217.         {
  218.         PRECONDITION( loc >= Lowerbound && ZeroBase(loc) < Data.Limit() );
  219.         return Data[ZeroBase(loc)];
  220.         }
  221.  
  222.     void ForEach( IterFunc iter, void *args )
  223.         {
  224.         if( !IsEmpty() )
  225.             Data.ForEach( iter, args );
  226.         }
  227.  
  228.     T *FirstThat( CondFunc cond, void *args ) const
  229.         {
  230.         if( IsEmpty() )
  231.             return 0;
  232.         return Data.FirstThat( cond, args );
  233.         }
  234.  
  235.     T *LastThat( CondFunc cond, void *args ) const
  236.         {
  237.         if( IsEmpty() )
  238.             return 0;
  239.         return Data.LastThat( cond, args );
  240.         }
  241.  
  242.     void Flush()
  243.         {
  244.         Data.Flush();
  245.         }
  246.  
  247. #if defined( BI_OLDNAMES )
  248.     int add( const T& t ) { return Add(t); }
  249.     int detach( const T& t,TShouldDelete::DeleteType=TShouldDelete::NoDelete)
  250.         { return Detach(t); }
  251.     int detach( int loc,TShouldDelete::DeleteType=TShouldDelete::NoDelete)
  252.         { return Detach(loc); }
  253.     int destroy( const T& t ) { return Destroy(t); }
  254.     int destroy( int loc,TShouldDelete::DeleteType ) { return Destroy(loc); }
  255.     int hasMember( const T& t ) const { return HasMember(t); }
  256.     void forEach( IterFunc iter, void *args )
  257.         { ForEach( iter, args ); }
  258.     T *firstThat( CondFunc cond, void *args ) const
  259.         { return FirstThat( cond, args ); }
  260.     T *lastThat( CondFunc cond, void *args ) const
  261.         { return lastThat( cond, args ); }
  262.     void flush( TShouldDelete::DeleteType = TShouldDelete::DefDelete )
  263.         { Flush(); }
  264. #endif
  265.  
  266. protected:
  267.  
  268.     const T& ItemAt( int i ) const
  269.         {
  270.         return Data[ ZeroBase(i) ];
  271.         }
  272.  
  273. };
  274.  
  275. /*------------------------------------------------------------------------*/
  276. /*                                                                        */
  277. /*  [INTERNAL USE ONLY]                                                   */
  278. /*                                                                        */
  279. /*  template <class Vect, class T> class TIArrayAsVectorImp               */
  280. /*                                                                        */
  281. /*  Implements the fundamental array operations for indirect arrays,      */
  282. /*  using a vector as the underlying implementation.                      */
  283. /*                                                                        */
  284. /*------------------------------------------------------------------------*/
  285.  
  286. template <class Vect, class T> class TIArrayAsVectorImp :
  287.     public TArrayAsVectorImp<Vect,T *>, public TShouldDelete
  288. {
  289.  
  290. public:
  291.  
  292.     typedef void (*IterFunc)(T&, void *);
  293.     typedef int  (*CondFunc)(const T&, void *);
  294.  
  295.     TIArrayAsVectorImp( int upper, int lower, int delta ) :
  296.         TArrayAsVectorImp<Vect,T *>( upper, lower, delta )
  297.         {
  298.         }
  299.  
  300.     ~TIArrayAsVectorImp()
  301.         {
  302.         Flush();
  303.         }
  304.  
  305.     int Add( T *t )
  306.         {
  307.         return Data.Add(t);
  308.         }
  309.  
  310.     int Detach( T *t,
  311.                 TShouldDelete::DeleteType dt = TShouldDelete::NoDelete )
  312.         {
  313.         return Data.Detach(t,DelObj(dt));
  314.         }
  315.  
  316.     int Detach( int loc,
  317.                 TShouldDelete::DeleteType dt = TShouldDelete::NoDelete )
  318.         {
  319.         return Data.Detach( ZeroBase(loc), DelObj(dt) );
  320.         }
  321.  
  322.     int Destroy( T *t )
  323.         {
  324.         return Detach(t,TShouldDelete::Delete);
  325.         }
  326.  
  327.     int Destroy( int loc )
  328.         {
  329.         return Detach(loc,TShouldDelete::Delete);
  330.         }
  331.  
  332.     int HasMember( const T *t ) const
  333.         {
  334.         return Data.Find(t) != UINT_MAX;
  335.         }
  336.  
  337.     int Find( const T *t ) const
  338.         {
  339.         return BoundBase( Data.Find( t ) );
  340.         }
  341.  
  342.     T *& operator []( int loc )
  343.         {
  344.         Grow( loc+1 );
  345.         return Data[ZeroBase(loc)];
  346.         }
  347.  
  348.     T *& operator []( int loc ) const
  349.         {
  350.         PRECONDITION( loc >= Lowerbound && ZeroBase(loc) < Data.Limit() );
  351.         return Data[ZeroBase(loc)];
  352.         }
  353.  
  354.     void ForEach( IterFunc iter, void *args )
  355.         {
  356.         if( !IsEmpty() )
  357.             Data.ForEach( iter, args );
  358.         }
  359.  
  360.     T *FirstThat( CondFunc cond, void *args ) const
  361.         {
  362.         if( IsEmpty() )
  363.             return 0;
  364.         return Data.FirstThat( cond, args );
  365.         }
  366.  
  367.     T *LastThat( CondFunc cond, void *args ) const
  368.         {
  369.         if( IsEmpty() )
  370.             return 0;
  371.         return Data.LastThat( cond, args );
  372.         }
  373.  
  374.     void Flush( DeleteType dt = DefDelete )
  375.         {
  376.         Data.Flush(DelObj(dt));
  377.         }
  378.  
  379. #if defined( BI_OLDNAMES )
  380.     int add( T *t ) { return Add(t); }
  381.     int detach( T *t,TShouldDelete::DeleteType dt =TShouldDelete::NoDelete)
  382.         { return Detach(t,dt); }
  383.     int detach( int loc,TShouldDelete::DeleteType dt =TShouldDelete::NoDelete)
  384.         { return Detach(loc,dt); }
  385.     int destroy( T *t ) { return Destroy(t); }
  386.     int destroy( int loc,TShouldDelete::DeleteType ) { return Destroy(loc); }
  387.     int find( const T *t ) const { return Find(t); }
  388.     int hasMember( T *t ) const { return HasMember(t); }
  389.     void forEach( IterFunc iter, void *args )
  390.         { ForEach( iter, args ); }
  391.     T *firstThat( CondFunc cond, void *args ) const
  392.         { return FirstThat( cond, args ); }
  393.     T *lastThat( CondFunc cond, void *args ) const
  394.         { return lastThat( cond, args ); }
  395.     void flush( TShouldDelete::DeleteType = TShouldDelete::DefDelete )
  396.         { Flush(); }
  397. #endif
  398.  
  399. protected:
  400.  
  401.     T *& ItemAt( int i ) const
  402.         {
  403.         return Data[ ZeroBase(i) ];
  404.         }
  405.  
  406. };
  407.  
  408. /*------------------------------------------------------------------------*/
  409. /*                                                                        */
  410. /*  template <class T,class Alloc> class TMArrayAsVector                  */
  411. /*  template <class T,class Alloc> class TMArrayAsVectorIterator          */
  412. /*                                                                        */
  413. /*  Implements a managed array of objects of type T, using a vector as    */
  414. /*  the underlying implementation.                                        */
  415. /*                                                                        */
  416. /*------------------------------------------------------------------------*/
  417.  
  418. template <class T, class Alloc> class TMArrayAsVectorIterator;
  419.  
  420. template <class T, class Alloc> class TMArrayAsVector :
  421.     public TDArrayAsVectorImp<TMCVectorImp<T,Alloc>,T>
  422. {
  423.  
  424.     friend TMArrayAsVectorIterator<T,Alloc>;
  425.  
  426. public:
  427.  
  428.     TMArrayAsVector( int upper, int lower = 0, int delta = 0 ) :
  429.         TDArrayAsVectorImp<TMCVectorImp<T,Alloc>,T>( upper, lower, delta )
  430.         {
  431.         }
  432.  
  433.     int AddAt( const T& t, int loc )
  434.         {
  435.         return Data.AddAt( t, ZeroBase(loc) );
  436.         }
  437.  
  438. #if defined( BI_OLDNAMES )
  439.     int addAt( const T& t, int loc ) { return AddAt(t,loc); }
  440. #endif
  441.  
  442. };
  443.  
  444. template <class T, class Alloc> class TMArrayAsVectorIterator :
  445.     public TMCVectorIteratorImp<T,Alloc>
  446. {
  447.  
  448. public:
  449.  
  450.     TMArrayAsVectorIterator( const TMArrayAsVector<T,Alloc>& a ) :
  451.         TMCVectorIteratorImp<T,Alloc>( a.Data ) {}
  452.  
  453. };
  454.  
  455. #if defined( BI_OLDNAMES )
  456. #define BI_MArrayAsVector TMArrayAsVector
  457. #define BI_MArrayAsVectorIterator TMArrayAsVectorIterator
  458. #endif
  459.  
  460. /*------------------------------------------------------------------------*/
  461. /*                                                                        */
  462. /*  template <class T> class TArrayAsVector                               */
  463. /*  template <class T> class TArrayAsVectorIterator                       */
  464. /*                                                                        */
  465. /*  Implements an array of objects of type T, using a vector as the       */
  466. /*  underlying implementation and TStandardAllocator as its memory        */
  467. /*  manager.                                                              */
  468. /*                                                                        */
  469. /*------------------------------------------------------------------------*/
  470.  
  471. template <class T> class TArrayAsVector :
  472.     public TMArrayAsVector<T,TStandardAllocator>
  473. {
  474.  
  475. public:
  476.  
  477.     TArrayAsVector( int upper, int lower = 0, int delta = 0 ) :
  478.         TMArrayAsVector<T,TStandardAllocator>( upper, lower, delta )
  479.         {
  480.         }
  481.  
  482. };
  483.  
  484. template <class T> class TArrayAsVectorIterator :
  485.     public TMArrayAsVectorIterator<T,TStandardAllocator>
  486. {
  487.  
  488. public:
  489.  
  490.     TArrayAsVectorIterator( const TArrayAsVector<T>& a ) :
  491.         TMArrayAsVectorIterator<T,TStandardAllocator>(a)
  492.         {
  493.         }
  494.  
  495. };
  496.  
  497. #if defined( BI_OLDNAMES )
  498. #define BI_ArrayAsVector TArrayAsVector
  499. #define BI_ArrayAsVectorIterator TArrayAsVectorIterator
  500. #endif
  501.  
  502. /*------------------------------------------------------------------------*/
  503. /*                                                                        */
  504. /*  template <class T,class Alloc> class TMSArrayAsVector                 */
  505. /*  template <class T,class Alloc> class TMSArrayAsVectorIterator         */
  506. /*                                                                        */
  507. /*  Implements a managed, sorted array of objects of type T, using a      */
  508. /*  vector as the underlying implementation.                              */
  509. /*                                                                        */
  510. /*------------------------------------------------------------------------*/
  511.  
  512. template <class T, class Alloc> class TMSArrayAsVectorIterator;
  513.  
  514. template <class T, class Alloc> class TMSArrayAsVector :
  515.     public TDArrayAsVectorImp<TMSVectorImp<T,Alloc>,T>
  516. {
  517.  
  518.     friend TMSArrayAsVectorIterator<T,Alloc>;
  519.  
  520. public:
  521.  
  522.     TMSArrayAsVector( int upper, int lower = 0, int delta = 0 ) :
  523.         TDArrayAsVectorImp<TMSVectorImp<T,Alloc>,T>( upper, lower, delta )
  524.         {
  525.         }
  526.  
  527. };
  528.  
  529. template <class T, class Alloc> class TMSArrayAsVectorIterator :
  530.     public TMSVectorIteratorImp<T,Alloc>
  531. {
  532.  
  533. public:
  534.  
  535.     TMSArrayAsVectorIterator( const TMSArrayAsVector<T,Alloc>& a ) :
  536.         TMSVectorIteratorImp<T,Alloc>( a.Data ) {}
  537.  
  538. };
  539.  
  540. #if defined( BI_OLDNAMES )
  541. #define BI_MSArrayAsVector TMSArrayAsVector
  542. #define BI_MSArrayAsVectorIterator TMSArrayAsVectorIterator
  543. #endif
  544.  
  545. /*------------------------------------------------------------------------*/
  546. /*                                                                        */
  547. /*  template <class T> class TSArrayAsVector                              */
  548. /*  template <class T> class TSArrayAsVectorIterator                      */
  549. /*                                                                        */
  550. /*  Implements a sorted array of objects of type T, using a vector as     */
  551. /*  the underlying implementation and TStandardAllocator as its memory    */
  552. /*  manager.                                                              */
  553. /*                                                                        */
  554. /*------------------------------------------------------------------------*/
  555.  
  556. template <class T> class TSArrayAsVector :
  557.     public TMSArrayAsVector<T,TStandardAllocator>
  558. {
  559.  
  560. public:
  561.  
  562.     TSArrayAsVector( int upper, int lower = 0, int delta = 0 ) :
  563.         TMSArrayAsVector<T,TStandardAllocator>( upper, lower, delta )
  564.         {
  565.         }
  566.  
  567. };
  568.  
  569. template <class T> class TSArrayAsVectorIterator :
  570.     public TMSArrayAsVectorIterator<T,TStandardAllocator>
  571. {
  572.  
  573. public:
  574.  
  575.     TSArrayAsVectorIterator( const TSArrayAsVector<T>& a ) :
  576.         TMSArrayAsVectorIterator<T,TStandardAllocator>( a ) {}
  577.  
  578. };
  579.  
  580. #if defined( BI_OLDNAMES )
  581. #define BI_SArrayAsVector TSArrayAsVector
  582. #define BI_SArrayAsVectorIterator TSArrayAsVectorIterator
  583. #endif
  584.  
  585. /*------------------------------------------------------------------------*/
  586. /*                                                                        */
  587. /*  template <class T,class Alloc> class TMIArrayAsVector                 */
  588. /*  template <class T,class Alloc> class TMIArrayAsVectorIterator         */
  589. /*                                                                        */
  590. /*  Implements a managed indirect array of objects of type T, using a     */
  591. /*  vector as the underlying implementation.                              */
  592. /*                                                                        */
  593. /*------------------------------------------------------------------------*/
  594.  
  595. template <class T, class Alloc> class TMIArrayAsVectorIterator;
  596.  
  597. template <class T, class Alloc> class TMIArrayAsVector :
  598.     public TIArrayAsVectorImp<TMICVectorImp<T,Alloc>,T>
  599. {
  600.  
  601.     friend TMIArrayAsVectorIterator<T,Alloc>;
  602.  
  603. public:
  604.  
  605.     TMIArrayAsVector( int upper, int lower = 0, int delta = 0 ) :
  606.         TIArrayAsVectorImp<TMICVectorImp<T,Alloc>,T>( upper, lower, delta )
  607.         {
  608.         }
  609.  
  610.     int AddAt( T *t, int loc )
  611.         {
  612.         return Data.AddAt( t, ZeroBase(loc) );
  613.         }
  614.  
  615. #if defined( BI_OLDNAMES )
  616.     int addAt( T *t, int loc ) { return AddAt(t,loc); }
  617. #endif
  618.  
  619. };
  620.  
  621. template <class T, class Alloc> class TMIArrayAsVectorIterator :
  622.     public TMICVectorIteratorImp<T,Alloc>
  623. {
  624.  
  625. public:
  626.  
  627.     TMIArrayAsVectorIterator( const TMIArrayAsVector<T,Alloc>& a ) :
  628.         TMICVectorIteratorImp<T,Alloc>( a.Data ) {}
  629.  
  630. };
  631.  
  632. #if defined( BI_OLDNAMES )
  633. #define BI_MIArrayAsVector TMIArrayAsVector
  634. #define BI_MIArrayAsVectorIterator TMIArrayAsVectorIterator
  635. #endif
  636.  
  637. /*------------------------------------------------------------------------*/
  638. /*                                                                        */
  639. /*  template <class T> class TIArrayAsVector                              */
  640. /*  template <class T> class TIArrayAsVectorIterator                      */
  641. /*                                                                        */
  642. /*  Implements an indirect array of objects of type T, using a vector as  */
  643. /*  the underlying implementation and TStandardAllocator as its memory    */
  644. /*  manager.                                                              */
  645. /*                                                                        */
  646. /*------------------------------------------------------------------------*/
  647.  
  648. template <class T> class TIArrayAsVector :
  649.     public TMIArrayAsVector<T,TStandardAllocator>
  650. {
  651.  
  652. public:
  653.  
  654.     TIArrayAsVector( int upper, int lower = 0, int delta = 0 ) :
  655.         TMIArrayAsVector<T,TStandardAllocator>( upper, lower, delta )
  656.         {
  657.         }
  658.  
  659. };
  660.  
  661. template <class T> class TIArrayAsVectorIterator :
  662.     public TMIArrayAsVectorIterator<T,TStandardAllocator>
  663. {
  664.  
  665. public:
  666.  
  667.     TIArrayAsVectorIterator( const TIArrayAsVector<T>& a ) :
  668.         TMIArrayAsVectorIterator<T,TStandardAllocator>(a)
  669.         {
  670.         }
  671.  
  672. };
  673.  
  674. #if defined( BI_OLDNAMES )
  675. #define BI_IArrayAsVector TIArrayAsVector
  676. #define BI_IArrayAsVectorIterator TIArrayAsVectorIterator
  677. #endif
  678.  
  679. /*------------------------------------------------------------------------*/
  680. /*                                                                        */
  681. /*  template <class T,class Alloc> class TMISArrayAsVector                */
  682. /*  template <class T,class Alloc> class TMISArrayAsVectorIterator        */
  683. /*                                                                        */
  684. /*  Implements a managed, indirect sorted array of objects of type T,     */
  685. /*  using a vector as the underlying implementation.                      */
  686. /*                                                                        */
  687. /*------------------------------------------------------------------------*/
  688.  
  689. template <class T, class Alloc> class TMISArrayAsVectorIterator;
  690.  
  691. template <class T, class Alloc> class TMISArrayAsVector :
  692.     public TIArrayAsVectorImp<TMISVectorImp<T,Alloc>,T>
  693. {
  694.  
  695.     friend TMISArrayAsVectorIterator<T,Alloc>;
  696.  
  697. public:
  698.  
  699.     TMISArrayAsVector( int upper, int lower = 0, int delta = 0 ) :
  700.         TIArrayAsVectorImp<TMISVectorImp<T,Alloc>,T>( upper, lower, delta )
  701.         {
  702.         }
  703.  
  704. };
  705.  
  706. template <class T, class Alloc> class TMISArrayAsVectorIterator :
  707.     public TMISVectorIteratorImp<T,Alloc>
  708. {
  709.  
  710. public:
  711.  
  712.     TMISArrayAsVectorIterator( const TMISArrayAsVector<T,Alloc>& a ) :
  713.         TMISVectorIteratorImp<T,Alloc>( a.Data ) {}
  714.  
  715. };
  716.  
  717. #if defined( BI_OLDNAMES )
  718. #define BI_MISArrayAsVector TMISArrayAsVector
  719. #define BI_MIArrayAsVectorIterator TMIArrayAsVectorIterator
  720. #endif
  721.  
  722. /*------------------------------------------------------------------------*/
  723. /*                                                                        */
  724. /*  template <class T> class TISArrayAsVector                             */
  725. /*  template <class T> class TISArrayAsVectorIterator                     */
  726. /*                                                                        */
  727. /*  Implements an indirect sorted array of objects of type T, using a     */
  728. /*  vector as the underlying implementation and TStandardAllocator as its */
  729. /*  memory manager.                                                       */
  730. /*                                                                        */
  731. /*------------------------------------------------------------------------*/
  732.  
  733. template <class T> class TISArrayAsVector :
  734.     public TMISArrayAsVector<T,TStandardAllocator>
  735. {
  736.  
  737. public:
  738.  
  739.     TISArrayAsVector( int upper, int lower = 0, int delta = 0 ) :
  740.         TMISArrayAsVector<T,TStandardAllocator>( upper, lower, delta )
  741.         {
  742.         }
  743.  
  744. };
  745.  
  746. template <class T> class TISArrayAsVectorIterator :
  747.     public TMISArrayAsVectorIterator<T,TStandardAllocator>
  748. {
  749.  
  750. public:
  751.  
  752.     TISArrayAsVectorIterator( const TISArrayAsVector<T>& a ) :
  753.         TMISArrayAsVectorIterator<T,TStandardAllocator>(a)
  754.         {
  755.         }
  756.  
  757. };
  758.  
  759. #if defined( BI_OLDNAMES )
  760. #define BI_ISArrayAsVector TISArrayAsVector
  761. #define BI_ISArrayAsVectorIterator TISArrayAsVectorIterator
  762. #endif
  763.  
  764. /*------------------------------------------------------------------------*/
  765. /*                                                                        */
  766. /*  template <class T> class TArray                                       */
  767. /*  template <class T> class TArrayIterator                               */
  768. /*                                                                        */
  769. /*  Easy names for TArrayAsVector and TArrayAsVectorIterator              */
  770. /*                                                                        */
  771. /*------------------------------------------------------------------------*/
  772.  
  773. template <class T> class TArray :
  774.     public TArrayAsVector<T>
  775. {
  776.  
  777. public:
  778.  
  779.     TArray( int upper, int lower = 0, int delta = 0 ) :
  780.         TArrayAsVector<T>( upper, lower, delta )
  781.         {
  782.         }
  783.  
  784. };
  785.  
  786. template <class T> class TArrayIterator :
  787.     public TArrayAsVectorIterator<T>
  788. {
  789.  
  790. public:
  791.  
  792.  
  793.     TArrayIterator( const TArray<T>& a ) :
  794.         TArrayAsVectorIterator<T>(a)
  795.         {
  796.         }
  797.  
  798. };
  799.  
  800. /*------------------------------------------------------------------------*/
  801. /*                                                                        */
  802. /*  template <class T> class TSArray                                      */
  803. /*  template <class T> class TSArrayIterator                              */
  804. /*                                                                        */
  805. /*  Easy names for TSArrayAsVector and TSArrayAsVectorIterator            */
  806. /*                                                                        */
  807. /*------------------------------------------------------------------------*/
  808.  
  809. template <class T> class TSArray :
  810.     public TSArrayAsVector<T>
  811. {
  812.  
  813. public:
  814.  
  815.     TSArray( int upper, int lower = 0, int delta = 0 ) :
  816.         TSArrayAsVector<T>( upper, lower, delta )
  817.         {
  818.         }
  819.  
  820. };
  821.  
  822. template <class T> class TSArrayIterator :
  823.     public TSArrayAsVectorIterator<T>
  824. {
  825.  
  826. public:
  827.  
  828.  
  829.     TSArrayIterator( const TSArray<T>& a ) :
  830.         TSArrayAsVectorIterator<T>(a)
  831.         {
  832.         }
  833.  
  834. };
  835.  
  836. #if defined(BI_NAMESPACE)
  837. }   // namespace ClassLib
  838. #endif
  839.  
  840. #if defined( BI_CLASSLIB_NO_po )
  841. #pragma option -po.
  842. #endif
  843.  
  844. #pragma option -Vo.
  845.  
  846. #endif  // CLASSLIB_ARRAYS_H
  847.