コード例 #1
0
ファイル: 82.cpp プロジェクト: TakuyaKimura/Leetcode
 ListNode* deleteDuplicates(ListNode* head) {
     ListNode dummy = ListNode(-1);
     dummy.next = head;
     ListNode *pre = &dummy, *cur = head, *first = head;
     while (cur)
     {
         if (cur->val != first->val)
         {
             if (first->next == cur)
             {
                 pre = first;
                 first = cur;
             }
             else
             {
                 deleteBetween(pre, cur);
                 first = cur;
             }
         }
         cur = cur->next;
     }
     if (first && first->next)
         deleteBetween(pre, nullptr);
     return dummy.next;
 }
コード例 #2
0
ファイル: foamobject.cpp プロジェクト: danbarrynz/engrid
void FoamObject::stripBuffer()
{
  while (deleteBetween(0, "/*", "*/")) {};
  while (deleteBetween(0, "//", "\n")) {};
  int i = m_Buffer.indexOf("FoamFile", 0);
  if (i != -1) {
    deleteBetween(i, "{", "}");
  }
  m_Buffer.replace("FoamFile","");
  m_Buffer.replace("{", " ");
  m_Buffer.replace("}", " ");
  m_Buffer.replace("(", " ");
  m_Buffer.replace(")", " ");
  m_Buffer.replace(";", " ");
  m_Buffer = m_Buffer.simplified();
}