home *** CD-ROM | disk | FTP | other *** search
- #ifndef __RWSORTVEC_H__
- #define __RWSORTVEC_H__
- pragma push_align_members(64);
-
- /*
- * RWSortedVector -- sorted vector; uses insertion sort.
- *
- * $Header: E:/vcs/rw/sortvec.h_v 1.3 17 Mar 1992 19:21:10 KEFFER $
- *
- ****************************************************************************
- *
- * Rogue Wave
- * P.O. Box 2328
- * Corvallis, OR 97339
- * Voice: (503) 754-3010 FAX: (503) 757-6650
- *
- * Copyright (C) 1989, 1990, 1991. This software is subject to copyright
- * protection under the laws of the United States and other countries.
- *
- ***************************************************************************
- *
- * $Log: E:/vcs/rw/sortvec.h_v $
- *
- * Rev 1.3 17 Mar 1992 19:21:10 KEFFER
- * Changed BOUNDS_CHECK to RWBOUNDS_CHECK
- *
- * Rev 1.2 18 Feb 1992 09:54:46 KEFFER
- *
- * Rev 1.1 28 Oct 1991 09:08:24 keffer
- * Changed inclusions to <rw/xxx.h>
- *
- * Rev 1.0 28 Jul 1991 08:17:18 keffer
- * Tools.h++ V4.0.5 PVCS baseline version
- *
- */
-
- /*
- * This collection inherits from RWOrdered. A few member functions
- * must be disallowed because the insertion order is determined internally
- * rather than by function calls. Examples are "insertAfter()", or
- * "prepend()". A few others can be done more efficiently because we can
- * take advantage of the internal sorting of objects. Examples are "index()",
- * "occurrencesOf()", etc.
- */
-
- #include "rw/ordcltn.h"
-
- // OrderedCollection iterator is used for SortedVector:
- typedef RWOrderedIterator RWSortedVectorIterator;
-
- class RWExport RWSortedVector : public RWOrdered {
- public:
-
- RWSortedVector(unsigned size = RWCollection::DEFAULT_CAPACITY);
-
- RWBoolean operator==(const RWSortedVector& c) const {return RWOrdered::operator==(c);}
-
- /****************** Redefined from RWOrdered *******************/
-
- #ifdef CONST_OVERLOADS
- virtual const RWCollectable* at(int) const; // Cannot use as lvalue.
- #endif
- virtual int index(const RWCollectable* p) const;
- virtual RWCollectable* insert(RWCollectable*);
- virtual ClassID isA() const {return __RWSORTEDVECTOR;}
- virtual RWCollectable* newSpecies() const;
- virtual unsigned occurrencesOf(const RWCollectable* p) const;
-
- const RWCollectable* operator[](int i) const // With bounds checking
- { boundsCheck(i); return vec(i); }
- const RWCollectable* operator()(int i) const // Optional bounds checking
- {
- #ifdef RWBOUNDS_CHECK
- boundsCheck(i);
- #endif
- return vec(i);
- }
-
- /****************** Inherited from RWOrdered *******************/
- //virtual void apply(RWapplyCollectable, void*);
- //virtual void clear();
- //virtual void clearAndDestroy();
- //virtual RWBoolean contains(const RWCollectable*) const;
- //virtual unsigned entries() const {return nitems;}
- //virtual RWCollectable* find(const RWCollectable* p) const;
- //virtual RWCollectable* first() const;
- //virtual RWBoolean isEmpty() const {return nitems==0;}
- //virtual RWCollectable* last() const;
- //virtual RWCollectable* remove(const RWCollectable*);
- //virtual void removeAndDestroy(const RWCollectable*);
-
- //void resize(unsigned); // Cannot shrink below population
-
- /****************** Disallowed from RWOrdered *******************/
- private:
- virtual RWCollectable*& at(int); // No lvalues allowed for sorted vector
- virtual RWCollectable* append(RWCollectable* a);
- virtual RWCollectable* insertAfter(int, RWCollectable*);
- virtual RWCollectable* prepend(RWCollectable*);
- void push(RWCollectable*);
- RWCollectable* pop();
- RWCollectable* top() const;
- };
-
- pragma pop_align_members();
- #endif /* __RWSORTVEC_H__ */
-