当前位置: 首页>>代码示例>>Python>>正文


Python Node.prev方法代码示例

本文整理汇总了Python中Node.Node.prev方法的典型用法代码示例。如果您正苦于以下问题:Python Node.prev方法的具体用法?Python Node.prev怎么用?Python Node.prev使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Node.Node的用法示例。


在下文中一共展示了Node.prev方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: add

# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import prev [as 别名]
	def add(self,data):
		newNode=Node(data,None,None)
		frontNode=self._header
		backNode=frontNode.next
		frontNode.next=newNode
		backNode.prev=newNode
		newNode.prev=frontNode
		newNode.next=backNode
开发者ID:eewilliac,项目名称:PythonLinkedList,代码行数:10,代码来源:DoublyLinkedList.py

示例2: build_list

# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import prev [as 别名]
def build_list(nodes_dict, file_content):
    # should be pointing to the start of the list
    nodes_as_linked_list = None

    for line in file_content:
        tokens = line.split()
        node_a_name = ""
        node_b_name = ""
        switch = 0
        before = True
        for string in tokens:
            if string == "after":
                before = False
            elif string == "comes":
                switch = 1
            elif not string == "before":
                if switch == 0:
                    node_a_name += string
                else:
                    node_b_name += string

        # after the for loop, node_a_name is the name of the first city
        # node_b_name is the name of hte second city
        # if before is True, then node_a_name comes before node_b_name
        # else, node_a_name comes after node_b_name

        if not node_a_name in nodes_dict:
            nodes_dict[node_a_name] = Node(node_a_name)
        if not node_b_name in nodes_dict:
            nodes_dict[node_b_name] = Node(node_b_name)

        if not modify_nodes(nodes_dict, node_a_name, node_b_name, before):
            return None

        if nodes_as_linked_list is None:
            nodes_as_linked_list = nodes_dict[node_a_name]
            if before:
                # set head to node A and set node A's next to point to B
                nodes_as_linked_list.prev = None
                nodes_as_linked_list.next = nodes_dict[node_b_name]
                nodes_dict[node_b_name].prev = nodes_as_linked_list
                nodes_dict[node_b_name].next = None
            else:
                # set head to node B and set node B's next to point to A
                nodes_as_linked_list.prev = nodes_dict[node_b_name]
                nodes_as_linked_list.next = None
                nodes_as_linked_list = nodes_as_linked_list.prev
                nodes_as_linked_list.next = nodes_dict[node_a_name]
                nodes_as_linked_list.prev = None
        else:
            if before:
                nodes_as_linked_list = modify_linked_list(node_a_name, node_b_name, nodes_dict, nodes_as_linked_list)
            else:
                nodes_as_linked_list = modify_linked_list(node_b_name, node_a_name, nodes_dict, nodes_as_linked_list)

    return nodes_as_linked_list
开发者ID:jojojames,项目名称:Python,代码行数:58,代码来源:puzzle_3.py

示例3: addItem

# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import prev [as 别名]
 def addItem(self, value):
     node = Node(value)
     if self.isEmpty():
         self.head = node
         self.tail = node
     else:
         node.prev = self.tail
         self.tail.next = node
         self.tail = node
     self.count += 1
开发者ID:erginbilgin,项目名称:PythonDoublyLinkedList,代码行数:12,代码来源:MyLinkedList.py

示例4: append

# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import prev [as 别名]
    def append(self, data):
        new_node = Node(data, None, None)

        if self.head == None:
            self.head = self.tail = new_node
        else:
            new_node.prev = self.tail
            new_node.next = None
            self.tail.next = new_node
            self.tail = new_node
开发者ID:Nyranith,项目名称:Overload-Factory-IS-105,代码行数:12,代码来源:buffer.py

示例5: add

# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import prev [as 别名]
    def add(self,value):
        new_node = Node(value, None, None)
        current_node = self.head

        if(current_node == None):
            self.head = new_node
        else:
            while(current_node.next != None):
                current_node = current_node.next

            current_node.next = new_node
            new_node.prev = current_node
开发者ID:Nyranith,项目名称:Overload-Factory-IS-105,代码行数:14,代码来源:buffer.py

示例6: insertItem

# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import prev [as 别名]
 def insertItem(self, value, position):
     node = Node(value)
     if self.count > position:
         if position == 0:
             node.next = self.head
             self.head.prev = node
             self.head = node
         else:
             currentNode = self.head
             for i in range(0, position):
                 currentNode = currentNode.next
             node.next = currentNode
             node.prev = currentNode.prev
             currentNode.prev.next = node
             currentNode.prev = node
         self.count += 1
开发者ID:erginbilgin,项目名称:PythonDoublyLinkedList,代码行数:18,代码来源:MyLinkedList.py

示例7: add_before

# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import prev [as 别名]
    def add_before(self, before_value, node_value):
        current_node = self.head
        new_node = Node(node_value, None, None)


        while current_node is not None:
            if current_node.data == before_value:
                if current_node.prev == None:
                    self.add_at_start(node_value)
                    #new_node.next = self.head
                    #self.head.prev = new_node
                    #self.head = new_node
                else:
                    new_node.prev = current_node.prev
                    new_node.next = current_node

                    current_node.prev = new_node

                break

            current_node = current_node.next
开发者ID:Nyranith,项目名称:Overload-Factory-IS-105,代码行数:23,代码来源:buffer.py

示例8: Node

# 需要导入模块: from Node import Node [as 别名]
# 或者: from Node.Node import prev [as 别名]
__author__ = 'Dixit_Patel'

from Node import Node

node = Node()
rear = Node()
node.num = 10;
node.next = Node();
node.prev = ""
rear = node

node.next.num = 11;
node.next.next = ""
node.next.prev = node


print(node.next.num)
print("rear: ", rear.num)
开发者ID:dixitk13,项目名称:python-scripts,代码行数:20,代码来源:DequeUse.py


注:本文中的Node.Node.prev方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。