Exemplo n.º 1
0
 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;
 }
Exemplo n.º 2
0
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();
}