home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / oclsrc15.zip / OCL / Include / OSortedList.hpp < prev    next >
C/C++ Source or Header  |  1996-08-12  |  3KB  |  116 lines

  1. // OCL - OS/2 Class Library
  2. // (c) Cubus 1995
  3. // All Rights Reserved
  4. // OSortedList.hpp
  5.  
  6. /*
  7.  * Redistribution and use in source and binary forms, with or without
  8.  * modification, are permitted provided that the following conditions
  9.  * are met:
  10.  * 1. Redistributions of source code must retain the above copyright
  11.  *    notice, this list of conditions and the following disclaimer.
  12.  * 2. Neither the name Cubus nor the name Team OCL may be used to
  13.  *    endorse or promote products derived from this software
  14.  *    without specific prior written permission.
  15.  * 3. See OCL.INF for a detailed copyright notice.
  16.  *
  17.  *              THIS SOFTWARE IS PROVIDED ``AS IS'' AND
  18.  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  19.  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  20.  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
  21.  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  22.  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  23.  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  24.  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  25.  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  26.  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  27.  * SUCH DAMAGE.
  28.  */
  29.  
  30. // $Header: W:/Projects/OCL/Include/rcs/OSortedList.hpp 1.50 1996/08/11 23:47:29 B.STEIN Release $
  31.  
  32. #ifndef SORTEDLIST_INCLUDED
  33.   #define SORTEDLIST_INCLUDED
  34.  
  35.  
  36. #ifndef LIST_INCLUDED
  37.   #include <OList.hpp>
  38. #endif
  39.  
  40. #ifndef OOCOLL_INCLUDED
  41.   #include <OOrderedCollection.hpp>
  42. #endif
  43.  
  44.  
  45. template <class T>
  46. class OSortedList 
  47.   : public OOrderedCollection
  48. {
  49.  protected:
  50.     virtual
  51.        BOOL _isLess       (PVOID first, PVOID second);
  52.  
  53.     virtual
  54.        void freeItem      (PVOID elem);
  55.  
  56.  public:
  57.  
  58.     OSortedList           (BOOL copyElements = FALSE);
  59.  
  60.     OSortedList           (OSortedList<T>& slist,
  61.                            BOOL copyElements = FALSE);
  62.  
  63.     virtual
  64.        ~OSortedList       ();
  65.  
  66.     virtual
  67.        PSZ isOfType       () const;
  68.  
  69.  
  70.     virtual T
  71.        *getFirst          (),
  72.        *getLast           (),
  73.        *get               (),
  74.        *getNext           (),
  75.        *getNext           (T *elem),
  76.        *getPrev           (),
  77.        *getPrev           (T *elem),
  78.        *getItem           (ULONG itemNum);
  79.  
  80.     virtual OListItem<T>
  81.       *first              () const,
  82.       *actual             () const,
  83.       *last               () const,
  84.       *getNextListItem    (T *elem),
  85.       *getPrevListItem    (T *elem);
  86.  
  87.  
  88.     virtual OSortedList<T>
  89.       &operator <<        (T* elem),
  90.       &operator <<        (T& elem),
  91.       &operator >>        (T& elem),
  92.       &operator >>        (T* elem);
  93.  
  94.     virtual void
  95.       add                 (T& elem),
  96.       add                 (T* elem),
  97.       allElementsDo       (void (*function)(const T* elem)) const,
  98.       allElementsDo       (OConstIterator<T>& iter) const,
  99.       allElementsDo       (void (*function)(T* elem)),
  100.       allElementsDo       (OIterator<T>& iter);
  101.  
  102. // pure virtual
  103.  
  104.     virtual BOOL isLess   (const T* first, const T* second) = 0;
  105. };
  106.  
  107.  
  108. #ifdef __OCL_RESOLVE_TEMPLATES__
  109.   #include <OSortedList.inl>
  110. #endif
  111.  
  112.  
  113. #endif // SORTEDLIST_INCLUDED
  114.  
  115. // end of source
  116.