59template<
typename TYP,
typename ATT = DWORD>
72 TOne(TYP t) : value(t) , attribute(ATT()) , pNextOne(NULL)
81 if ( pNextOne != NULL )
101 TTop(
void) : TOne(TYP()) , size(0) , pLastOne(NULL) {}
113 TOne* GetPointer(INDEX index)
const
115 const TOne* P =
this;
116 for ( INDEX i = index + 1; i > 0; i-- )
118 if ( P->pNextOne == NULL )
125 return const_cast<TOne*
>(P);
132 TOne* GetLastPointer(
void)
135 if ( pLastOne != NULL ){
return pLastOne; }
140 if ( P->pNextOne == NULL )
146 ASSERTLIB(pLastOne == NULL || pLastOne == P);
157 void m_Separate(
void)
159 m_hpTop->m_syncObj.Lock();
166 TOne* pOld = m_hpTop->pNextOne;
169 ASSERTLIB(pOld != NULL);
170 pNew->pNextOne =
new TOne(pOld->value);
171 pNew->pNextOne->attribute = pOld->attribute;
173 P->pLastOne = pNew->pNextOne;
175 pOld = pOld->pNextOne;
176 pNew = pNew->pNextOne;
179 m_hpTop->m_syncObj.Unlock();
184 m_hpTop->m_syncObj.Unlock();
198 const TOne* P = m_hpTop->GetPointer(index);
199 return (P == NULL) ? NULL : &(P->value);
211 TOne* P = m_hpTop->GetPointer(index);
212 return (P == NULL) ? NULL : &(P->value);
225 INDEX index = ite.GetIndex();
227 return begin() + index;
244 CListT(
void) : _super(), m_hpTop(new TTop)
269 m_hpTop = other.m_hpTop;
283 TOne* P = list.GetPointer(0);
284 loop ( i, list.m_hpTop->GetSize() )
286 ASSERTLIB( P != NULL );
287 VERIFYLIB(
Add(P->value, P->attribute) != INVALID_INDEX );
301 virtual bool Lock(DWORD dwTime = INFINITE)
const
303 return m_syncFunc.
Lock();
318 return m_hpTop->size;
328 virtual INDEX
Add(
const TYP& t)
330 return Add(t, ATT());
344 m_hpTop->m_syncObj.Lock();
345 TOne* P = m_hpTop->GetPointer(index - 1);
348 m_hpTop->m_syncObj.Unlock();
351 TOne* pTmp = P->pNextOne;
354 m_hpTop->m_syncObj.Unlock();
357 P->pNextOne = pTmp->pNextOne;
360 m_hpTop->pLastOne = NULL;
361 m_hpTop->m_syncObj.Unlock();
374 virtual bool Set(INDEX index,
const TYP& t)
376 return Set(index, t, ATT());
386 virtual bool SetEx(INDEX index,
const TYP& t)
388 return SetEx(index, t, ATT());
408 virtual void Swap(INDEX index1, INDEX index2)
410 if ( index1 == index2 )
416 TOne* P1 = m_hpTop->GetPointer(index1 - 1);
417 TOne* P2 = m_hpTop->GetPointer(index2 - 1);
419 TOne* P1n = P1->pNextOne;
420 TOne* P2n = P2->pNextOne;
422 TOne** P1nn = &(P1n->pNextOne);
423 TOne** P2nn = &(P2n->pNextOne);
430 m_hpTop->pLastOne = NULL;
441 INDEX
Add(
const TYP& t,
const ATT& attribute)
444 m_hpTop->m_syncObj.Lock();
445 INDEX r = m_hpTop->size;
446 TOne* P = m_hpTop->GetLastPointer();
447 ASSERTLIB(P != NULL);
448 P->pNextOne =
new TOne(t);
449 P->pNextOne->attribute = attribute;
451 m_hpTop->pLastOne = P->pNextOne;
452 m_hpTop->m_syncObj.Unlock();
462 INDEX
AddEx(
const TYP& t,
const ATT& attribute)
465 return Add(t, attribute);
478 bool Set(INDEX index,
const TYP& t,
const ATT& attribute)
481 TOne* P = m_hpTop->GetPointer(index);
487 P->attribute = attribute;
499 bool SetEx(INDEX index,
const TYP& t,
const ATT& attribute)
502 return Set(index, t, attribute);
514 TOne* P = m_hpTop->GetPointer(index);
519 ASSERT1(
false,
"CListT::GetAttribute",
"範囲外のIndex(%d)が指定されました。", index);
532 bool Insert(INDEX index,
const TYP& t,
const ATT& attribute = ATT())
538 return Add(t) != INVALID_INDEX;
540 m_hpTop->m_syncObj.Lock();
541 TOne* P = m_hpTop->GetPointer(index - 1);
544 m_hpTop->m_syncObj.Unlock();
547 TOne* pNew =
new TOne(t);
548 pNew->attribute = attribute;
549 pNew->pNextOne = P->pNextOne;
552 m_hpTop->m_syncObj.Unlock();
566 if ( size == INVALID_SIZE )
571 m_hpTop->m_syncObj.Lock();
572 if ( size < m_hpTop->size )
576 TOne* P = m_hpTop->GetPointer(size - 1);
578 m_hpTop->size = size;
579 m_hpTop->m_syncObj.Unlock();
581 else if ( size > m_hpTop->size )
584 INT_PTR l = size - m_hpTop->size;
586 m_hpTop->m_syncObj.Unlock();
611 if ( ! checker.
IsValid(
At(i)) ^ boIsReverse )
613 if ( !
Remove(i) ){
return INVALID_SIZE; }
640 for ( INDEX i =
GetSize() - 1; i >= 0; i-- )
#define loop(VAR, CNT)
loop構文.
iterator insert(iterator ite, const TYP &t=TYP())
[反復] 挿入
bool Insert(INDEX index, const TYP &t, const ATT &attribute=ATT())
[追加] 要素一つ挿入.
size_t CullOnAttribute(typename const IConstCollectionT< ATT >::IChecker &checker, bool boIsReverse=false)
[削除] 間引き.
virtual void Swap(INDEX index1, INDEX index2)
[設定] 要素の入れ替え
INDEX Add(const TYP &t, const ATT &attribute)
[追加] 要素一つ追加
virtual size_t GetSize(void) const
[取得] 要素数取得
bool Set(INDEX index, const TYP &t, const ATT &attribute)
[設定] 要素の設定
virtual size_t Cull(const IChecker &checker, bool boIsReverse=false)
[削除] 間引き.
virtual void Deserialize(const IDeserializer &ds)
[処理] デシリアライズ
void push_front(const TYP &t)
[反復] 先頭に挿入
virtual ~CListT(void)
デストラクタ
virtual bool Remove(INDEX index)
[削除] 要素一つ削除
virtual bool Lock(DWORD dwTime=INFINITE) const
[排他] ロック
virtual bool SetSize(size_t size)
[操作] サイズ指定
CListT & operator+=(const CListT &list)
[追加] 追加オペレータ.
virtual bool RemoveAll(void)
[削除] 全要素削除
INDEX AddEx(const TYP &t, const ATT &attribute)
[追加] 要素一つ追加
CListT & operator=(const CListT &other)
[代入] コピーオペレータ
CListT(const CListT &other)
コピーコンストラクタ
virtual INDEX Add(const TYP &t)
[追加] 要素一つ追加
virtual void Serialize(ISerializer &_sr) const
[処理] シリアライズ
bool SetEx(INDEX index, const TYP &t, const ATT &attribute)
[設定] 要素の設定
virtual void Unlock(void) const
[排他] アンロック
virtual const TYP * m_GetConstPointer(INDEX index) const
[取得] 要素アドレス取得
const ATT & GetAttribute(INDEX index) const
[取得] 要素の属性値、取得
virtual bool SetEx(INDEX index, const TYP &t)
[設定] 要素の設定.
virtual bool Set(INDEX index, const TYP &t)
[設定] 要素の設定.
virtual TYP * m_GetPointer(INDEX index)
[取得] 要素アドレス取得
int GetReferCount(void) const
[取得] 参照数取得.
virtual bool Lock(DWORD dwTime=INFINITE) const
[排他] ロック
virtual void Unlock(void) const
[排他] アンロック
virtual const TYP & At(INDEX index) const
[取得] 要素の参照取得.
TNB::CListT< BYTE > CByteList
BYTE配列管理クラス
#define EXCLUSIVE2(CLS1, CLS2)
簡易排他ツイン制御マクロ.
#define EXCLUSIVE(CLS)
簡易排他制御マクロ.
const_iterator begin(void) const
[反復] 先頭const_iterator.
情報群管理インターフェースのチェッカーインターフェース.
virtual bool IsValid(const TYP &T) const =0
[確認] チェック
bool IsEmpty(void) const
[確認] 要素の有無確認.