Tag Archives: linked list

Linked Lists via ctypes in Python

from ctypes import *

class linknode(Structure):
    pass
linknode._fields_ = [
                ("nextNode", POINTER(linknode)),
                ("intData", c_int),
                ]
class linked_list():
    head_node = None
    def add(self, int_data):
        node_to_add = linknode(intData = c_int(int_data))
        if (self.head_node == None):
            self.head_node = node_to_add
        else:
            traverse_node

Posted in Programming, Python, Snippets | Tagged , , , , | Leave a comment