home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 7 / 07.iso / c / c221 / 6.ddi / MWHC.006 / 92 < prev    next >
Encoding:
Text File  |  1992-06-07  |  3.6 KB  |  107 lines

  1. #ifndef __RWSORTVEC_H__
  2. #define __RWSORTVEC_H__
  3. pragma push_align_members(64);
  4.  
  5. /*
  6.  * RWSortedVector -- sorted vector; uses insertion sort.
  7.  *
  8.  * $Header:   E:/vcs/rw/sortvec.h_v   1.3   17 Mar 1992 19:21:10   KEFFER  $
  9.  *
  10.  ****************************************************************************
  11.  *
  12.  * Rogue Wave 
  13.  * P.O. Box 2328
  14.  * Corvallis, OR 97339
  15.  * Voice: (503) 754-3010    FAX: (503) 757-6650
  16.  *
  17.  * Copyright (C) 1989, 1990, 1991. This software is subject to copyright 
  18.  * protection under the laws of the United States and other countries.
  19.  *
  20.  ***************************************************************************
  21.  *
  22.  * $Log:   E:/vcs/rw/sortvec.h_v  $
  23.  * 
  24.  *    Rev 1.3   17 Mar 1992 19:21:10   KEFFER
  25.  * Changed BOUNDS_CHECK to RWBOUNDS_CHECK
  26.  * 
  27.  *    Rev 1.2   18 Feb 1992 09:54:46   KEFFER
  28.  * 
  29.  *    Rev 1.1   28 Oct 1991 09:08:24   keffer
  30.  * Changed inclusions to <rw/xxx.h>
  31.  * 
  32.  *    Rev 1.0   28 Jul 1991 08:17:18   keffer
  33.  * Tools.h++ V4.0.5 PVCS baseline version
  34.  *
  35.  */
  36.  
  37. /*
  38.  * This collection inherits from RWOrdered.  A few member functions
  39.  * must be disallowed because the insertion order is determined internally
  40.  * rather than by function calls.  Examples are "insertAfter()", or 
  41.  * "prepend()".  A few others can be done more efficiently because we can
  42.  * take advantage of the internal sorting of objects.  Examples are "index()",
  43.  * "occurrencesOf()", etc.
  44.  */
  45.  
  46. #include "rw/ordcltn.h"
  47.  
  48. // OrderedCollection iterator is used for SortedVector:
  49. typedef RWOrderedIterator RWSortedVectorIterator;
  50.  
  51. class RWExport RWSortedVector : public RWOrdered {
  52. public:
  53.  
  54.   RWSortedVector(unsigned size = RWCollection::DEFAULT_CAPACITY);
  55.  
  56.   RWBoolean            operator==(const RWSortedVector& c) const {return RWOrdered::operator==(c);}
  57.  
  58.   /****************** Redefined from RWOrdered *******************/
  59.  
  60. #ifdef CONST_OVERLOADS
  61.   virtual const RWCollectable*    at(int) const;    // Cannot use as lvalue.
  62. #endif
  63.   virtual int            index(const RWCollectable* p) const;
  64.   virtual RWCollectable*    insert(RWCollectable*);
  65.   virtual ClassID        isA() const {return __RWSORTEDVECTOR;}
  66.   virtual RWCollectable*    newSpecies() const;
  67.   virtual unsigned        occurrencesOf(const RWCollectable* p) const;
  68.  
  69.   const RWCollectable*        operator[](int i) const        // With bounds checking
  70.     { boundsCheck(i); return vec(i); }
  71.   const RWCollectable*        operator()(int i) const        // Optional bounds checking
  72.     {
  73. #ifdef RWBOUNDS_CHECK
  74.       boundsCheck(i);
  75. #endif
  76.       return vec(i);
  77.     }
  78.  
  79.   /****************** Inherited from RWOrdered *******************/
  80. //virtual void            apply(RWapplyCollectable, void*);
  81. //virtual void            clear();
  82. //virtual void            clearAndDestroy();
  83. //virtual RWBoolean        contains(const RWCollectable*) const;
  84. //virtual unsigned        entries() const {return nitems;}
  85. //virtual RWCollectable*    find(const RWCollectable* p) const;
  86. //virtual RWCollectable*    first() const;
  87. //virtual RWBoolean        isEmpty() const {return nitems==0;}
  88. //virtual RWCollectable*    last() const;
  89. //virtual RWCollectable*    remove(const RWCollectable*);
  90. //virtual void            removeAndDestroy(const RWCollectable*);
  91.  
  92. //void                resize(unsigned);    // Cannot shrink below population
  93.  
  94.   /****************** Disallowed from RWOrdered *******************/
  95. private:
  96.   virtual RWCollectable*&    at(int);    // No lvalues allowed for sorted vector
  97.   virtual RWCollectable*    append(RWCollectable* a);
  98.   virtual RWCollectable*    insertAfter(int, RWCollectable*);
  99.   virtual RWCollectable*    prepend(RWCollectable*);
  100.   void                push(RWCollectable*);
  101.   RWCollectable*        pop();
  102.   RWCollectable*        top() const;
  103. };
  104.  
  105. pragma pop_align_members();
  106. #endif /* __RWSORTVEC_H__ */
  107.