home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c082_122 / 2.ddi / CLASSINC.ZIP / DEQUE.H < prev    next >
Encoding:
C/C++ Source or Header  |  1992-06-10  |  5.1 KB  |  205 lines

  1. /*------------------------------------------------------------------------*/
  2. /*                                                                        */
  3. /*  DEQUE.H                                                               */
  4. /*                                                                        */
  5. /*  Copyright Borland International 1991, 1992                            */
  6. /*  All Rights Reserved                                                   */
  7. /*                                                                        */
  8. /*------------------------------------------------------------------------*/
  9.  
  10. #if !defined( __DEQUE_H )
  11. #define __DEQUE_H
  12.  
  13. #if defined( TEMPLATES )
  14.  
  15.     #if !defined( __DEQUES_H )
  16.     #include <Deques.h>
  17.     #endif  // __DEQUES_H
  18.  
  19.     #pragma option -Vo-
  20.     #if defined( __BCOPT__ ) && !defined( _ALLOW_po )
  21.     #pragma option -po-
  22.     #endif
  23.  
  24.     #define Deque   BI_TCDequeAsDoubleList
  25.     #define PDeque  PBI_TCDequeAsDoubleList
  26.     #define RDeque  RBI_TCDequeAsDoubleList
  27.     #define RPDeque RPBI_TCDequeAsDoubleList
  28.     #define PCDeque PCBI_TCDequeAsDoubleList
  29.     #define RCDeque RCBI_TCDequeAsDoubleList
  30.  
  31.     _CLASSDEF( BI_TCDequeAsDoubleList )
  32.  
  33.     #define DequeIterator   BI_TCDequeAsDoubleListIterator
  34.     #define PDequeIterator  PBI_TCDequeAsDoubleListIterator
  35.     #define RDequeIterator  RBI_TCDequeAsDoubleListIterator
  36.     #define RPDequeIterator RPBI_TCDequeAsDoubleListIterator
  37.     #define PCDequeIterator PCBI_TCDequeAsDoubleListIterator
  38.     #define RCDequeIterator RCBI_TCDequeAsDoubleListIterator
  39.  
  40.     _CLASSDEF( BI_TCDequeAsDoubleListIterator )
  41.  
  42. #else   // TEMPLATES
  43.  
  44.     #if !defined( __CLSTYPES_H )
  45.     #include <ClsTypes.h>
  46.     #endif  // __CLSTYPES_H
  47.  
  48.     #if !defined( __CONTAIN_H )
  49.     #include <Contain.h>
  50.     #endif  // __CONTAIN_H
  51.  
  52.     #if !defined( __DBLLIST_H )
  53.     #include <DblList.h>
  54.     #endif  // __DBLLIST_H
  55.  
  56.     #pragma option -Vo-
  57.     #if defined( __BCOPT__ ) && !defined( _ALLOW_po )
  58.     #pragma option -po-
  59.     #endif
  60.  
  61.     _CLASSDEF(Deque)
  62.  
  63.     class _CLASSTYPE Deque : public Container
  64.     {
  65.  
  66.     public:
  67.  
  68.         ~Deque()
  69.             {
  70.             flush();
  71.             }
  72.  
  73.         Object& peekLeft() const
  74.             {
  75.             return list.peekAtHead();
  76.             }
  77.  
  78.         Object& peekRight() const
  79.             {
  80.             return list.peekAtTail();
  81.             }
  82.  
  83.         Object& getLeft();
  84.         Object& getRight();
  85.  
  86.         void putLeft( Object& o )
  87.             {
  88.             list.addAtHead( o );
  89.             itemsInContainer++;
  90.             }
  91.  
  92.         void putRight( Object& o )
  93.             {
  94.             list.addAtTail( o );
  95.             itemsInContainer++;
  96.             }
  97.  
  98.         virtual void flush( DeleteType dt = DefDelete )
  99.             {
  100.             list.flush( dt );
  101.             }
  102.  
  103.         virtual int isEmpty() const
  104.             {
  105.             return list.isEmpty();
  106.             }
  107.  
  108.         virtual countType getItemsInContainer() const
  109.             {
  110.             return list.getItemsInContainer();
  111.             }
  112.  
  113.         virtual void forEach( iterFuncType f, void _FAR *arg )
  114.             {
  115.             list.forEach( f, arg );
  116.             }
  117.  
  118.         virtual Object _FAR & firstThat( condFuncType f, void _FAR *arg ) const
  119.             {
  120.             return list.firstThat( f, arg );
  121.             }
  122.  
  123.         virtual Object _FAR & lastThat( condFuncType f, void _FAR *arg ) const
  124.             {
  125.             return list.lastThat( f, arg );
  126.             }
  127.  
  128.         virtual classType isA() const
  129.             {
  130.             return dequeClass;
  131.             }
  132.  
  133.         virtual char _FAR *nameOf() const
  134.             {
  135.             return "Deque";
  136.             }
  137.  
  138.         virtual hashValueType hashValue() const
  139.             {
  140.             return list.hashValue();
  141.             }
  142.  
  143.         virtual int isEqual( const Object& obj ) const
  144.             {
  145.             return list.isEqual( obj );
  146.             }
  147.  
  148.         virtual int isSortable() const
  149.             {
  150.             return list.isSortable();
  151.             }
  152.  
  153.         virtual int isAssociation() const
  154.             {
  155.             return list.isAssociation();
  156.             }
  157.  
  158.         virtual void printOn( ostream& os ) const
  159.             {
  160.             list.printOn( os );
  161.             }
  162.  
  163.         virtual void printHeader( ostream& os ) const
  164.             {
  165.             list.printHeader( os );
  166.             }
  167.  
  168.         virtual void printSeparator( ostream& os ) const
  169.             {
  170.             list.printSeparator( os );
  171.             }
  172.  
  173.         virtual void printTrailer( ostream& os ) const
  174.             {
  175.             list.printTrailer( os );
  176.             }
  177.  
  178.         virtual ContainerIterator& initIterator() const;
  179.  
  180.         int ownsElements()
  181.             {
  182.             return list.ownsElements();
  183.             }
  184.  
  185.         void ownsElements( int del )
  186.             { 
  187.             list.ownsElements( del );
  188.             }
  189.  
  190.     private:
  191.  
  192.         DoubleList list;
  193.  
  194.     };
  195.  
  196. #endif  // TEMPLATES
  197.  
  198. #if defined( __BCOPT__ ) && !defined( _ALLOW_po )
  199. #pragma option -po.
  200. #endif
  201. #pragma option -Vo.
  202.  
  203. #endif  // __DEQUE_H
  204.  
  205.