]>
git.saurik.com Git - wxWidgets.git/blob - src/stc/scintilla/src/Array.h
e556912f6037672148eb21cb7fbcce2a823327e9
2 * This file is defining a kind of tool for simulating std::vector
3 * for using wx on OS which are not supporting the STL
4 * @author foldink (foldink@gmail.com)
5 * @date 26-February-2010
15 //struct SelectionRange;
18 * @class ArrayIterator
19 * @brief This class is used to simulate an iterator in the array
20 * @author foldink (foldink@gmail.com)
21 * @date 26-February-2010
29 * @param parent, parented array to store positions in
31 ArrayIterator( Array
* parent
, size_t idx
):
36 virtual ~ArrayIterator()
42 ArrayIterator(const ArrayIterator
& rhs
):
43 m_parent(rhs
.m_parent
),
46 /***********************************************************************
48 **********************************************************************/
49 /** the equal operator is used to overload copy for the array */
50 ArrayIterator
& operator=(const ArrayIterator
& rhs
)
52 m_parent
= rhs
.m_parent
;
58 /** Smart pointer part overload as it is in standard templates arrays */
59 SelectionRange
& operator*();
62 ArrayIterator
operator++(int);
65 ArrayIterator
& operator++();
68 ArrayIterator
operator--(int);
71 ArrayIterator
& operator--();
73 /** a + int operator */
74 ArrayIterator
operator+(size_t idx
);
76 /** a - int operator */
77 ArrayIterator
operator-(size_t idx
);
79 /** a += int operator */
80 ArrayIterator
& operator+=(size_t idx
);
82 /** a -= int operator */
83 ArrayIterator
& operator-=(size_t idx
);
86 bool operator!=(const ArrayIterator
& rhs
);
89 bool operator==(const ArrayIterator
& rhs
);
91 /** Set the idx if needed */
92 void SetIdx(size_t idx
) {m_idx
= idx
;};
93 /** Get the idx if needed */
94 size_t GetIdx() {return m_idx
;};
102 * @brief simple array of SelectionRange
103 * @brief This class is used to simulate an iterator in the array
104 * @author foldink (foldink@gmail.com)
105 * @date 26-February-2010
109 friend class ArrayIterator
;
112 /** default ctor taking the len in input */
113 Array( size_t len
= 0 );
115 /** ctor with len and initial value */
116 Array( size_t len
, const SelectionRange
& val
);
119 Array( const Array
& rhs
);
125 Array
& operator=( const Array
& rhs
);
128 SelectionRange
& operator[]( size_t idx
)
131 throw "Error access to vector range out of bounds";
133 return *(m_data
+ idx
);
137 const SelectionRange
& operator[]( size_t idx
) const
140 throw "Error access to vector range out of bounds";
142 return *(m_data
+ idx
);
146 size_t size() const {return m_size
;};
148 /** check if the array is empty or not */
149 bool empty() const {return (m_size
== 0);};
152 void reserve( size_t len
);
155 SelectionRange
& front() {
157 throw "Trying to access to an uninitialized array";
163 SelectionRange
& back() {
165 throw "Trying to access to an uninitialized array";
167 return *(m_data
+ m_size
-1);
171 void push_back( const SelectionRange
& val
);
176 /** insert before the given iterator position */
177 void insert( ArrayIterator it
, SelectionRange
& val
);
180 void erase( ArrayIterator it
);
186 void resize( size_t n
, SelectionRange val
= SelectionRange() );
189 bool operator==(const Array
& rhs
);
192 ArrayIterator
begin();
198 SelectionRange
* m_data
;
203 * @brief Sorting method for a replace in Editor.cxx
204 * @author foldink (foldink@gmail.com)
205 * @date 26-February-2010
207 extern void ArraySort( ArrayIterator start
, ArrayIterator finish
);