void CSortStringArray::Sort() { BOOL bNotDone = TRUE; while (bNotDone) { bNotDone = FALSE; for (int pos = 0; pos < GetUpperBound(); pos++) { bNotDone |= CompareAndSwap(pos); } } }
//------------------------------------------------------------------------------ // // Function Name: CMLListCtrlColumns::Flush() // // Parameters: bDelete - TRUE to force deallocation of all objects // // Return Value: None // // Description: This function is called to remove all objects from the // array // //------------------------------------------------------------------------------ void CMLListCtrlColumns::Flush(BOOL bDelete) { // Do we want to delete the objects? if(bDelete) { for(int i = 0; i <= GetUpperBound(); i++) { if(GetAt(i) != 0) delete GetAt(i); } } // Remove all pointers from the array RemoveAll(); }
// ------------------------- CloseAll ----------------------------------------- // close them all void CServerRS232Array::CloseAll() { CRS232Port *pPort,*pPort1; LONG n=GetUpperBound(); // go backwards through the list so that the objects // are destroyed in reverse order of creation. pPort1 = (CRS232Port *)GetAt(0); while (n>=0) { pPort = (CRS232Port *)GetAt(n); // Make sure to close all items this array holds pPort->keepPolling = FALSE; if (NULL != pPort) pPort->ClosePort(); n--; } } // CloseAll
// -------------------------------- NumberConnected --------------------------- // return # of sockets that are still connected to something LONG CServerRS232Array::NumberConnected() { CRS232Port *pPort; LONG n=GetUpperBound(); LONG ret = 0; // go backwards through the list so that the objects // are destroyed in reverse order of creation. while (n>=0) { pPort = (CRS232Port *)GetAt(n); // Make sure to delete all items this array holds if (NULL != pPort) if (INVALID_HANDLE_VALUE != pPort->h232Port) ret++; n--; } return(ret); } // NumberConnected
//m$ implementation ==> MiGetPreviousNode __checkReturn bool GetPrev( __inout const TYPE** node ) { if (node && *node) { const TYPE* next; if (next = LeftChild(*node)) return GetUpperBound(next, node); next = Parent(*node); for (const void* child = *node; next && next != child; next = Parent(child)) { if (LeftChild(next) != child) { *node = next; return true; } child = next; } } return false; }
void CGXGridCellStylePtrArrayPtrArray::Serialize(CArchive& ar) { // Serializes only existing elements, // e.g. 1 xxx 2 xxx 3 xxx 7 xxx 22 xxx DWORD_MAX, // where xxx is a CGXGridCellStylePtrArray object and DWORD_MAX identifies the end of serialization static const WORD wVersion = 1; WORD wActualVersion = wVersion; ASSERT_VALID(this); if (ar.IsStoring()) { ar << wVersion; } else { // Check for version first ar >> wActualVersion; if( wActualVersion != wVersion ) { // Wrong version #ifdef _DEBUG TRACE0( "Incompatible format while reading CGXGridCellStylePtrArrayPtrArray " ); TRACE2("in %s at line %d\n", THIS_FILE, __LINE__); ASSERT(0); // ASSERTION-> Incompatible format while reading CGXGridCellStylePtrArrayPtrArray object ->END #endif AfxThrowArchiveException(CArchiveException::badSchema); return; } } const DWORD dwTerm = 0xFFFFFFFF; if (ar.IsStoring()) { // storing DWORD dwSize = (DWORD)GetSize(); ar << dwSize; for (int index = 0; index <= GetUpperBound(); index++) { CGXGridCellStylePtrArray* pStylePtrArray = GetAt(index); if (pStylePtrArray) { ar << (DWORD) index; pStylePtrArray->Serialize(ar); } } ar << dwTerm; } else { // loading DeleteAll(); DWORD dwSize; ar >> dwSize; SetSize((int) dwSize); DWORD dwIndex; ar >> dwIndex; while (dwIndex != dwTerm) { CGXGridCellStylePtrArray* pStylePtrArray = new CGXGridCellStylePtrArray; pStylePtrArray->Serialize(ar); SetAt((int) dwIndex, pStylePtrArray); // Next id ar >> dwIndex; } } }