OSDN Git Service

Use std::list instead of CList
authorTakashi Sawanaka <sdottaka@users.sourceforge.net>
Mon, 13 Mar 2023 11:57:29 +0000 (20:57 +0900)
committerTakashi Sawanaka <sdottaka@users.sourceforge.net>
Mon, 13 Mar 2023 11:57:29 +0000 (20:57 +0900)
Externals/crystaledit/editlib/ccrystaltextbuffer.cpp
Externals/crystaledit/editlib/ccrystaltextbuffer.h
Src/Common/CMoveConstraint.cpp
Src/Common/CMoveConstraint.h

index 96085fc..a7b9d78 100644 (file)
@@ -987,49 +987,32 @@ GetText (int nStartLine, int nStartChar, int nEndLine, int nEndChar,
 void CCrystalTextBuffer::
 AddView (CCrystalTextView * pView)
 {
-  m_lpViews.AddTail (pView);
+  m_lpViews.push_back (pView);
 }
 
 void CCrystalTextBuffer::
 RemoveView (CCrystalTextView * pView)
 {
-  POSITION pos = m_lpViews.GetHeadPosition ();
-  while (pos != nullptr)
-    {
-      POSITION thispos = pos;
-      CCrystalTextView *pvw = m_lpViews.GetNext (pos);
-      if (pvw == pView)
-        {
-          m_lpViews.RemoveAt (thispos);
-          return;
-        }
-    }
-  ASSERT (false);
+  auto it = std::find(m_lpViews.begin(), m_lpViews.end(), pView);
+  if (it != m_lpViews.end())
+      m_lpViews.erase(it);
 }
 
 CrystalLineParser::TextDefinition *CCrystalTextBuffer::
 RetypeViews (const tchar_t* lpszFileName)
 {
-  POSITION pos = m_lpViews.GetHeadPosition ();
   CString sNew = GetExt (lpszFileName);
   CrystalLineParser::TextDefinition *def = CrystalLineParser::GetTextType (sNew);
-  while (pos != nullptr)
-    {
-      CCrystalTextView *pView = m_lpViews.GetNext (pos);
-      pView->SetTextType (def);
-    }
+  for (auto* pView : m_lpViews)
+    pView->SetTextType (def);
   return def;
 }
 
 void CCrystalTextBuffer::
 UpdateViews (CCrystalTextView * pSource, CUpdateContext * pContext, DWORD dwUpdateFlags, int nLineIndex /*= -1*/ )
 {
-  POSITION pos = m_lpViews.GetHeadPosition ();
-  while (pos != nullptr)
-    {
-      CCrystalTextView *pView = m_lpViews.GetNext (pos);
-      pView->UpdateView (pSource, pContext, dwUpdateFlags, nLineIndex);
-    }
+  for (auto* pView : m_lpViews)
+    pView->UpdateView (pSource, pContext, dwUpdateFlags, nLineIndex);
 }
 
 /**
@@ -2156,10 +2139,8 @@ InvalidateColumns ()
 {
   for (auto& buf : m_pSharedTableProps->m_textBufferList)
     {
-      POSITION pos = buf->m_lpViews.GetHeadPosition ();
-      while (pos != nullptr)
+      for (auto* pView : buf->m_lpViews)
         {
-          CCrystalTextView* pView = buf->m_lpViews.GetNext (pos);
           pView->InvalidateScreenRect ();
           pView->UpdateView (nullptr, nullptr, UPDATE_HORZRANGE | UPDATE_VERTRANGE, -1);
         }
index 04caa4a..47182b3 100644 (file)
@@ -37,6 +37,7 @@
 #include "cepoint.h"
 #include <memory>
 #include <vector>
+#include <list>
 
 #ifndef __AFXTEMPL_H__
 #pragma message("Include <afxtempl.h> in your stdafx.h to avoid this message")
@@ -165,7 +166,7 @@ public :
     //END SW
 
     //  Connected views
-    CList < CCrystalTextView *, CCrystalTextView * >m_lpViews;
+    std::list < CCrystalTextView * > m_lpViews;
 
     // Table Editing
     bool m_bTableEditing;
index 48e9570..50d8cb3 100644 (file)
@@ -254,7 +254,7 @@ CMoveConstraint::ClearMostData()
        m_fShrinkHeight=0;
        m_bPropertyPage=false;
        m_bPropertySheet=false;
-       m_ConstraintList.RemoveAll();
+       m_ConstraintList.clear();
        m_bPersistent=false;
        m_bConstrainNonChildren = false;
 }
@@ -305,8 +305,7 @@ DoConstrain(CWnd * pWnd, HWND hwndChild, double fLeftX, double fExpandX, double
                m_nDelayed++;
        }
 
-       ConstraintList & constraintList = m_ConstraintList;
-       constraintList.AddTail(constraint);
+       m_ConstraintList.push_back(constraint);
        return true;
 }
 
@@ -389,10 +388,8 @@ CMoveConstraint::CheckDeferredChildren()
 {
        if (m_nDelayed == 0)
                return;
-       ConstraintList & constraintList = m_ConstraintList;
-       for (POSITION pos=constraintList.GetHeadPosition(); pos != nullptr; constraintList.GetNext(pos))
+       for (auto& constraint : m_ConstraintList)
        {
-               Constraint & constraint = constraintList.GetAt(pos);
                if (constraint.m_hwndChild  != nullptr)
                        continue;
                ASSERT(constraint.m_pWnd != nullptr);
@@ -436,10 +433,8 @@ CMoveConstraint::Resize(HWND hWnd, UINT nType)
        int nDeltaWidth = (rectParentCurrent.right - m_rectDlgOriginal.right);
        int nDeltaHeight = (rectParentCurrent.bottom - m_rectDlgOriginal.bottom);
 
-       ConstraintList & constraintList = m_ConstraintList;
-       for (POSITION pos=constraintList.GetHeadPosition(); pos != nullptr; constraintList.GetNext(pos))
+       for (auto& constraint : m_ConstraintList)
        {
-               Constraint & constraint = constraintList.GetAt(pos);
                if (constraint.m_hwndChild == nullptr)
                        continue;
 
index aa221f0..38dbcae 100644 (file)
@@ -206,7 +206,7 @@ protected:
                void Init();
        };
 
-       typedef CList<Constraint, Constraint &> ConstraintList;
+       typedef std::list<Constraint> ConstraintList;
 
 
 // Implementation data