]>
git.saurik.com Git - wxWidgets.git/blob - contrib/src/stc/scintilla/src/SVector.h
d4d49c717d6f30f876513281f2f7d1480a690888
1 // Scintilla source code edit control
2 // SVector.h - a simple expandable vector
3 // Copyright 1998-1999 by Neil Hodgson <neilh@hare.net.au>
4 // The License.txt file describes the conditions under which this software may be distributed.
9 // A simple expandable integer vector.
10 // Storage not allocated for elements until an element is used.
11 // This makes it very lightweight unless used so is a good match for optional features.
15 unsigned int size
; // Number of elements allocated
16 unsigned int len
; // Number of elements in vector
17 bool allocFailure
; // A memory allocation call has failed
19 // Internally allocate more elements than the user wants to avoid
20 // thrashng the memory allocator
21 void SizeTo(int newSize
) {
25 newSize
= (newSize
* 3) / 2;
26 int* newv
= new int[newSize
];
53 SVector(const SVector
&other
) {
58 if (other
.Length() > 0) {
59 SizeTo(other
.Length());
61 for (int i
=0;i
<other
.Length();i
++)
67 SVector
&operator=(const SVector
&other
) {
74 if (other
.Length() > 0) {
75 SizeTo(other
.Length());
77 for (int i
=0;i
<other
.Length();i
++)
85 int &operator[](unsigned int i
) {
100 void SetLength(unsigned int newLength
) {
101 if (newLength
> len
) {
102 if (newLength
>= size
) {