本文整理汇总了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)