當前位置: 首頁>>代碼示例>>Python>>正文


Python LinkedList.insertAfter方法代碼示例

本文整理匯總了Python中LinkedList.LinkedList.insertAfter方法的典型用法代碼示例。如果您正苦於以下問題:Python LinkedList.insertAfter方法的具體用法?Python LinkedList.insertAfter怎麽用?Python LinkedList.insertAfter使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在LinkedList.LinkedList的用法示例。


在下文中一共展示了LinkedList.insertAfter方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: _getProximityQueryTermPostingList

# 需要導入模塊: from LinkedList import LinkedList [as 別名]
# 或者: from LinkedList.LinkedList import insertAfter [as 別名]
 def _getProximityQueryTermPostingList(self, term1String, term2String, distance):
     term1    = self._getQueryTermPostingList(term1String);
     term2    = self._getQueryTermPostingList(term2String);
     docs1    = term1.docs._head;
     docs2    = term2.docs._head;
     newDocs1 = LinkedList();
     newDocs2 = LinkedList();
     termHasDocs = False
     while (docs1 is not None) and (docs2 is not None):
         if docs1.value == docs2.value:
             if self._docHasTokensWithinDistance(docs1.value, docs2.value, distance):
                 newDocs1.insertAfter(docs1.value);
                 newDocs2.insertAfter(docs2.value);
                 termHasDocs = True;
             docs1 = docs1.next;
             docs2 = docs2.next;
         else:
             if docs1.value < docs2.value: docs1 = docs1.next;
             else: docs2 = docs2.next;
     # transfer term count per document to truncated list
     newDocs1.count = term1.count
     newDocs2.count = term2.count
     # exchange full document term count with truncated list
     term1.docs = newDocs1;
     term2.docs = newDocs2;
     if termHasDocs: return term1, term2;
     else: return None, None
開發者ID:anconaesselmann,項目名稱:pySearch,代碼行數:29,代碼來源:SearchEngine.py

示例2: comment

# 需要導入模塊: from LinkedList import LinkedList [as 別名]
# 或者: from LinkedList.LinkedList import insertAfter [as 別名]
        comment("FAIL -> " + test_name +"\nsize debe ser  0 cuando la lista esta vacia")
        grade(0)
except:
    e = sys.exc_info()[1]
    comment("FAIL -> " + test_name + "\n" + str(e))
    grade(0)



# Check one element list - insertAfter


try:
    test_name = 'LinkedList con un elemento: insertAfter()'
    l = LinkedList()
    l.insertAfter(17)
    if l.head != l.tail or l.head != l.current:
        comment("FAIL -> " + test_name+"\n head, tail y current deben apuntar al mismo nodo cuando solo hay un elemento")
        grade(0)
    else:
        if l.current.getData() != 17:
            comment("FAIL -> " + test_name +"\n getData() no funciona correctamente cuando la lista tiene un solo elemento")
            grade(0)
        else:
            if l.current.getNext() != None:
                comment("FAIL -> " + test_name +"\n getNext() no funciona correctamente cuando la lista tiene un solo elemento. getNext() deberia devolver None en este caso")
                grade(0)
            else:
                if l.size != 1:
                    comment("FAIL -> " + test_name +"\n La variable size no se incrementa correctamente")
                    grade(0)
開發者ID:emiliogq,項目名稱:pyrobot,代碼行數:33,代碼來源:joc_proves_LinkedList.py


注:本文中的LinkedList.LinkedList.insertAfter方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。