MCPcopy Create free account
hub / github.com/CobaltFusion/DebugViewPP / CAtlArray

Class CAtlArray

Libraries/TabbingFramework/CustomTabCtrl.h:667–728  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

665
666template<typename E>
667class CAtlArray : protected ATL::CSimpleArray<E>
668{
669protected:
670 typedef CAtlArray thisClass;
671 typedef ATL::CSimpleArray<E> baseClass;
672
673public:
674
675 //Real CAtlArray: size_t GetCount() const throw();
676 size_t GetCount() const
677 {
678 return m_nSize;
679 }
680
681 //Real CAtlArray: void InsertAt( size_t iElement, INARGTYPE element, size_t nCount = 1 );
682 void InsertAt( size_t nIndex, E& element )
683 {
684 if(m_nSize == m_nAllocSize)
685 {
686 E* aT;
687 int nNewAllocSize = (m_nAllocSize == 0) ? 1 : (m_nSize * 2);
688 aT = (E*)realloc(m_aT, nNewAllocSize * sizeof(E));
689 if(aT == NULL)
690 return; // FALSE;
691 m_nAllocSize = nNewAllocSize;
692 m_aT = aT;
693 }
694 memmove((void*)&m_aT[nIndex+1], (void*)&m_aT[nIndex], (m_nSize - nIndex ) * sizeof(E));
695 m_nSize++;
696 SetAtIndex(nIndex, element);
697 //return TRUE;
698 }
699
700 //Real CAtlArray: void RemoveAt( size_t iElement, size_t nCount = 1 );
701 void RemoveAt( size_t nIndex )
702 {
703 // This is an improvement over CSimpleArray::RemoveAt suggested
704 // by Jim Springfield on the ATL discussion list
705 m_aT[nIndex].~E();
706 if((int)nIndex != (m_nSize - 1))
707 {
708 memmove((void*)&m_aT[nIndex], (void*)&m_aT[nIndex + 1], (m_nSize - (nIndex + 1)) * sizeof(E));
709 }
710 m_nSize--;
711 //return TRUE;
712 }
713
714 //Real CAtlArray: const E& operator[]( size_t iElement ) const throw();
715 const E& operator[]( size_t iElement ) const
716 {
717 ATLASSERT( iElement < (size_t)m_nSize );
718 return( m_aT[iElement] );
719 }
720
721 //Real CAtlArray: E& operator[]( size_t iElement ) throw();
722 E& operator[]( size_t iElement )
723 {
724 ATLASSERT( iElement < (size_t)m_nSize );

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected