122 INT_PTR index = ite -
begin();
124 return begin() + index;
134 INT_PTR index = ite -
begin();
136 return begin() + index;
181 m_hptHead = other.m_hptHead;
207 m_hptHead = other.m_hptHead;
220 virtual TYP
Get(INDEX index)
const
222 return * m_hptHead->datack(index);
233 virtual const TYP&
At(INDEX index)
const
235 return * m_hptHead->datack(index);
246 virtual TYP&
Ref(INDEX index)
248 TYP* P = m_GetPtr(index);
265 virtual bool Set(INDEX index,
const TYP& t)
267 TYP* P = m_GetPtr(index);
299 TYP* P = m_GetPtr(index);
300 if ( P != NULL ){
return *P; }
342 m_incrementSize = size;
353 virtual bool Lock(DWORD dwTime = INFINITE)
const
355 return m_syncFunc.
Lock();
370 ASSERTLIB(! m_hptHead.
IsNull());
371 return m_hptHead->dataSize;
383 virtual INDEX
Add(
const TYP& t)
386 return (
AddElements(1, &t) == 1) ? r : INVALID_INDEX;
416 TYP* P = m_hptHead->pBuffer;
418 if ( size == 0 || nowSize - index <= size )
422 return RemoveAll() ? nowSize : INVALID_SIZE;
424 size = nowSize - index;
427 if ( nowSize > index + size )
429 loop ( i, nowSize - (index + size) )
431 ASSERTLIB( index + i + size < nowSize );
432 P[index + i] = P[index + i + size];
436 size_t s = m_hptHead->dataSize - size;
442 m_hptHead->dataSize -= size;
461 else if ( m_hptHead.
IsNull() )
465 THead* lpTmp = m_CreateHead(size);
466 m_CopyBuffer(lpTmp->pBuffer, P, size);
472 m_hptHead->syncObj.Lock();
473 THead* ptHead = m_hptHead;
476 size_t l = ptHead->dataSize + size;
477 THead* lpTmp = m_CreateHead(l);
478 m_CopyBuffer(lpTmp->pBuffer, ptHead->pBuffer, ptHead->dataSize);
479 m_CopyBuffer(lpTmp->data(ptHead->dataSize), P, size);
480 m_hptHead->syncObj.Unlock();
485 m_hptHead->syncObj.Unlock();
486 size_t l = ptHead->dataSize + size;
488 if ( ptHead->bufferSize >= l )
491 m_CopyBuffer(ptHead->data(ptHead->dataSize), P, size);
492 ptHead->dataSize = l;
498 size_t ss = m_GetSecureSize(l);
499 TYP* N =
new TYP[ss];
501 m_CopyBuffer(&N[0], ptHead->pBuffer, ptHead->dataSize);
502 m_CopyBuffer(&N[ptHead->dataSize], P, size);
504 if ( ptHead->pBuffer != NULL )
506 delete[] ptHead->pBuffer;
509 ptHead->bufferSize = ss;
510 ptHead->dataSize = l;
532 m_hptHead = v.m_hptHead;
551 TYP* P = m_hptHead->data(j);
579 virtual bool Insert(INDEX index,
const TYP& t)
586 if (
Add(TYP()) == INVALID_INDEX )
591 TYP* P = m_hptHead->pBuffer;
592 for (
size_t i = size; i > index; i-- )
607 m_hptHead->boValid =
false;
620 if ( size != INVALID_SIZE )
628 else if ( size == 0 )
634 size_t now = m_hptHead->dataSize;
639 TYP* P = m_hptHead->data(size);
640 for (
size_t i = size; i < now; i++ )
644 m_hptHead->dataSize = size;
646 else if ( now < size )
666 ASSERTLIB(! m_hptHead.
IsNull());
667 return m_hptHead->pBuffer;
689 if (
IsEmpty() && ! m_hptHead->boValid )
711 if ( m_hptHead->dataSize > startIndex )
713 if ( size == 0 || m_hptHead->dataSize - startIndex < size )
716 size = m_hptHead->dataSize - startIndex;
751 m_hptHead->syncObj.Lock();
758 m_hptHead->syncObj.Unlock();
764 else if ( iCnt == 1 )
767 m_hptHead->syncObj.Unlock();
781 size = m_hptHead->dataSize;
784 THead* lpTmp = m_CreateHead(size);
786 m_CopyBuffer(lpTmp->pBuffer, m_hptHead->pBuffer, size);
788 m_hptHead->syncObj.Unlock();
794 return m_hptHead->pBuffer;
809 m_hptHead->syncObj.Lock();
817 m_hptHead->syncObj.Unlock();
833 if ( size == 0 || size > l )
839 TYP* P = vb.m_hptHead->data();
860 THead(
void) : bufferSize(0) , dataSize(0) , boValid(true) , pBuffer(NULL) {}
865 if ( pBuffer != NULL )
877 TYP* data(INDEX f = 0)
const
887 TYP* datack(INDEX f = 0)
const
900 size_t m_incrementSize;
907 size_t m_GetSecureSize(
size_t size)
910 size_t marginSize = m_incrementSize;
911 if ( marginSize == 0 )
914 marginSize = size / 8;
915 marginSize = (marginSize < 4) ? 4 : ((marginSize > 1024) ? 1024 : marginSize);
917 return size + marginSize;
927 THead* m_CreateHead(
size_t size)
929 THead* lptTmpHead =
new THead;
931 size_t bs = m_GetSecureSize(size);
932 lptTmpHead->dataSize = size;
933 lptTmpHead->bufferSize = bs;
935 lptTmpHead->pBuffer =
new TYP[bs];
946 void m_CopyBuffer(TYP* _lpDst,
const TYP* lpSrc,
size_t iLen)
948 ASSERTLIB(_lpDst != NULL);
959 ASSERTLIB(! ::IsBadReadPtr(lpSrc, iLen));
962 *_lpDst++ = *lpSrc++;
973 m_hptHead =
new THead;
978 void m_Separate(
void)
980 m_hptHead->syncObj.Lock();
983 size_t size = m_hptHead->dataSize;
985 THead* lpTmp = m_CreateHead(size);
987 m_CopyBuffer(lpTmp->pBuffer, m_hptHead->pBuffer, size);
989 m_hptHead->syncObj.Unlock();
994 m_hptHead->syncObj.Unlock();
1004 TYP* m_GetPtr(INDEX index)
1009 return m_hptHead->data(index);
1038template<
typename TYP>
1053 virtual bool Set(INDEX index,
const TYP& t)
1059 return _super::Set(index, t);
1070 virtual bool Insert(INDEX index,
const TYP& t)
1076 return _super::Insert(index, t);
1093 return _super::operator[](index);
1110 return _super::operator[](index);
1159 v.
SetElements(
static_cast<size_t>(ba.GetSize()), ba.GetData());
#define loop(VAR, CNT)
loop構文.
virtual bool Insert(INDEX index, const TYP &t)
[追加] 要素一つ挿入
const TYP & operator[](INDEX index) const
[取得] 要素の参照取得.
TYP & operator[](INDEX index)
[取得] 要素の参照取得.
virtual bool Set(INDEX index, const TYP &t)
[設定] 要素の設定.
int SetReferCount(int iCount)
[設定] 参照数設定
int GetReferCount(void) const
[取得] 参照数取得.
bool IsNull(void) const
[確認] NULLチェック
virtual bool Lock(DWORD dwTime=INFINITE) const
[排他] ロック
virtual void Unlock(void) const
[排他] アンロック
iterator insert(iterator ite, const TYP &t=TYP())
[反復] 挿入
friend CVectorT< TYP > ToVector(const IConstCollectionT< TYP > &c, size_t size=0)
[作成] Vector作成
CVectorT & operator+=(const CVectorT< TYP > &vector)
[追加] 追加オペレータ
virtual size_t GetSize(void) const
[取得] サイズ取得
const_iterator end(void) const
[反復] 最後const_iterator.
friend class CVectorTest
フレンドクラス宣言
virtual bool Insert(INDEX index, const TYP &t)
[追加] 要素一つ挿入
virtual size_t RemoveElements(INDEX index, size_t size=0)
[削除] 要素削除.
virtual TYP Get(INDEX index) const
[取得] 要素の取得.
TYP * GetBuffer(size_t size=0)
[操作] データアドレス取得
void push_front(const TYP &t)
[反復] 先頭に挿入
iterator begin(void)
[反復] 先頭iterator.
void SetIncrementSize(size_t size)
[設定] 余白サイズ
CVectorT< TYP > operator+(const CVectorT< TYP > &other) const
[作成] 連結
void ReleaseBuffer(void)
[操作] データの管理を元に戻す.
virtual bool Remove(INDEX index)
[削除] 要素一つ削除.
virtual const TYP & At(INDEX index) const
[取得] 要素の参照取得.
virtual bool Lock(DWORD dwTime=INFINITE) const
[排他] ロック
void Invalid(void)
[操作] 無効状態にする
iterator erase(iterator ite)
[反復] 削除
bool IsValid(void) const
[確認] 有効チェック
virtual bool SetSize(size_t size)
[操作] サイズ指定
CVectorT(size_t size=0)
コンストラクタ
const TYP & operator[](INDEX index) const
[取得] 要素の参照取得.
virtual TYP & Ref(INDEX index)
[取得] 要素の参照取得.
virtual ~CVectorT(void)
デストラクタ
virtual bool RemoveAll(void)
[削除] 空化
virtual size_t AddElements(size_t size, const TYP *P=NULL)
[追加] 複数要素追加.
virtual const TYP * ReferBuffer(void) const
[取得] データアドレス取得
CVectorT< TYP > Mid(INDEX startIndex, size_t size=0) const
[作成] 切り出し
CVectorT & operator=(const CVectorT &other)
[代入] 代入
virtual INDEX Add(const TYP &t)
[追加] 要素一つ追加.
void push_back(const TYP &t)
[反復] 最後に追加
CVectorT(const CVectorT< TYP > &other)
コピーコンストラクタ
const_iterator begin(void) const
[反復] 先頭const_iterator.
TYP & operator[](INDEX index)
[取得] 要素の参照取得.
virtual void Unlock(void) const
[排他] アンロック
virtual size_t Append(const IConstCollectionT< TYP > &c)
[追加] 追加.
virtual bool Set(INDEX index, const TYP &t)
[設定] 要素の設定.
virtual size_t SetElements(size_t size, const TYP *P=NULL)
[設定] 複数要素設定.
iterator end(void)
[反復] 最後iterator.
int GetReferCount(void)
[取得] 参照数取得
void Copy(CByteArray &ba, const CByteVector &dat)
[複製] CByteVector からCByteArrayへコピー
TNB::CVectorT< WORD > CWordVector
WORD配列管理クラス
TNB::CVectorT< DWORD > CDwordVector
DWORD配列管理クラス
TNB::CVectorT< BYTE > CByteVector
BYTE配列管理クラス
CByteVector ToByteVector(const CByteArray &ba)
[複製] CByteArrayから CByteVector へコピー
#define EXCLUSIVE2(CLS1, CLS2)
簡易排他ツイン制御マクロ.
#define EXCLUSIVE(CLS)
簡易排他制御マクロ.
bool IsInRange(INDEX value, size_t size)
[確認] 範囲チェック.
void MemCopy(T *_pDst, const void *pSrc, size_t len)
[複製] メモリコピー
bool IsEmpty(void) const
[確認] 要素の有無確認.
virtual const TYP & At(INDEX index) const =0
[取得] 要素の参照取得.
bool IsInRange(INDEX index) const
[確認] INDEXの有効確認.
virtual size_t GetSize(void) const =0
[取得] 要素数取得.
連続メモリ配置型情報群管理インターフェーステンプレート