def getCombinationExtraSet(extraList, index, selectExtraSet, oneExtraSet):
if (index >= len(extraList)): #
selectExtraSet.add(frozenset(oneExtraSet))
return
extra = extraList[index]
if (extra.type == "int"):
oneExtraSetCopy = set(oneExtraSet)
oneExtraSetCopy.add(extra) # ==
getCombinationExtraSet(extraList, index + 1, selectExtraSet, oneExtraSetCopy)
oneExtraSetCopy = set(oneExtraSet)
extraG = Extra(extra.key, extra.type, extra.value)#+1
extraG.value = int(extraG.value) + 1
oneExtraSetCopy.add(extraG)
getCombinationExtraSet(extraList, index + 1, selectExtraSet, oneExtraSetCopy)
oneExtraSetCopy = set(oneExtraSet)
extraL = Extra(extra.key, extra.type, extra.value)#-1
extraL.value = int(extra.value) - 1
oneExtraSetCopy.add(extraL)
getCombinationExtraSet(extraList, index + 1, selectExtraSet, oneExtraSetCopy)
else:
if extra.type == "float":
oneExtraSetCopy = set(oneExtraSet)
oneExtraSetCopy.add(extra)
getCombinationExtraSet(extraList, index + 1, selectExtraSet, oneExtraSetCopy)
extraG = Extra(extra.key, extra.type, extra.value)
extraG.value = float(extraG.value) + 0.1
oneExtraSetCopy = set(oneExtraSet)
oneExtraSetCopy.add(extraG)
getCombinationExtraSet(extraList, index + 1, selectExtraSet, oneExtraSetCopy)
extraL = Extra(extra.key, extra.type, extra.value)
extraL.value = float(extra.value) - 0.1
oneExtraSetCopy = set(oneExtraSet)
oneExtraSetCopy.add(extraL)
getCombinationExtraSet(extraList, index + 1, selectExtraSet, oneExtraSetCopy)
else:
if (extra.type != "java.lang.String"):
fail_unHandle = open(logDir + "/" + "fail_unHandle.txt", 'a+')
fail_unHandle.write(extra.type + "can't handle" + "\n")
fail_unHandle.close()
oneExtraSetCopy = set(oneExtraSet)
getCombinationExtraSet(extraList, index + 1, selectExtraSet, oneExtraSetCopy)
oneExtraSetCopy = set(oneExtraSet)
oneExtraSetCopy.add(extra)
getCombinationExtraSet(extraList, index + 1, selectExtraSet, oneExtraSetCopy)
递归组合都不会了?尼玛
最新推荐文章于 2021-05-30 01:51:45 发布