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


Python PE.add方法代碼示例

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


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

示例1: insertAppend

# 需要導入模塊: import PE [as 別名]
# 或者: from PE import add [as 別名]
def insertAppend(C6, v, e) :
    """appends  e  to the end of array/list  v  in the heap.
       Does the same actions as an insertAssign to an indexed array,
       but preserves more heap info since the append does not produce
       any aliases within v

       params : C6; v - a vartee; e - an etree
    """
    sigma = C6["store"]
    heap = C6["heap"]
    vname = v[1]
    vold = Parse.makeOldVar(v)
    if lookupType(C6, vname) != "array" :
        error("cannot append to a non-list/array")
    else :
        loc = PE.peToTuple(sigma[vname])
        length = heap[loc][0]
        newlength = PE.add(length, PE.make(1))
        vector = heap[loc][1]

        # assign original to v_old:
        sigma[vold[1]] = sigma[vname]

        # make copy for the new value of  v:
        copy = {}
        for k in vector :
            copy[k] = vector[k]
        newloc = PE.make(PE.makeSym())
        rhs = PE.evall(C6, e)
        copy[ PE.peToTuple(length) ] = rhs
        sigma[vname] = newloc
        heap[ PE.peToTuple(newloc) ] = (newlength, copy)
開發者ID:amgregoi,項目名稱:School,代碼行數:34,代碼來源:Tables.py


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