-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNode.py
More file actions
64 lines (51 loc) · 1.57 KB
/
Node.py
File metadata and controls
64 lines (51 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/python
#coding=utf-8
'''
一个节点用三个字段描述
该节点所在类名
该节点方法名
该节点父节点
'''
class Node:
# def __init__(self):
# self.__className = ''
# self.__methodName = ''
# self.__parent = None
# self.__childList = []
def __init__(self,classname = '',methodname = ''):
self.__className = classname
self.__methodName = methodname
self.__parent = None
self.__childList = []
def equils(self,node):
if node.getClassName() == self.__className and node.getMethodName() == self.__methodName:
return True
return False
def getHash(self):
return hash(self.__className+self.__methodName)
def setClassName(self,className):
self.__className = className
def getClassName(self):
return self.__className
def setMethodName(self,methodName):
self.__methodName = methodName
def getMethodName(self):
return self.__methodName
def setParent(self,parent):
self.__parent = parent
def getParent(self):
return self.__parent
def getChildList(self):
return self.__childList
'''
添加子节点 同时子节点里面添加父节点
'''
def addChild(self,node):
self.__childList.append(node)
node.setParent(self)
def addChildList(self,nodeList):
self.__childList = self.__childList+nodeList
for node in nodeList:
node.setParent(self)
def deleteChild(self,node):
self.__childList.remove(node)