//接上面
" P/ n9 R9 @$ p6 U% I' u0 Itemplate<class TYPE, class ARG_TYPE>+ d( D, O3 Z9 C4 [$ X8 C
YCArray<TYPE, ARG_TYPE>::~YCArray()& I* N% a/ u' K/ K
{1 {1 Z* |) z; x/ O9 C
ASSERT_VALID(this); if (Ym_pData != NULL)9 \9 R! M; e7 o# a6 e
{
# J. W: k( L. L. e: |4 }2 b+ J DestructAllElement(0,m_nSize);. |- I1 Z6 P5 {1 j; l5 F! k( k
//DestructElements<TYPE>(Ym_pData, m_nSize);7 Y o2 G2 z$ {9 S
delete[] (BYTE*)Ym_pData;! P0 G" i7 Z" h0 |4 Y" F5 i0 l& I3 q# E
}5 f( U) ]9 |$ Y
}6 y u3 w S" M `) X
template<class TYPE, class ARG_TYPE>9 j- H: m' S( C6 C3 X
CString YCArray<TYPE, ARG_TYPE>::GetSign()! n( i( Q1 g. Y0 I& P& C
{7 o) X& d- ?4 c6 @
lock_sign=0;
# W9 e+ T, b/ g5 | return Sign;3 r; J2 G4 H# o5 y
}
" h- m7 b: ]& [& f' otemplate<class TYPE, class ARG_TYPE>
, M& d0 _% Z, q" D: [int YCArray<TYPE, ARG_TYPE>::SetSign(CString& sign)
$ ?/ Z8 R: K+ T5 ?! C{: ?0 u5 f; `1 F6 W3 c. w9 l
int i=0;
* [% @+ n; W2 F' d- d# L8 c! n while(lock_sign&&i<MAXSIGNTIME){7 v( n0 {7 r2 M3 O" F) ]
Sleep(1);
2 q/ w6 ~0 e. U. P9 ^& a i++;
2 u# Y- n* s6 G& }3 u }
4 U: d7 K- Z+ s; Q lock_sign=1;
5 x7 C( d) Y; }) B" v Sign=sign;
6 S# V. A0 u; }, U$ o return TRUE;
$ E! j7 f8 I0 H$ ?' p" u. Y2 s}& l! p+ x" O% M% P
//用与把 nindex 后的索引往后推 nCount ,自动调整好buffer
. _ z% @8 k7 }" C) w8 ?template<class TYPE, class ARG_TYPE>
& W9 q/ {( K$ ^ m" {" lBOOL YCArray<TYPE, ARG_TYPE>::SetIndexSize(int nNewSize)# w3 z( r) q* u* G
{
; Q- {6 | G/ D8 P* }. I; a) ^# i if(strIndexNum < nNewSize){* h1 e* P% Y/ p' f
CString* tp = new CString[nNewSize];//新的buffer) ?4 @% ~: E' U" r
for(int i=0;i<strIndexNum;i++){//把老索引复制过来( e! ]! w) U7 Y4 W0 a5 T
tp = strIndex;
2 @6 ^; Q" R7 t1 A1 k9 N4 \ }& B% g# h! p z$ J) H- q- K& l
for(i=strIndexNum;i<nNewSize;i++){7 {# j) ~8 F: U2 ?" ?$ ^. v
tp = "" ;4 D5 K# T& {( Y1 l" q; B
}
0 [; Q& P8 Z" S delete[] strIndex ;1 l) z+ D/ y) P- B
strIndex = tp ;
9 V1 U# ? Q4 E0 G( C X/ E strIndexNum = nNewSize ;
9 s" T5 T$ Z7 O4 w! g8 e) A }else if(strIndexNum < nNewSize){9 w4 v, h7 S/ s. ~
for(int i=nNewSize;i<strIndexNum;i++){! h0 s. j4 K: X( A
strIndex = "" ;! y9 w* t3 X$ q0 J, h2 {
}/ F6 L1 A* J4 z" z2 `' z5 Q
} z! b( y+ r% ~: @' b4 j
return TRUE;4 O& @8 q8 m( q
}
3 P" g( b v3 n3 [% u, Ctemplate<class TYPE, class ARG_TYPE>
: D' K/ @- V! A& R3 m5 @, x& W t qBOOL YCArray<TYPE, ARG_TYPE>::INSERTIndex(int nIndex,int nCount /*=1*/)% z: ~7 U/ ?. a0 m
{
) W: X+ Y% f: R$ n n, e& d CString* tp = new CString[m_nSize+nCount];//新的buffer! v7 e9 v2 c: ]$ a
for(int i=0;i<nIndex;i++){//把老索引复制过来
8 B0 C9 W) a5 \7 b tp = strIndex;
# f$ F& y5 t2 ~4 g" { }int j =0 ;
8 p5 J" R6 }* j' ^3 z1 f4 v# p) ` for(i=nIndex+nCount;i<m_nSize;i++){//把老索引复制过来
: m' J( b' `; B. c. r3 J tp = strIndex[nIndex+j];
0 @" r! s/ l( h1 e" j" D j++;! M3 ^+ F* a" o- n6 e) v T
}) N5 s& j# L7 ~. j2 X1 \5 t4 @4 e% H% r
delete[] strIndex ;+ H, Q* X' c. X' O
strIndex = tp ;% p* M0 N4 d0 z6 e/ u" R
return TRUE;
( T. h6 R' p7 h9 Q}3 L4 o8 J4 ^0 o! @2 E
template<class TYPE, class ARG_TYPE>& ^. C" p( n" S% M$ P4 y
BOOL YCArray<TYPE, ARG_TYPE>::SETIndex(CString cIndex,int nIndex), K- g' [0 E& H' O1 i8 @
{//在 nIndex 后面添加一个 字符串索引+ m; i7 \1 H e: k4 w
strIndex[nIndex] = cIndex ;1 i, Y, S( @% [; W& v* c) w5 w
return TRUE;9 f& s" K$ k0 o" a- }7 G, Q
}$ U/ o7 ] U2 M3 z. [ A
template<class TYPE, class ARG_TYPE>
& c. m% K8 R: V2 }9 @BOOL YCArray<TYPE, ARG_TYPE>:ELIndex(int nIndex,int nCount /*=1*/)) g+ X. C+ ?' s% E7 h
{//需要在 m_nSize 变化之前调用!!5 J8 r% w- F7 @' C2 u' N- s' V
ASSERT(nIndex >= 0);
, i! O; O# B/ V" H- y3 T9 o ASSERT(nCount >= 0);
: ?9 h. z: R$ w* d ASSERT(nIndex + nCount <= m_nSize);0 a/ `9 x: b8 ^* H+ M7 N8 Q
int j =0 ;
1 {9 F5 A+ I; Q9 M for(int i=nIndex+nCount;i<m_nSize;i++){//把老索引复制过来
- y- P! i6 I; l0 I; S% L strIndex[nIndex+j] = strIndex;
) k& S9 W& D! m0 N- C j++;
. x% l2 N; T' b+ A7 q }
2 ?' l3 i( f* L; u: x return TRUE;
! c) e I& Z, J/ d9 {}
6 l2 I7 s+ Y) Y5 X x. W9 [template<class TYPE, class ARG_TYPE>
' B( ^ C7 ~( S, d: IBOOL YCArray<TYPE, ARG_TYPE>:ELIndex(CString cIndex,int nCount /*=1*/); [5 I9 l5 Q3 ]
{
4 e' m) N v6 e int nIndex=this->GetIndex(cIndex);
1 U% S+ ~) q& }" Q return this->DELIndex(nIndex,nCount);
+ a1 k! `7 o0 E, G& R# U}
1 ]- A3 @7 y! v/ j# {template<class TYPE, class ARG_TYPE>/ ~6 q1 |- L# \7 J" Y! A
int YCArray<TYPE, ARG_TYPE>::GetIndex(CString cIndex)
) ?# N% c! { ]- H0 U5 B1 u% c{//得到 cIndex 的数字索引) H! N' A5 a" n& G. F) ]
int nPos = -1;9 P' r$ L- A' A8 j
for(int i=0;i<m_nSize;i++){
" h, R5 b8 O- O8 s `* d1 _( w# _/ l if(strIndex == cIndex){# ]% ?9 ~2 f, h" L+ J V& Z
nPos = i ;break;
8 f" @8 L7 U3 ~# R, \: A } ]# L1 I# {- r' X- p
}
- ]: b k9 W7 U* Q( z- v& q return nPos;
) P. s9 U& B# t: X}. c1 U- Y$ [# L0 F5 S
template<class TYPE, class ARG_TYPE>
# a ^# Z" O5 V- sCString YCArray<TYPE, ARG_TYPE>::GetIndex(int nIndex)
' a1 s* W4 A* c( ?{//返回 nIndex 的字符串索引4 z( _. T5 P$ t0 K
return strIndex[nIndex];
, I- T6 \. {* P, r}, d/ `1 l% ~9 I
/////////////////////////////////////////////////////////////////////////////
% `/ i& j, {: E4 W8 n/ e" z// YCArray<TYPE, ARG_TYPE> inline functions template<class TYPE, class ARG_TYPE>
" C; S5 ~4 N4 `2 V c- q( [AFX_INLINE int YCArray<TYPE, ARG_TYPE>::GetSize() const
* {7 r+ _+ Y; w7 I) l$ l' z { return m_nSize; }* F5 q* [5 R, a! r8 f) A
template<class TYPE, class ARG_TYPE>
# j4 v# A! C/ O6 u0 B5 oAFX_INLINE int YCArray<TYPE, ARG_TYPE>::GetUpperBound() const
) a- c$ r1 k: O5 U1 q5 `& @2 m( y { return m_nSize-1; }3 T' B1 l) I$ _- m$ @9 ~% D
template<class TYPE, class ARG_TYPE>
7 {" @2 O; C$ EAFX_INLINE void YCArray<TYPE, ARG_TYPE>::RemoveAll()
/ V/ E2 F0 A& e5 B { SetSize(0, -1); }4 g) Y& X+ A, {# w
template<class TYPE, class ARG_TYPE>9 n7 e, \: }$ z" y8 A
AFX_INLINE TYPE YCArray<TYPE, ARG_TYPE>::GetAt(int nIndex) const7 q% d6 S) h3 i6 U. z
{ ASSERT(nIndex >= 0 && nIndex < m_nSize);4 I( F. }" |1 r4 i5 A0 }& q
return *Ym_pData[nIndex]; }! f a' M( P, v) ^8 i
template<class TYPE, class ARG_TYPE>
0 `0 i: x" ^5 g- F% Y8 TAFX_INLINE void YCArray<TYPE, ARG_TYPE>::SetAt(int nIndex, ARG_TYPE newElement)
: D$ { T, p9 B0 i/ S9 X( q. }# [ { ASSERT(nIndex >= 0 && nIndex < m_nSize);
+ K% b- _# o- L8 H; A *(Ym_pData[nIndex]) = newElement; } template<class TYPE, class ARG_TYPE>
: K4 X$ V$ y$ gAFX_INLINE TYPE& YCArray<TYPE, ARG_TYPE>::ElementAt(int nIndex)' B2 j2 g) V1 r5 @
{ ASSERT(nIndex >= 0 && nIndex < m_nSize);
2 x* P- H6 h8 P( k# b return *Ym_pData[nIndex]; } template<class TYPE, class ARG_TYPE>
; J4 V2 z$ F$ QTYPE YCArray<TYPE, ARG_TYPE>::GetAt(CString cIndex) const
: t) z9 B( | M; p; I( d{! z% r% }( w. J) c2 f
int nIndex=GetIndex(cIndex);9 W2 C8 N* \ m v+ p8 S7 ]* i- P2 K
return GetAt(nIndex);
9 i" O9 E# l2 m4 o}
7 ]8 V. a" h& \! wtemplate<class TYPE, class ARG_TYPE>, j! {& T7 w7 ^
void YCArray<TYPE, ARG_TYPE>::SetAt(CString cIndex, ARG_TYPE newElement)* _7 m. M' m5 [1 P6 W1 n. k
{
0 U- D/ p, i! |& {7 |/ Q3 X( Y int nIndex=GetIndex(cIndex);$ W2 `) s/ [: w: z, w- O
return SetAt(nIndex, newElement);& p/ |, y3 r0 D2 a6 ~ | @: S
}
2 f: p" g9 u+ m5 a4 xtemplate<class TYPE, class ARG_TYPE>
5 `$ U- r6 C) I& z- b8 S" o9 T( vTYPE& YCArray<TYPE, ARG_TYPE>::ElementAt(CString cIndex). }, b. S0 N5 I; i7 o0 M2 m! u
{
' `/ x2 w b8 c% ?. ~- _& N int nIndex=GetIndex(cIndex);
4 }$ [' Z& t: j2 k/ U4 b) w return ElementAt(nIndex);5 \; _) y: p; k0 m+ X
}8 p2 `$ n" M% x& s3 [4 x
template<class TYPE, class ARG_TYPE>) q8 [7 J" M7 Q% N2 ]# X
AFX_INLINE const TYPE** YCArray<TYPE, ARG_TYPE>::GetData() const: ?5 f+ q0 s: ~ |; W! `( ~
{ return (const TYPE**)Ym_pData; } b3 a5 O$ L/ i+ r' E( o& v3 X
template<class TYPE, class ARG_TYPE>/ Z4 d! q7 F' i% W$ E
AFX_INLINE TYPE** YCArray<TYPE, ARG_TYPE>::GetData()/ K" Q5 U/ [9 s- {. w7 r, [8 x
{ return (TYPE**)Ym_pData; }% P- l: D7 c) h1 K6 z; W2 ^; k
template<class TYPE, class ARG_TYPE>
, ?' A7 T1 v/ o& g$ ]' j& WAFX_INLINE int YCArray<TYPE, ARG_TYPE>::Add(ARG_TYPE newElement,CString cIndex /* ="" */)
1 _ s6 i: t5 Y. w { int nIndex = m_nSize;5 d5 a( V- r6 ^
SetAtGrow(nIndex, newElement);' \, [' r! p R) S! H
SETIndex(cIndex,nIndex);
# p5 D3 U% p6 V \$ |+ p return nIndex; }- [! M0 ?* X; ?$ g
template<class TYPE, class ARG_TYPE>& b) m. m8 t1 A& ~2 ~- B
AFX_INLINE TYPE YCArray<TYPE, ARG_TYPE>:perator[](int nIndex) const
; p* b" A& j+ J4 y { return GetAt(nIndex); }% T9 R+ h5 W( i% A5 b* y) }" B
template<class TYPE, class ARG_TYPE>
! h2 C" V K/ i2 D* u* {AFX_INLINE TYPE& YCArray<TYPE, ARG_TYPE>:perator[](int nIndex)
N. X7 J( t! k/ H6 R- X { return ElementAt(nIndex); }9 A" f/ C& j l( j
template<class TYPE, class ARG_TYPE>
$ l9 L3 O% k( k# j, {9 `AFX_INLINE TYPE YCArray<TYPE, ARG_TYPE>:perator[](CString cIndex) const
" I9 ^5 m& C$ N. a' D4 u* A4 @{
; D) C# K o4 R6 C int nIndex=GetIndex(cIndex); return operator[](nIndex);
- Z$ [! r8 P/ r2 Y0 X}
$ a3 g0 a$ f. r* d5 k" y# C/ wtemplate<class TYPE, class ARG_TYPE> X4 L( z& q/ J" Z: j; T
AFX_INLINE TYPE& YCArray<TYPE, ARG_TYPE>:perator[](CString cIndex)
: A: b5 B) g2 _3 @{
: [" u: k- q* Z/ ^ int nIndex=GetIndex(cIndex);+ c4 x& K v' r) A/ ]1 Q! V
return operator[](nIndex);
: V& R" A' Q/ b" i5 H}
( g. {# A { K+ [. _/*% J: }7 H) T1 W& B+ ^0 J
template<class TYPE, class ARG_TYPE>
# f& u2 p& O( Z; D: I; tAFX_INLINE YCArray<TYPE,ARG_TYPE> YCArray<TYPE, ARG_TYPE>:perator=(YCArray<TYPE,ARG_TYPE>& tparr) const
. X, R7 c6 q2 P{
: `6 Y" O" B& z int i,j;1 w5 Y# ^$ D% m6 A
for(i=0;i<tparr.GetSize();i++){
, n2 t) h) F( o1 c7 D. o j = GetIndex(tparr.GetIndex(i));
6 _' v4 i# H# q) F- |2 s' a2 ? if(j>-1){
; P* }: f9 Z2 I7 p: { operator[](tparr.GetIndex(i)) = tparr;0 U( a/ b/ e/ N" |, m) p: c
}else{$ w' e! R; b! {7 V4 r0 E
Add(tparr,tparr.GetIndex(i));8 j! L$ m# [3 k: O/ z, v1 J
}
6 h U X8 ^; a& k& M& Y: \ }; I* V( T1 v5 O' c' X* I
return this;; y1 A0 e' o8 ? j) v4 {$ { q" J
}
$ a t( w) J! h4 \+ w( ]4 M( ~*/
1 e; L' v' j# [2 y- P& ]/ T0 R/ Ltemplate<class TYPE, class ARG_TYPE>
) a% k6 g) O+ X* N/ A( ZAFX_INLINE YCArray<TYPE,ARG_TYPE>& YCArray<TYPE, ARG_TYPE>:perator=(YCArray<TYPE,ARG_TYPE>& src)( u [" v/ |5 h& _6 w7 F8 @6 d
{
( y5 e: M' m& y* O/ c ASSERT_VALID(this);, ^& I |/ W, g* ]. i9 g
ASSERT(this != &src); // cannot append to itself SetSize(src.m_nSize);- t) f1 N: I1 _( r
for(int i=0;i<m_nSize;i++){
1 l4 [8 z7 |9 V; { /*将此句修改为内存拷贝*///
+ e! c( E- |! }' Z1 \* @6 _ *Ym_pData = *src.Ym_pData ;4 P& O5 |, ~7 x& N* p6 ~
//memcpy(Ym_pData,src.Ym_pData,sizeof(TYPE));: T' z* @# b( N- s: v/ s
SETIndex(src.GetIndex(i),i);
1 o# {* U7 ^4 t$ x5 b$ Q }/ B6 F& H" j2 E/ e. T
return *this;' t# r' l! B! s! }3 w) E
}1 ^: |& |) ?* g* q+ C
/////////////////////////////////////////////////////////////////////////////
% c4 B9 ~" b9 I// YCArray<TYPE, ARG_TYPE> out-of-line functions template<class TYPE, class ARG_TYPE>
h- O& S7 U% o5 I3 mYCArray<TYPE, ARG_TYPE>::YCArray()9 Y( N5 v9 L; p( c
{% s! v) B, i) N7 l/ C. H
Ym_pData = NULL;
7 p; ~. x0 P& E strIndexNum = m_nSize = m_nMaxSize = m_nGrowBy = 0;
( r. z5 E9 G `4 M" V) R1 ] strIndex=NULL;MAXSIGNTIME=10;
$ @8 f1 m- f, Y! D}6 _$ M5 x$ G, ]) r
template<class TYPE, class ARG_TYPE>
9 g8 k4 Y: i; V7 B! I) k/ N, q% dYCArray<TYPE, ARG_TYPE>::YCArray(YCArray<TYPE, ARG_TYPE>& tp)/ k+ s, `7 l8 b/ ?: \0 s& y
{
( N! k% z6 J+ `- R. S" G+ y" R Ym_pData = NULL;9 @2 m; i( R& F' [
strIndexNum = m_nSize = m_nMaxSize = m_nGrowBy = 0;5 J8 ^' l* ~: V9 ?1 i; V0 {
strIndex=NULL;MAXSIGNTIME=10;; @* {+ Z, I9 l# O* n. ^# ]7 u
operator=(tp);( E7 T9 [! t( C
} template<class TYPE, class ARG_TYPE>
" G7 i/ t7 Q# a5 r) Ivoid YCArray<TYPE, ARG_TYPE>::SetSize(int nNewSize, int nGrowBy)6 b, h( v! S' h- `
{
; P5 T% f2 ~+ J( i3 ? ASSERT_VALID(this);* A3 _) m/ s/ E4 }4 l. l
ASSERT(nNewSize >= 0); if (nGrowBy != -1)7 U( z' Q: i' {( H$ s
m_nGrowBy = nGrowBy; // set new size if (nNewSize == 0){
0 t1 `/ r% b0 w9 m // shrink to nothing
. i0 ^) ]! m, |$ m0 d0 M0 u if (Ym_pData != NULL){- S( ~* n1 U% j" ` N$ x
DestructAllElement(0,m_nSize);% X" R, o+ A3 @; [7 \
//DestructElements<TYPE>(Ym_pData, m_nSize);
( R' q3 i3 }+ n2 E delete[] (BYTE*)Ym_pData;, z- {0 n( M( V
Ym_pData = NULL;" P5 t& y) N) t! c' V9 m' \* O
}9 e9 p, t3 S, \$ R- t* j" H2 r
m_nSize = m_nMaxSize = 0;
' w6 [$ t( S5 k' f; G; {1 O. ` } else if (Ym_pData == NULL){ s9 o9 f ~8 \
// create one with exact size3 V7 J2 i+ @8 i9 q. i' b1 z
#ifdef SIZE_T_MAX
8 I) u- u. h' |% u ASSERT(nNewSize <= SIZE_T_MAX/sizeof(TYPE*)); // no overflow
4 M' Q; d) t2 ?: ^#endif
' F! e) K/ i7 a Ym_pData = (TYPE**) new BYTE[nNewSize * sizeof(TYPE*)];2 {( r" N5 }6 N. u
ConstructAllElements(0,nNewSize);//ConstructElements<TYPE>(Ym_pData, nNewSize);9 R4 j1 C8 I6 [' f
m_nSize = m_nMaxSize = nNewSize;9 [( i( x9 E. W, x+ J0 j" S
} else if (nNewSize <= m_nMaxSize){ d6 w! p8 A8 d( L6 l$ Q: W% i
// it fits
* C# H& z5 z* f if (nNewSize > m_nSize)+ r9 [' w, f! n5 x e
{% f1 M5 Y) i' x1 a/ ]% Q8 f, w
// initialize the new elements7 j9 ^' P! q4 T" q( A2 b
ConstructAllElements(m_nSize,nNewSize-m_nSize);//ConstructElements<TYPE>(&Ym_pData[m_nSize], nNewSize-m_nSize);
+ B& c5 B1 t* B, v, [: c, p }* ~2 b8 c- V# B. R1 ?9 v
else if (m_nSize > nNewSize)/ Q5 p9 S: G& r! v' L# _
{6 _* D- @7 t. `. k: [2 Q
// destroy the old elements) a% S$ D% v+ t# f/ h
DestructAllElement(nNewSize,m_nSize-nNewSize);% w* R6 b: b& p, F" j
//DestructElements<TYPE>(&Ym_pData[nNewSize], m_nSize-nNewSize);
! c! D/ g5 B+ ?- T! w }9 q! F9 x$ b3 g
m_nSize = nNewSize;+ N' E) A/ F2 U
}6 U) R* R* F% R j1 ^! q
else
' m8 V8 a) A4 f: P8 ~ {% a% d4 l& }; l+ v9 X$ i
// otherwise, grow array, h& Y; Q! W$ ?0 o8 M) ?. x
int nGrowBy = m_nGrowBy;7 \1 q2 j1 Y9 v2 c; [, n
if (nGrowBy == 0)" ?$ `' _! A) H& l0 M
{
3 m, Z6 V" x4 ~' x9 p // heuristically determine growth when nGrowBy == 0
5 V1 c! t% J; D, B // (this avoids heap fragmentation in many situations) R) C% v% A) p, m1 f! g
nGrowBy = m_nSize / 8;" w3 G" U" \' ^$ U
nGrowBy = (nGrowBy < 4) ? 4 : ((nGrowBy > 1024) ? 1024 : nGrowBy);/ r; Q" L1 K" A7 d
}
, Q' ?7 N' Y5 z. @- r int nNewMax;
( Z' F! K. {) I- N0 A- | if (nNewSize < m_nMaxSize + nGrowBy) S" j' ]: v: {
nNewMax = m_nMaxSize + nGrowBy; // granularity
) ?# Q8 \2 L# p2 y3 w9 b0 O1 }6 f else- l5 ~6 n5 Y6 T: Z! z
nNewMax = nNewSize; // no slush ASSERT(nNewMax >= m_nMaxSize); // no wrap around- T" s, R' n: k. t1 r4 |; @
#ifdef SIZE_T_MAX
7 s( u) M/ ?- z ASSERT(nNewMax <= SIZE_T_MAX/sizeof(TYPE)); // no overflow$ u4 ^, G" P. u+ O) ^; [ K9 f
#endif: k5 x8 H5 \6 F. U: a% z
TYPE** pNewData = (TYPE**) new BYTE[nNewMax * sizeof(TYPE*)];//TYPE* pNewData = (TYPE*) new BYTE[nNewMax * sizeof(TYPE)]; // copy new data from old
, a$ I+ M, d9 ?+ s+ G4 u& T memcpy(pNewData, Ym_pData, m_nSize * sizeof(TYPE*)); // construct remaining elements% U9 {4 Q a' X8 k1 `
ASSERT(nNewSize > m_nSize); //throw("/*wait for me --- yzhlinux*/");" n7 F: r% S* ~ M* o" i( T- a. O
delete[] (BYTE*)Ym_pData;% c$ K% W" ~; {6 }
Ym_pData = pNewData;
: X# K6 h- ~5 v9 l9 Q. [ ConstructAllElements(m_nSize,nNewSize-m_nSize);//ConstructElements<TYPE>(&pNewData[m_nSize], nNewSize-m_nSize); // get rid of old stuff (note: no destructors called)2 W N u; O2 J
m_nSize = nNewSize;
: g7 |% q9 \, d' J m_nMaxSize = nNewMax;' \! X! o6 o! X0 d; j7 U+ n3 ~ Z# J6 I
}0 _) K. h3 I. Y9 d
SetIndexSize(nNewSize);0 V. J" b, s. h- g2 q& \
}8 E6 d a" j. w+ C2 Y6 _7 N0 ?; f
|