From 1057d74a111cb8bbc4cd9914276327e94b246e0f Mon Sep 17 00:00:00 2001 From: Robert Osfield Date: Fri, 27 Jun 2008 12:44:41 +0000 Subject: [PATCH] Simplified the MixinVector class so that it no longer supports custom allocators, instead just uses std::vector<>'s default allocators. --- include/osg/MixinVector | 78 +++++++++++++++++------------------------ include/osg/Shape | 4 +-- 2 files changed, 35 insertions(+), 47 deletions(-) diff --git a/include/osg/MixinVector b/include/osg/MixinVector index cfa462aac..0ed454c38 100644 --- a/include/osg/MixinVector +++ b/include/osg/MixinVector @@ -24,10 +24,10 @@ namespace osg { * * @author Neil Groves */ -template > +template class MixinVector { - typedef typename std::vector vector_type; + typedef typename std::vector vector_type; public: typedef typename vector_type::allocator_type allocator_type; typedef typename vector_type::value_type value_type; @@ -42,27 +42,18 @@ public: typedef typename vector_type::size_type size_type; typedef typename vector_type::difference_type difference_type; - explicit MixinVector(const allocator_type& alloc = allocator_type()) - : _impl(alloc) + explicit MixinVector() : _impl() { } - + explicit MixinVector(size_type initial_size, const value_type& fill_value = value_type()) : _impl(initial_size, fill_value) { } - MixinVector(size_type initial_size, - const value_type& fill_value, - const allocator_type& alloc) - : _impl(initial_size, fill_value, alloc) - { - } - template - MixinVector(InputIterator first, InputIterator last, - const allocator_type& alloc = allocator_type()) - : _impl(first, last, alloc) + MixinVector(InputIterator first, InputIterator last) + : _impl(first, last) { } @@ -90,9 +81,6 @@ public: virtual ~MixinVector() {} - operator const vector_type&() const { return _impl; } - operator vector_type&() { return _impl; } - void clear() { _impl.clear(); } void resize(size_type new_size, const value_type& fill_value = value_type()) { _impl.resize(new_size, fill_value); } void reserve(size_type new_capacity) { _impl.reserve(new_capacity); } @@ -153,54 +141,54 @@ public: vector_type& asVector() { return _impl; } const vector_type& asVector() const { return _impl; } - friend inline bool operator==(const MixinVector& left, const MixinVector& right) { return left._impl == right._impl; } - friend inline bool operator==(const MixinVector& left, const std::vector& right) { return left._impl == right; } - friend inline bool operator==(const std::vector& left, const MixinVector& right) { return left == right._impl; } + friend inline bool operator==(const MixinVector& left, const MixinVector& right) { return left._impl == right._impl; } + friend inline bool operator==(const MixinVector& left, const std::vector& right) { return left._impl == right; } + friend inline bool operator==(const std::vector& left, const MixinVector& right) { return left == right._impl; } - friend inline bool operator!=(const MixinVector& left, const MixinVector& right) { return left._impl != right._impl; } - friend inline bool operator!=(const MixinVector& left, const std::vector& right) { return left._impl != right; } - friend inline bool operator!=(const std::vector& left, const MixinVector& right) { return left != right._impl; } + friend inline bool operator!=(const MixinVector& left, const MixinVector& right) { return left._impl != right._impl; } + friend inline bool operator!=(const MixinVector& left, const std::vector& right) { return left._impl != right; } + friend inline bool operator!=(const std::vector& left, const MixinVector& right) { return left != right._impl; } - friend inline bool operator<(const MixinVector& left, const MixinVector& right) { return left._impl < right._impl; } - friend inline bool operator<(const MixinVector& left, const std::vector& right) { return left._impl < right; } - friend inline bool operator<(const std::vector& left, const MixinVector& right) { return left < right._impl; } + friend inline bool operator<(const MixinVector& left, const MixinVector& right) { return left._impl < right._impl; } + friend inline bool operator<(const MixinVector& left, const std::vector& right) { return left._impl < right; } + friend inline bool operator<(const std::vector& left, const MixinVector& right) { return left < right._impl; } - friend inline bool operator>(const MixinVector& left, const MixinVector& right) { return left._impl > right._impl; } - friend inline bool operator>(const MixinVector& left, const std::vector& right) { return left._impl > right; } - friend inline bool operator>(const std::vector& left, const MixinVector& right) { return left > right._impl; } + friend inline bool operator>(const MixinVector& left, const MixinVector& right) { return left._impl > right._impl; } + friend inline bool operator>(const MixinVector& left, const std::vector& right) { return left._impl > right; } + friend inline bool operator>(const std::vector& left, const MixinVector& right) { return left > right._impl; } - friend inline bool operator<=(const MixinVector& left, const MixinVector& right) { return left._impl <= right._impl; } - friend inline bool operator<=(const MixinVector& left, const std::vector& right) { return left._impl <= right; } - friend inline bool operator<=(const std::vector& left, const MixinVector& right) { return left <= right._impl; } + friend inline bool operator<=(const MixinVector& left, const MixinVector& right) { return left._impl <= right._impl; } + friend inline bool operator<=(const MixinVector& left, const std::vector& right) { return left._impl <= right; } + friend inline bool operator<=(const std::vector& left, const MixinVector& right) { return left <= right._impl; } - friend inline bool operator>=(const MixinVector& left, const MixinVector& right) { return left._impl >= right._impl; } - friend inline bool operator>=(const MixinVector& left, const std::vector& right) { return left._impl >= right; } - friend inline bool operator>=(const std::vector& left, const MixinVector& right) { return left >= right._impl; } + friend inline bool operator>=(const MixinVector& left, const MixinVector& right) { return left._impl >= right._impl; } + friend inline bool operator>=(const MixinVector& left, const std::vector& right) { return left._impl >= right; } + friend inline bool operator>=(const std::vector& left, const MixinVector& right) { return left >= right._impl; } private: vector_type _impl; }; -template inline +template inline void -swap(MixinVector& left, - MixinVector& right) +swap(MixinVector& left, + MixinVector& right) { std::swap(left.asVector(), right.asVector()); } -template inline +template inline void -swap(MixinVector& left, - std::vector& right) +swap(MixinVector& left, + std::vector& right) { std::swap(left.asVector(), right); } -template inline +template inline void -swap(std::vector& left, - MixinVector& right) +swap(std::vector& left, + MixinVector& right) { std::swap(left, right.asVector()); } diff --git a/include/osg/Shape b/include/osg/Shape index 183cd4d0b..1b8cee092 100644 --- a/include/osg/Shape +++ b/include/osg/Shape @@ -508,9 +508,9 @@ class OSG_EXPORT HeightField : public Shape /** Get the const sFloatArray height data.*/ const osg::FloatArray* getFloatArray() const { return _heights.get(); } - HeightList& getHeightList() { return *_heights; } + HeightList& getHeightList() { return _heights->asVector(); } - const HeightList& getHeightList() const { return *_heights; } + const HeightList& getHeightList() const { return _heights->asVector(); } /** Set the height of the skirt to render around the edge of HeightField. * The skirt is used as a means of disguising edge boundaries between adjacent HeightField,