1 // TortoiseSVN - a Windows shell extension for easy version control
\r
3 // Copyright (C) 2003-2006 - Stefan Kueng
\r
5 // This program is free software; you can redistribute it and/or
\r
6 // modify it under the terms of the GNU General Public License
\r
7 // as published by the Free Software Foundation; either version 2
\r
8 // of the License, or (at your option) any later version.
\r
10 // This program is distributed in the hope that it will be useful,
\r
11 // but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
12 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
13 // GNU General Public License for more details.
\r
15 // You should have received a copy of the GNU General Public License
\r
16 // along with this program; if not, write to the Free Software Foundation,
\r
17 // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
\r
26 * Subclass of the STL's vector class that allows the class to be used more
\r
27 * freely in place of a C-style array.
\r
28 * @author Damian Powell
\r
30 template <class T, class Al = std::allocator<T> >
\r
31 class vector : public std::vector<T, Al> {
\r
36 * Default constructor creates an empty vector.
\r
42 * Creates a vector of n items where each item is initialized to its
\r
43 * default value as defined by 'T()'
\r
44 * @param n The number of items to allocate in the new vector.
\r
46 inline vector(size_type n)
\r
47 : std::vector<T, Al> (n)
\r
51 * Creates a vector of n items where each item is initialized to the
\r
52 * specified value t.
\r
53 * @param n The number of items to allocate in the new vector.
\r
54 * @param t The value that each new item shall be initialized to.
\r
56 inline vector(size_type n, const T& t)
\r
57 : std::vector<T, Al> (n, t)
\r
61 * Index operator returns reference to the specified immutable item.
\r
62 * No additional bounds checking is performed.
\r
63 * @param i The index of the value to return a reference to.
\r
64 * @return An immutable reference to the item at index i.
\r
66 inline const_reference operator [] (size_type i) const {
\r
68 return std::vector<T, Al>::operator [] (i);
\r
72 * Index operator returns a reference to the specified item. No
\r
73 * additional bounds checking is performed.
\r
74 * @param i The index of the value to return a reference to.
\r
75 * @return A reference to the item at index i.
\r
77 inline reference operator [] (size_type i) {
\r
79 return std::vector<T, Al>::operator [] (i);
\r
83 * Conversion operator returns pointer to the immutable item at the
\r
84 * beginning of this array of NULL if the array is empty.
\r
85 * @param i The index of the value to return a reference to.
\r
86 * @return A pointer to an immutable item or NULL.
\r
88 inline operator const_pointer () const {
\r
89 return empty() ? NULL : &operator[](0);
\r
93 * Conversion operator returns pointer to the item at the beginning of
\r
94 * this array of NULL if the array is empty.
\r
95 * @param i The index of the value to return a reference to.
\r
96 * @return A pointer to an item or NULL.
\r
98 inline operator pointer () {
\r
99 return empty() ? NULL : &operator[](0);
\r