本文整理汇总了Python中Node.Node.Next方法的典型用法代码示例。如果您正苦于以下问题:Python Node.Next方法的具体用法?Python Node.Next怎么用?Python Node.Next使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Node.Node
的用法示例。
在下文中一共展示了Node.Next方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: insertInOrder
# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import Next [as 别名]
def insertInOrder(self,x):
if self.__head:
pre,cur=None,self.__head
while cur.Next!=self.__head and x>cur.val:
pre,cur=cur,cur.Next
temp=Node(x)
if not pre:
# ^^ conditional check takes care of the cases where the insertion has to be made at the beginning or end
temp.Next=cur
self.__head=temp
else:
temp.Next=pre.Next
pre.Next=temp
else:
self.__head=Node(x)
CL.__size+=1
示例2: Insert
# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import Next [as 别名]
def Insert(self,index=None,element=None):
self.__locationNode(index)
node=Node(element)
#list have no node
if(self.__size==0):
self.__current=self.__end=self.__head=node
else:
#new node's next node is current's next
node.Next=self.__current.Next
#new node's previous node is current node
self.__current.Next=node
#insert at end of list,End need move on
if(self.__current==self.__end):
self.__end=self.__end.Next
#increases size
self.__size+=1
示例3: insertInOrder
# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import Next [as 别名]
def insertInOrder(self,x):
if self.__head:
pre,cur=None,self.__head
while cur.Next and cur.val<=x:
pre,cur=cur,cur.Next
if cur==self.__head and pre==None:
temp=Node(x)
temp.Next=self.__head
self.__head=temp
elif cur.Next==None and pre:
pre.Next=Node(x)
else:
pre.Next,pre.Next.Next=Node(x),cur
else:
self.__head=Node(x)
SL.__size+=1