MixinVector
Go to the documentation of this file.
/* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
*
* This library is open source and may be redistributed and/or modified under
* the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
* (at your option) any later version. The full license is in LICENSE file
* included with this distribution, and on the openscenegraph.org website.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* OpenSceneGraph Public License for more details.
*/
#ifndef OSG_MIXIN_VECTOR
#define OSG_MIXIN_VECTOR 1
#include <vector>
namespace osg {
template<class ValueT>
class MixinVector
{
typedef typename std::vector<ValueT> vector_type;
public:
typedef typename vector_type::allocator_type allocator_type;
typedef typename vector_type::value_type value_type;
typedef typename vector_type::const_pointer const_pointer;
typedef typename vector_type::pointer pointer;
typedef typename vector_type::const_reference const_reference;
typedef typename vector_type::reference reference;
typedef typename vector_type::const_iterator const_iterator;
typedef typename vector_type::iterator iterator;
typedef typename vector_type::const_reverse_iterator const_reverse_iterator;
typedef typename vector_type::reverse_iterator reverse_iterator;
typedef typename vector_type::size_type size_type;
typedef typename vector_type::difference_type difference_type;
explicit MixinVector() : _impl()
{
}
explicit MixinVector(size_type initial_size, const value_type& fill_value = value_type())
: _impl(initial_size, fill_value)
{
}
template<class InputIterator>
MixinVector(InputIterator first, InputIterator last)
: _impl(first, last)
{
}
MixinVector(const vector_type& other)
: _impl(other)
{
}
MixinVector(const MixinVector& other)
: _impl(other._impl)
{
}
MixinVector& operator=(const vector_type& other)
{
_impl = other;
return *this;
}
MixinVector& operator=(const MixinVector& other)
{
_impl = other._impl;
return *this;
}
virtual ~MixinVector() {}
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); }
void swap(vector_type& other) { _impl.swap(other); }
void swap(MixinVector& other) { _impl.swap(other._impl); }
bool empty() const { return _impl.empty(); }
size_type size() const { return _impl.size(); }
size_type capacity() const { return _impl.capacity(); }
size_type max_size() const { return _impl.max_size(); }
allocator_type get_allocator() const { return _impl.get_allocator(); }
const_iterator begin() const { return _impl.begin(); }
iterator begin() { return _impl.begin(); }
const_iterator end() const { return _impl.end(); }
iterator end() { return _impl.end(); }
const_reverse_iterator rbegin() const { return _impl.rbegin(); }
reverse_iterator rbegin() { return _impl.rbegin(); }
const_reverse_iterator rend() const { return _impl.rend(); }
reverse_iterator rend() { return _impl.rend(); }
const_reference operator[](size_type index) const { return _impl[index]; }
reference operator[](size_type index) { return _impl[index]; }
const_reference at(size_type index) const { return _impl.at(index); }
reference at(size_type index) { return _impl.at(index); }
void assign(size_type count, const value_type& value) { _impl.assign(count, value); }
template<class Iter>
void assign(Iter first, Iter last) { _impl.assign(first, last); }
void push_back(const value_type& value) { _impl.push_back(value); }
void pop_back() { _impl.pop_back(); }
iterator erase(iterator where) { return _impl.erase(where); }
iterator erase(iterator first, iterator last) { return _impl.erase(first, last); }
iterator insert(iterator where, const value_type& value) { return _impl.insert(where, value); }
template<class InputIterator>
void insert(iterator where, InputIterator first, InputIterator last)
{
_impl.insert(where, first, last);
}
void insert(iterator where, size_type count, const value_type& value)
{
_impl.insert(where, count, value);
}
const_reference back() const { return _impl.back(); }
reference back() { return _impl.back(); }
const_reference front() const { return _impl.front(); }
reference front() { return _impl.front(); }
vector_type& asVector() { return _impl; }
const vector_type& asVector() const { return _impl; }
friend inline bool operator==(const MixinVector<ValueT>& left, const MixinVector<ValueT>& right) { return left._impl == right._impl; }
friend inline bool operator==(const MixinVector<ValueT>& left, const std::vector<ValueT>& right) { return left._impl == right; }
friend inline bool operator==(const std::vector<ValueT>& left, const MixinVector<ValueT>& right) { return left == right._impl; }
friend inline bool operator!=(const MixinVector<ValueT>& left, const MixinVector<ValueT>& right) { return left._impl != right._impl; }
friend inline bool operator!=(const MixinVector<ValueT>& left, const std::vector<ValueT>& right) { return left._impl != right; }
friend inline bool operator!=(const std::vector<ValueT>& left, const MixinVector<ValueT>& right) { return left != right._impl; }
friend inline bool operator<(const MixinVector<ValueT>& left, const MixinVector<ValueT>& right) { return left._impl < right._impl; }
friend inline bool operator<(const MixinVector<ValueT>& left, const std::vector<ValueT>& right) { return left._impl < right; }
friend inline bool operator<(const std::vector<ValueT>& left, const MixinVector<ValueT>& right) { return left < right._impl; }
friend inline bool operator>(const MixinVector<ValueT>& left, const MixinVector<ValueT>& right) { return left._impl > right._impl; }
friend inline bool operator>(const MixinVector<ValueT>& left, const std::vector<ValueT>& right) { return left._impl > right; }
friend inline bool operator>(const std::vector<ValueT>& left, const MixinVector<ValueT>& right) { return left > right._impl; }
friend inline bool operator<=(const MixinVector<ValueT>& left, const MixinVector<ValueT>& right) { return left._impl <= right._impl; }
friend inline bool operator<=(const MixinVector<ValueT>& left, const std::vector<ValueT>& right) { return left._impl <= right; }
friend inline bool operator<=(const std::vector<ValueT>& left, const MixinVector<ValueT>& right) { return left <= right._impl; }
friend inline bool operator>=(const MixinVector<ValueT>& left, const MixinVector<ValueT>& right) { return left._impl >= right._impl; }
friend inline bool operator>=(const MixinVector<ValueT>& left, const std::vector<ValueT>& right) { return left._impl >= right; }
friend inline bool operator>=(const std::vector<ValueT>& left, const MixinVector<ValueT>& right) { return left >= right._impl; }
private:
vector_type _impl;
};
template<class ValueT> inline
void
swap(MixinVector<ValueT>& left,
MixinVector<ValueT>& right)
{
std::swap(left.asVector(), right.asVector());
}
template<class ValueT> inline
void
swap(MixinVector<ValueT>& left,
std::vector<ValueT>& right)
{
std::swap(left.asVector(), right);
}
template<class ValueT> inline
void
swap(std::vector<ValueT>& left,
MixinVector<ValueT>& right)
{
std::swap(left, right.asVector());
}
} // namespace osg
#endif
osg::MixinVector
Definition MixinVector:29
osg::MixinVector::operator>
friend bool operator>(const MixinVector< ValueT > &left, const std::vector< ValueT > &right)
Definition MixinVector:157
osg::MixinVector::erase
iterator erase(iterator where)
Definition MixinVector:120
osg::MixinVector::clear
void clear()
Definition MixinVector:84
osg::MixinVector::const_reference
vector_type::const_reference const_reference
Definition MixinVector:36
osg::MixinVector::rbegin
reverse_iterator rbegin()
Definition MixinVector:103
osg::MixinVector::size
size_type size() const
Definition MixinVector:92
osg::MixinVector::front
reference front()
Definition MixinVector:139
osg::MixinVector::pop_back
void pop_back()
Definition MixinVector:118
osg::MixinVector::reverse_iterator
vector_type::reverse_iterator reverse_iterator
Definition MixinVector:41
osg::MixinVector::operator[]
reference operator[](size_type index)
Definition MixinVector:108
osg::MixinVector::insert
void insert(iterator where, InputIterator first, InputIterator last)
Definition MixinVector:126
osg::MixinVector::back
const_reference back() const
Definition MixinVector:136
osg::MixinVector::operator=
MixinVector & operator=(const MixinVector &other)
Definition MixinVector:76
osg::MixinVector::operator=
MixinVector & operator=(const vector_type &other)
Definition MixinVector:70
osg::MixinVector::max_size
size_type max_size() const
Definition MixinVector:94
osg::MixinVector::operator<=
friend bool operator<=(const MixinVector< ValueT > &left, const MixinVector< ValueT > &right)
Definition MixinVector:160
osg::MixinVector::operator[]
const_reference operator[](size_type index) const
Definition MixinVector:107
osg::MixinVector::difference_type
vector_type::difference_type difference_type
Definition MixinVector:43
osg::MixinVector::MixinVector
MixinVector(const vector_type &other)
Definition MixinVector:60
osg::MixinVector::operator==
friend bool operator==(const MixinVector< ValueT > &left, const MixinVector< ValueT > &right)
Definition MixinVector:144
osg::MixinVector::operator>=
friend bool operator>=(const MixinVector< ValueT > &left, const MixinVector< ValueT > &right)
Definition MixinVector:164
osg::MixinVector::at
reference at(size_type index)
Definition MixinVector:111
osg::MixinVector::asVector
vector_type & asVector()
Definition MixinVector:141
osg::MixinVector::operator<=
friend bool operator<=(const std::vector< ValueT > &left, const MixinVector< ValueT > &right)
Definition MixinVector:162
osg::MixinVector::operator>
friend bool operator>(const MixinVector< ValueT > &left, const MixinVector< ValueT > &right)
Definition MixinVector:156
osg::MixinVector::end
const_iterator end() const
Definition MixinVector:99
osg::MixinVector::resize
void resize(size_type new_size, const value_type &fill_value=value_type())
Definition MixinVector:85
osg::MixinVector::size_type
vector_type::size_type size_type
Definition MixinVector:42
osg::MixinVector::const_pointer
vector_type::const_pointer const_pointer
Definition MixinVector:34
osg::MixinVector::operator!=
friend bool operator!=(const MixinVector< ValueT > &left, const MixinVector< ValueT > &right)
Definition MixinVector:148
osg::MixinVector::swap
void swap(MixinVector &other)
Definition MixinVector:89
osg::MixinVector::operator<
friend bool operator<(const MixinVector< ValueT > &left, const std::vector< ValueT > &right)
Definition MixinVector:153
osg::MixinVector::value_type
vector_type::value_type value_type
Definition MixinVector:33
osg::MixinVector::operator<
friend bool operator<(const MixinVector< ValueT > &left, const MixinVector< ValueT > &right)
Definition MixinVector:152
osg::MixinVector::assign
void assign(size_type count, const value_type &value)
Definition MixinVector:113
osg::MixinVector::MixinVector
MixinVector(InputIterator first, InputIterator last)
Definition MixinVector:55
osg::MixinVector::const_reverse_iterator
vector_type::const_reverse_iterator const_reverse_iterator
Definition MixinVector:40
osg::MixinVector::front
const_reference front() const
Definition MixinVector:138
osg::MixinVector::end
iterator end()
Definition MixinVector:100
osg::MixinVector::asVector
const vector_type & asVector() const
Definition MixinVector:142
osg::MixinVector::pointer
vector_type::pointer pointer
Definition MixinVector:35
osg::MixinVector::rend
reverse_iterator rend()
Definition MixinVector:105
osg::MixinVector::operator>=
friend bool operator>=(const MixinVector< ValueT > &left, const std::vector< ValueT > &right)
Definition MixinVector:165
osg::MixinVector::assign
void assign(Iter first, Iter last)
Definition MixinVector:115
osg::MixinVector::operator<
friend bool operator<(const std::vector< ValueT > &left, const MixinVector< ValueT > &right)
Definition MixinVector:154
osg::MixinVector::reserve
void reserve(size_type new_capacity)
Definition MixinVector:86
osg::MixinVector::at
const_reference at(size_type index) const
Definition MixinVector:110
osg::MixinVector::back
reference back()
Definition MixinVector:137
osg::MixinVector::operator>=
friend bool operator>=(const std::vector< ValueT > &left, const MixinVector< ValueT > &right)
Definition MixinVector:166
osg::MixinVector::begin
iterator begin()
Definition MixinVector:98
osg::MixinVector::MixinVector
MixinVector(size_type initial_size, const value_type &fill_value=value_type())
Definition MixinVector:49
osg::MixinVector::rend
const_reverse_iterator rend() const
Definition MixinVector:104
osg::MixinVector::begin
const_iterator begin() const
Definition MixinVector:97
osg::MixinVector::push_back
void push_back(const value_type &value)
Definition MixinVector:117
osg::MixinVector::operator!=
friend bool operator!=(const std::vector< ValueT > &left, const MixinVector< ValueT > &right)
Definition MixinVector:150
osg::MixinVector::MixinVector
MixinVector()
Definition MixinVector:45
osg::MixinVector::operator==
friend bool operator==(const std::vector< ValueT > &left, const MixinVector< ValueT > &right)
Definition MixinVector:146
osg::MixinVector::MixinVector
MixinVector(const MixinVector &other)
Definition MixinVector:65
osg::MixinVector::rbegin
const_reverse_iterator rbegin() const
Definition MixinVector:102
osg::MixinVector::capacity
size_type capacity() const
Definition MixinVector:93
osg::MixinVector::swap
void swap(vector_type &other)
Definition MixinVector:88
osg::MixinVector::reference
vector_type::reference reference
Definition MixinVector:37
osg::MixinVector::get_allocator
allocator_type get_allocator() const
Definition MixinVector:95
osg::MixinVector::operator>
friend bool operator>(const std::vector< ValueT > &left, const MixinVector< ValueT > &right)
Definition MixinVector:158
osg::MixinVector::insert
iterator insert(iterator where, const value_type &value)
Definition MixinVector:123
osg::MixinVector::iterator
vector_type::iterator iterator
Definition MixinVector:39
osg::MixinVector::operator==
friend bool operator==(const MixinVector< ValueT > &left, const std::vector< ValueT > &right)
Definition MixinVector:145
osg::MixinVector::~MixinVector
virtual ~MixinVector()
Definition MixinVector:82
osg::MixinVector::empty
bool empty() const
Definition MixinVector:91
osg::MixinVector::insert
void insert(iterator where, size_type count, const value_type &value)
Definition MixinVector:131
osg::MixinVector::const_iterator
vector_type::const_iterator const_iterator
Definition MixinVector:38
osg::MixinVector::erase
iterator erase(iterator first, iterator last)
Definition MixinVector:121
osg::MixinVector::allocator_type
vector_type::allocator_type allocator_type
Definition MixinVector:32
osg::MixinVector::operator!=
friend bool operator!=(const MixinVector< ValueT > &left, const std::vector< ValueT > &right)
Definition MixinVector:149
osg::MixinVector::operator<=
friend bool operator<=(const MixinVector< ValueT > &left, const std::vector< ValueT > &right)
Definition MixinVector:161
osg
Definition AlphaFunc:19
osg::swap
void swap(MixinVector< ValueT > &left, MixinVector< ValueT > &right)
Definition MixinVector:174