BOOL CNetworkAdapterList::SetIpAddrEntry(LONG lIfIndex, LPCTSTR lpstrIPAddr, LPCTSTR lpstrIPNetMask, LPCTSTR lpstrNetNumber) { CNetworkAdapter cAdapter; POSITION pPosCur, pPosNext; pPosNext = GetHeadPosition(); pPosCur = GetHeadPosition(); while (pPosNext != NULL) { cAdapter = GetNext( pPosNext); if (cAdapter.GetIfIndex() == lIfIndex) { // That's the adapter to update cAdapter.SetIPAddress( lpstrIPAddr); cAdapter.SetIPNetMask( lpstrIPNetMask); cAdapter.SetNetNumber( lpstrNetNumber ); SetAt( pPosCur, cAdapter); return TRUE; } // Browse the next adapter and save the adapter position in the list pPosCur = pPosNext; } return FALSE; }
NEPointerList* NEPointerList::getElementsWithShortestDurationNotNull() { assert(!empty()); NEPointerList* list=new NEPointerList; GRNotationElement * e = NULL; GuidoPos pos=GetHeadPosition(); TYPE_DURATION dur(INT_MAX,1); while (pos) { e = GetNext(pos); if (e->getDuration() < dur && e->getDuration() > DURATION_0) dur = e->getDuration(); } pos = GetHeadPosition(); while (pos) { e = GetNext(pos); if (e->getDuration() == dur) { list->push_back(e); } } return list; }
BOOL CNetworkAdapterList::SetIpAddrEntry(LPCTSTR lpstrMAC, LPCTSTR lpstrIPAddr, LPCTSTR lpstrIPNetMask , LPCTSTR lpstrGateway, LPCTSTR lpstrDhcpServer, LPCTSTR lpstrNetNumber) { CNetworkAdapter cAdapter; POSITION pPosCur, pPosNext; pPosNext = GetHeadPosition(); pPosCur = GetHeadPosition(); while (pPosNext != NULL) { cAdapter = GetNext( pPosNext); if (_tcscmp( cAdapter.GetMACAddress(), lpstrMAC) ==0) { // That's the adapter to update cAdapter.SetIPAddress( lpstrIPAddr); cAdapter.SetIPNetMask( lpstrIPNetMask); cAdapter.SetGateway( lpstrGateway); cAdapter.SetDhcpServer( lpstrDhcpServer); cAdapter.SetNetNumber( lpstrNetNumber ); SetAt( pPosCur, cAdapter); return TRUE; } // Browse the next adapter and save the adapter position in the list pPosCur = pPosNext; } return FALSE; }
void CXTPDockingPaneTabbedContainer::OnTabsChanged() { if (!m_hWnd) return; m_nLockReposition += 1; DeleteAllItems(); m_bCloseItemButton = GetDockingPaneManager()->m_bShowCloseTabButton; POSITION pos = GetHeadPosition(); while (pos) { CXTPDockingPane* pPane = (CXTPDockingPane*)GetNext(pos); CXTPTabManagerItem* pItem = AddItem(GetItemCount()); if (m_pSelectedPane == pPane) SetSelectedItem(pItem); pItem->SetCaption(pPane->GetTabCaption()); pItem->SetColor(pPane->GetItemColor()); pItem->SetTooltip(pPane->GetTitle()); pItem->SetEnabled(pPane->GetEnabled() & xtpPaneEnableClient); pItem->SetClosable((pPane->GetOptions() & xtpPaneNoCloseable) == 0); pItem->SetData((DWORD_PTR)pPane); } ////////////////////////////////////////////////////////////////////////// m_pCaptionButtons->CheckForMouseOver(CPoint(-1, -1)); m_nLockReposition -= 1; }
void CXTPDockingPaneTabbedContainer::InvalidatePane(BOOL bSelectionChanged) { if (!GetSafeHwnd()) return; if (m_pParentContainer == 0) return; if (m_nLockReposition) return; m_nLockReposition += 1; OnTabsChanged(); m_nLockReposition -= 1; CRect rect = m_rcWindow; CXTPDockingPaneBase::GetPaintManager()->AdjustClientRect(this, rect, TRUE); if (bSelectionChanged) { POSITION pos = GetHeadPosition(); while (pos) { CXTPDockingPane* pPane = (CXTPDockingPane*)GetNext(pos); CRect rcPane = m_pSelectedPane == pPane ? rect : CRect(0, 0, 0, 0); pPane->OnSizeParent(m_pDockingSite, rcPane, 0); } } Invalidate(FALSE); m_pParentContainer->InvalidatePane(bSelectionChanged); }
void CXTPDockingPaneTabbedContainer::GetMinMaxInfo(LPMINMAXINFO pMinMaxInfo) const { CXTPDockingPaneBase::GetMinMaxInfo(pMinMaxInfo); if (IsEmpty()) return; if (IsPaneMinimized()) { if (((CXTPDockingPaneSplitterContainer*)m_pParentContainer)->IsHoriz()) pMinMaxInfo->ptMaxTrackSize.x = 0; else pMinMaxInfo->ptMaxTrackSize.y = 0; AdjustMinMaxInfoClientRect(pMinMaxInfo, FALSE); } else { POSITION pos = GetHeadPosition(); while (pos) { CXTPDockingPaneBase* pPane = GetNext(pos); MINMAXINFO info; pPane->GetMinMaxInfo(&info); pMinMaxInfo->ptMinTrackSize.x = max(pMinMaxInfo->ptMinTrackSize.x, info.ptMinTrackSize.x); pMinMaxInfo->ptMinTrackSize.y = max(pMinMaxInfo->ptMinTrackSize.y, info.ptMinTrackSize.y); pMinMaxInfo->ptMaxTrackSize.x = min(pMinMaxInfo->ptMaxTrackSize.x, info.ptMaxTrackSize.x); pMinMaxInfo->ptMaxTrackSize.y = min(pMinMaxInfo->ptMaxTrackSize.y, info.ptMaxTrackSize.y); } AdjustMinMaxInfoClientRect(pMinMaxInfo); } }
// // remove the single unit indicated by the dwID (with optional flag // to delete the actual object too) // void CAIUnitList::RemoveUnit( DWORD dwID, BOOL bObjectToo /*=TRUE*/ ) { ASSERT_VALID( this ); // no need to remove that which is not there CAIUnit *pUnit = GetUnit( dwID ); if( pUnit == NULL ) return; POSITION pos1, pos2; for( pos1 = GetHeadPosition(); ( pos2 = pos1 ) != NULL; ) { pUnit = (CAIUnit *)GetNext( pos1 ); if( pUnit != NULL ) { ASSERT_VALID( pUnit ); if( pUnit->GetID() != dwID ) continue; } pUnit = (CAIUnit *)GetAt( pos2 ); if( pUnit != NULL ) { ASSERT_VALID( pUnit ); RemoveAt( pos2 ); if( bObjectToo ) delete pUnit; break; } } }
// // remove all units belonging to this player // void CAIUnitList::RemoveUnits( int iPlayer ) { ASSERT_VALID( this ); CAIUnit *pUnit = NULL; POSITION pos1, pos2; for( pos1 = GetHeadPosition(); ( pos2 = pos1 ) != NULL; ) { pUnit = (CAIUnit *)GetNext( pos1 ); if( pUnit != NULL ) { ASSERT_VALID( pUnit ); if( pUnit->GetOwner() != iPlayer ) continue; } pUnit = (CAIUnit *)GetAt( pos2 ); if( pUnit != NULL ) { ASSERT_VALID( pUnit ); RemoveAt( pos2 ); delete pUnit; } } }
// // count number of vehicle units which have the passed dwID in // their dwData, indicating this is unit assigned for repair // at that repair center // int CAIUnitList::GetRepairCount( int iPlayer, DWORD dwRepBldg ) { int iCount = 0; POSITION pos = GetHeadPosition(); while( pos != NULL ) { CAIUnit *pUnit = (CAIUnit *)GetNext( pos ); if( pUnit != NULL ) { #if 0 //THREADS_ENABLED // BUGBUG this function must yield myYieldThread(); //if( myYieldThread() == TM_QUIT ) // throw(ERR_CAI_TM_QUIT); // THROW( pException ); #endif ASSERT_VALID( pUnit ); if( pUnit->GetOwner() != iPlayer ) continue; if( pUnit->GetType() != CUnit::vehicle ) continue; // this vehicle is assigned to be repaired at the // repair center passed in if( pUnit->GetDataDW() == dwRepBldg ) iCount++; } } return( iCount ); }
// 1. Satz über seine Buchmarke akt. BOOL CPtrListExt :: SetFirstRecord (COleVariant varBookmark, const char *pAbfallArt/* = NULL*/) { if ((VT_EMPTY == varBookmark.vt) || IsEmpty ()) return FALSE; BOOL bFound = FALSE; POSITION pos = GetHeadPosition(); CRecordInfo *pInfo = NULL; while (pos != NULL) { pInfo = (CRecordInfo *) GetNext(pos); ASSERT (NULL != pInfo); if (!bFound && (varBookmark == pInfo -> m_varBookMark)) { bFound = TRUE; pInfo -> m_bFirst = TRUE; // ggf. Art ändern if (pAbfallArt && *pAbfallArt) pInfo -> m_strAbfArt = pAbfallArt; } else pInfo -> m_bFirst = FALSE; } return bFound; }
void GSRasterizerList::Draw(const GSRasterizerData* data) { *m_sync = 0; m_stats.Reset(); __int64 start = __rdtsc(); POSITION pos = GetTailPosition(); while(pos) { GetPrev(pos)->Draw(data); } while(*m_sync) { _mm_pause(); } m_stats.ticks = __rdtsc() - start; pos = GetHeadPosition(); while(pos) { GSRasterizerStats s; GetNext(pos)->GetStats(s); m_stats.pixels += s.pixels; m_stats.prims = max(m_stats.prims, s.prims); } }
CRect CXTPDockingPaneSplitterContainer::_CalculateResultDockingRectSelf(CXTPDockingPaneBase* pPaneI, XTPDockingPaneDirection direction, CXTPDockingPaneBase* pNeighbour) { direction = GetDockingPaneManager()->GetRTLDirection(direction); ASSERT(pNeighbour); BOOL bAfter = (direction == xtpPaneDockRight || direction == xtpPaneDockBottom); // getting list of nonempty panes CXTPDockingPaneBaseList lst; POSITION posPanes = GetHeadPosition(); while (posPanes) { CXTPDockingPaneBase* pPane = GetNext(posPanes); if (pPane->IsEmpty() || (pPane == pPaneI)) continue; POSITION pos = lst.AddTail(pPane); if (pPane == pNeighbour) { if (bAfter) lst.InsertAfter(pos, pPaneI); else lst.InsertBefore(pos, pPaneI); } } CRect rcResult = _CalculateResultDockingRect(m_bHoriz, lst, m_rcWindow, pPaneI); m_pDockingSite->ClientToScreen(rcResult); return rcResult; }
void CXTPDockingPaneSplitterContainer::_InsertPane(CXTPDockingPaneBase* pPane, CXTPDockingPaneBase* pNeighbour, BOOL bAfter) { POSITION pos = pNeighbour ? m_lstPanes.Find(pNeighbour) : NULL; if (bAfter) { if (pos == NULL) pos = m_lstPanes.GetTailPosition(); m_lstPanes.InsertAfter(pos, pPane); } else { if (pos == NULL) pos = GetHeadPosition(); m_lstPanes.InsertBefore(pos, pPane); } pPane->m_pParentContainer = this; pPane->SetDockingSite(GetDockingSite()); GetDockingPaneManager()->RecalcFrameLayout(this, TRUE); _UpdateSplitters(); if (m_pParentContainer) { m_pParentContainer->OnChildContainerChanged(this); } pPane->OnParentContainerChanged(this); }
LPCTSTR CInputDeviceList::GetHash() { COcsCrypto myHash; CInputDevice myObject; POSITION pos; BOOL bContinue; CString csToHash; if (GetCount() == 0) return NULL; if (!myHash.HashInit()) return NULL; pos = GetHeadPosition(); bContinue = (pos != NULL); if (bContinue) // There is one record => get the first myObject = GetNext( pos); while (bContinue) { csToHash.Format( _T( "%s%s%s%s%s%s"), myObject.GetType(), myObject.GetManufacturer(), myObject.GetCaption(), myObject.GetDescription(), myObject.GetPointingInterface(), myObject.GetPointingType()); myHash.HashUpdate( csToHash); bContinue = (pos != NULL); if (bContinue) myObject = GetNext( pos); } return myHash.HashFinal(); }
void CSUIBtnList::OnSize(CRect WndRect){ POSITION pos = GetHeadPosition(); while(pos){ CSUIButton* cBtn = GetNext(pos); cBtn->OnSize(WndRect); } }
void CSUIBtnList::ClearStat(){ POSITION pos = GetHeadPosition(); while(pos){ CSUIButton* cBtn = GetNext(pos); cBtn->m_stat = 0; } }
LPCTSTR CVideoAdapterList::GetHash() { COcsCrypto myHash; CVideoAdapter myObject; POSITION pos; BOOL bContinue; CString csToHash; if (!myHash.HashInit()) return NULL; pos = GetHeadPosition(); bContinue = (pos != NULL); if (bContinue) // There is one record => get the first myObject = GetNext( pos); while (bContinue) { csToHash.Format( _T( "%s%s%s%s"), myObject.GetName(), myObject.GetChipset(), myObject.GetMemory(), myObject.GetScreenResolution()); myHash.HashUpdate( LPCTSTR( csToHash), csToHash.GetLength()); bContinue = (pos != NULL); if (bContinue) myObject = GetNext( pos); } return myHash.HashFinal(); }
BOOL CValueList::Save(const char *pszFilename) { CString strFile; if (!pszFilename) strFile = m_strFile; else strFile = pszFilename; CFile file; if (!file.Open(strFile,CFile::modeWrite|CFile::modeCreate)) return(FALSE); CArchive ar(&file,CArchive::store); ar << GetCount(); CValueItem vi; POSITION pos = GetHeadPosition(); while(pos) { vi = GetNext(pos); ar << vi.m_strText; ar << vi.m_nValue; } ar.Close(); file.Close(); return(TRUE); }
// Calling this function with bEnable equals to true when // shuffle is already enabled will re-shuffle the tracks. void CPlaylist::SetShuffle(bool bEnable) { m_bShuffle = bEnable; if (bEnable && !IsEmpty()) { m_nShuffledListSize = GetCount(); CAtlArray<plsort_t> positions; positions.SetCount(m_nShuffledListSize + 1); srand((unsigned int)time(nullptr)); POSITION pos = GetHeadPosition(); for (size_t i = 0; pos; i++, GetNext(pos)) { positions[i].n = rand(); positions[i].pos = pos; } qsort(positions.GetData(), m_nShuffledListSize, sizeof(plsort_t), compare); positions[m_nShuffledListSize].pos = nullptr; // Termination m_posHeadShuffle = positions[0].pos; m_posTailShuffle = nullptr; for (size_t i = 0; i < m_nShuffledListSize; i++) { pos = positions[i].pos; CPlaylistItem& pli = GetAt(pos); pli.m_posPrevShuffle = m_posTailShuffle; pli.m_posNextShuffle = positions[i + 1].pos; m_posTailShuffle = pos; } } else { m_posHeadShuffle = m_posTailShuffle = nullptr; m_nShuffledListSize = 0; } }
LPCTSTR CSystemSlotList::GetHash() { COcsCrypto myHash; CSystemSlot myObject; POSITION pos; BOOL bContinue; CString csToHash; if (GetCount() == 0) return NULL; if (!myHash.HashInit()) return NULL; pos = GetHeadPosition(); bContinue = (pos != NULL); if (bContinue) // There is one record => get the first myObject = GetNext( pos); while (bContinue) { csToHash.Format( _T( "%s%s%s%s%s"), myObject.GetName(), myObject.GetDescription(), myObject.GetSlotDesignation(), myObject.GetUsage(), myObject.GetStatus()); myHash.HashUpdate( csToHash); bContinue = (pos != NULL); if (bContinue) myObject = GetNext( pos); } return myHash.HashFinal(); }
LPCTSTR CModemList::GetHash() { COcsCrypto myHash; CModem myObject; POSITION pos; BOOL bContinue; CString csToHash; if (!myHash.HashInit()) return NULL; pos = GetHeadPosition(); bContinue = (pos != NULL); if (bContinue) // There is one record => get the first myObject = GetNext( pos); while (bContinue) { csToHash.Format( _T( "%s%s%s%s"), myObject.GetName(), myObject.GetModel(), myObject.GetDescription(), myObject.GetType()); myHash.HashUpdate( LPCTSTR( csToHash), csToHash.GetLength()); bContinue = (pos != NULL); if (bContinue) myObject = GetNext( pos); } return myHash.HashFinal(); }
LPCTSTR CMemorySlotList::GetHash() { COcsCrypto myHash; CMemorySlot myObject; POSITION pos; BOOL bContinue; static CString csToHash; if (GetCount() == 0) return NULL; if (!myHash.HashInit()) return NULL; pos = GetHeadPosition(); bContinue = (pos != NULL); if (bContinue) // There is one record => get the first myObject = GetNext( pos); while (bContinue) { csToHash.Format( _T( "%s%s%s%s%s%s%u%s"), myObject.GetCaption(), myObject.GetDescription(), myObject.GetCapacity(), myObject.GetUsage(), myObject.GetType(), myObject.GetSpeed(), myObject.GetSlotNumber(), myObject.GetSN()); myHash.HashUpdate( csToHash); bContinue = (pos != NULL); if (bContinue) myObject = GetNext( pos); } return myHash.HashFinal(); }
LPCTSTR CNetworkAdapterList::GetHash() { COcsCrypto myHash; CNetworkAdapter myObject; POSITION pos; BOOL bContinue; CString csToHash; if (GetCount() == 0) return NULL; if (!myHash.HashInit()) return NULL; pos = GetHeadPosition(); bContinue = (pos != NULL); if (bContinue) // There is one record => get the first myObject = GetNext( pos); while (bContinue) { csToHash.Format( _T( "%s%s%s%s%s%s%s%s%s"), myObject.GetDescription(), myObject.GetType(), myObject.GetTypeMIB(), myObject.GetMACAddress(), myObject.GetOperationalStatus(), myObject.GetIPAddress(), myObject.GetIPNetMask(), myObject.GetGateway(), myObject.GetDhcpServer()); myHash.HashUpdate( csToHash); bContinue = (pos != NULL); if (bContinue) myObject = GetNext( pos); } return myHash.HashFinal(); }
POSITION CPlaylist::Shuffle() { static INT_PTR idx = 0; static INT_PTR count = 0; static CAtlArray<plsort_t> a; ASSERT(GetCount() > 2); // insert or remove items in playlist, or index out of bounds then recalculate if ((count != GetCount()) || (idx >= GetCount())) { a.RemoveAll(); idx = 0; a.SetCount(count = GetCount()); POSITION pos = GetHeadPosition(); for (INT_PTR i = 0; pos; i++, GetNext(pos)) { a[i].pos = pos; // initialize position array } //Use Fisher-Yates shuffle algorithm srand((unsigned)time(nullptr)); for (INT_PTR i = 0; i < (count - 1); i++) { INT_PTR r = i + (rand() % (count - i)); POSITION temp = a[i].pos; a[i].pos = a[r].pos; a[r].pos = temp; } } return a[idx++].pos; }
//--------------------------------------------------------------------------- // Join all the records in all paritions. //--------------------------------------------------------------------------- bool CTDPartitions::joinPartitions(CTDRecords& jointRecs) { jointRecs.RemoveAll(); for (POSITION pos = GetHeadPosition(); pos != NULL;) { jointRecs.Append(*(GetNext(pos)->getAllRecords())); } return true; }
void CFuncList::CreateFuncList(int idx) { if (pGlobalFuncList == NULL) return; if (idx >= pGlobalFuncList->GetSize()) return; AddTail(pGlobalFuncList->ElementAt(idx)); SetOutstandList(idx); m_position = GetHeadPosition(); }
void CSUIBtnList::PaintAll(CMemoryDC *hDC, CRect rc){ POSITION pos = GetHeadPosition(); while(pos){ CSUIButton* cBtn = GetNext(pos); cBtn->OnPaint(hDC, rc); } }
void CSearchProfileList::Clear() { POSITION p = GetHeadPosition(); while (p) { CSearchProfile* prof = (CSearchProfile*)GetNext(p); delete prof; } RemoveAll(); }
/** * Quicksearch the file for str in fields */ void CBibList::DoQuickSearch(CString str, CString fields, BOOL regexpr) { POSITION p = GetHeadPosition(); while (p) { CBibItem *bi = (CBibItem*)GetNext(p); if (bi->IsRegularItem()) bi->DoQuickSearch(str, fields, regexpr); } }
int CSUIBtnList::GetMaxHeight(){ int nHeight = 0; POSITION pos = GetHeadPosition(); while(pos){ CSUIButton* cBtn = GetNext(pos); nHeight = max(nHeight, cBtn->m_orgbtnSize.cy); } return nHeight; }