2008-03-08 13:52:38 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
// Name: vector.h
|
2008-03-10 15:24:38 +00:00
|
|
|
// Purpose: interface of wxVector<T>
|
2008-03-08 13:52:38 +00:00
|
|
|
// Author: wxWidgets team
|
|
|
|
// RCS-ID: $Id$
|
|
|
|
// Licence: wxWindows license
|
|
|
|
/////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
/**
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-21 14:51:28 +00:00
|
|
|
wxVector<T> is a template class which implements most of the @c std::vector
|
|
|
|
class and can be used like it.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-04-28 08:26:04 +00:00
|
|
|
If wxWidgets is compiled in STL mode, wxVector will just be a typedef to
|
|
|
|
@c std::vector. Just like for @c std::vector, objects stored in wxVector<T>
|
|
|
|
need to be @e assignable but don't have to be @e "default constructible".
|
2008-03-21 14:51:28 +00:00
|
|
|
|
|
|
|
Please refer to the STL documentation for further information.
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-03-22 16:07:29 +00:00
|
|
|
@nolibrary
|
2008-03-21 14:51:28 +00:00
|
|
|
@category{containers}
|
2008-03-08 14:43:31 +00:00
|
|
|
|
2008-04-28 08:26:04 +00:00
|
|
|
@see @ref overview_container, wxList<T>, wxArray<T>
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-21 14:51:28 +00:00
|
|
|
template<typename T>
|
2008-03-08 14:43:31 +00:00
|
|
|
class wxVector<T>
|
2008-03-08 13:52:38 +00:00
|
|
|
{
|
|
|
|
public:
|
2008-03-21 14:51:28 +00:00
|
|
|
typedef size_t size_type;
|
|
|
|
typedef T value_type;
|
|
|
|
typedef value_type* iterator;
|
|
|
|
typedef const value_type* const_iterator;
|
|
|
|
typedef value_type& reference;
|
|
|
|
|
2008-03-08 13:52:38 +00:00
|
|
|
/**
|
|
|
|
Constructor.
|
|
|
|
*/
|
2008-03-21 14:51:28 +00:00
|
|
|
wxVector();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Copy onstructor.
|
|
|
|
*/
|
|
|
|
wxVector(const wxVector<T>& c);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Destructor.
|
|
|
|
*/
|
2008-03-21 14:51:28 +00:00
|
|
|
~wxVector();
|
|
|
|
|
|
|
|
/**
|
2008-04-28 08:26:04 +00:00
|
|
|
Returns item at position @a idx.
|
2008-03-21 14:51:28 +00:00
|
|
|
*/
|
|
|
|
const value_type& at(size_type idx) const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2008-04-28 08:26:04 +00:00
|
|
|
Returns item at position @a idx.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-21 14:51:28 +00:00
|
|
|
value_type& at(size_type idx);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2008-03-21 14:51:28 +00:00
|
|
|
Return the last item.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-21 14:51:28 +00:00
|
|
|
const value_type& back() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Return the last item.
|
|
|
|
*/
|
|
|
|
value_type& back();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Return iterator to beginning of the vector.
|
|
|
|
*/
|
|
|
|
const_iterator begin() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Return iterator to beginning of the vector.
|
|
|
|
*/
|
2008-03-21 14:51:28 +00:00
|
|
|
iterator begin();
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2008-03-21 14:51:28 +00:00
|
|
|
Returns vector's current capacity, i.e. how much memory is allocated.
|
2008-03-20 13:45:17 +00:00
|
|
|
|
2008-03-21 14:51:28 +00:00
|
|
|
@see reserve()
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
size_type capacity() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Clears the vector.
|
|
|
|
*/
|
|
|
|
void clear();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns @true if the vector is empty.
|
|
|
|
*/
|
2008-03-09 16:24:26 +00:00
|
|
|
bool empty() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns iterator to the end of the vector.
|
|
|
|
*/
|
2008-03-21 14:51:28 +00:00
|
|
|
const_iterator end() const;
|
|
|
|
|
|
|
|
/**
|
|
|
|
Returns iterator to the end of the vector.
|
|
|
|
*/
|
|
|
|
iterator end();
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2008-03-21 14:51:28 +00:00
|
|
|
Erase item pointed to by iterator @a it.
|
|
|
|
|
|
|
|
@return Iterator pointing to the item immediately after the erased one.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
iterator erase(iterator it);
|
2008-03-21 14:51:28 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Erase items in the range @a first to @a last (@a last is not erased).
|
|
|
|
|
2008-04-28 08:26:04 +00:00
|
|
|
@return Iterator pointing to the item immediately after the erased
|
|
|
|
range.
|
2008-03-21 14:51:28 +00:00
|
|
|
*/
|
2008-03-08 14:43:31 +00:00
|
|
|
iterator erase(iterator first, iterator last);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2008-03-21 14:51:28 +00:00
|
|
|
Returns the first item.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-21 14:51:28 +00:00
|
|
|
const value_type& front() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2008-03-21 14:51:28 +00:00
|
|
|
Returns the first item.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-21 14:51:28 +00:00
|
|
|
value_type& front();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Insert item @a v at given position @a it.
|
|
|
|
|
|
|
|
@return Iterator for the inserted item.
|
|
|
|
*/
|
|
|
|
iterator insert(iterator it, const value_type& v = value_type());
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Assignment operator.
|
|
|
|
*/
|
2008-04-28 08:26:04 +00:00
|
|
|
wxVector& operator=(const wxVector& vb);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
2008-04-28 08:26:04 +00:00
|
|
|
Returns item at position @a idx.
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
2008-03-21 14:51:28 +00:00
|
|
|
const value_type& operator[](size_type idx) const;
|
|
|
|
|
|
|
|
/**
|
2008-04-28 08:26:04 +00:00
|
|
|
Returns item at position @a idx.
|
2008-03-21 14:51:28 +00:00
|
|
|
*/
|
|
|
|
value_type& operator[](size_type idx);
|
2008-03-08 13:52:38 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Removes the last item.
|
|
|
|
*/
|
|
|
|
void pop_back();
|
|
|
|
|
|
|
|
/**
|
|
|
|
Adds an item to the end of the vector.
|
|
|
|
*/
|
|
|
|
void push_back(const value_type& v);
|
|
|
|
|
|
|
|
/**
|
2008-03-21 14:51:28 +00:00
|
|
|
Reserves memory for at least @a n items.
|
|
|
|
|
|
|
|
@see capacity()
|
2008-03-08 13:52:38 +00:00
|
|
|
*/
|
|
|
|
void reserve(size_type n);
|
2008-04-28 08:26:04 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
Returns the size of the vector.
|
|
|
|
*/
|
|
|
|
size_type size() const;
|
2008-03-08 13:52:38 +00:00
|
|
|
};
|
2008-03-10 15:24:38 +00:00
|
|
|
|