예제 #1
0
list_destroy = helpers.wrap_func(list_lib.list_destroy, _List, [_List])

# unsigned int list_length(list_t list)
list_length = helpers.wrap_func(list_lib.list_length, ctypes.c_uint, [_List])

# bool list_is_equal(list_t list, list_t other)
list_is_equal = helpers.wrap_func(list_lib.list_is_equal, ctypes.c_bool,
                                  [_List, _List])

# data_t list_search(list_t list, index_t index)
list_search = helpers.wrap_func(list_lib.list_search, base_wrapper._Data,
                                [_List, base_wrapper._Index])

# list_t list_append(list_t list, index_t index, data_t data)
list_append = helpers.maybe_implemented(
    list_lib, 'list_append', _List,
    [_List, base_wrapper._Index, base_wrapper._Data])

# list_t list_remove(list_t list, index_t index)
list_remove = helpers.wrap_func(list_lib.list_remove, _List,
                                [_List, base_wrapper._Index])

# list_t list_copy(list_t list)
list_copy = helpers.wrap_func(list_lib.list_copy, _List, [_List])

# void list_dump(list_t list, FILE *fd)
list_dump = helpers.wrap_func(list_lib.list_dump, None,
                              [_List, helpers.FILE_ptr])

# Punto estrella 1
# list_t list_add(list_t list, index_t index, data_t data)
예제 #2
0
# ctypes wrapper
stack_lib = helpers.get_lib('stack.so')

# TADs


class __Stack(ctypes.Structure):
    pass


_Stack = ctypes.POINTER(__Stack)

# Wrappers

# stack_t stack_empty(void)
stack_empty = helpers.maybe_implemented(stack_lib, 'stack_empty', _Stack, [])

# stack_t stack_destroy(stack_t stack)
stack_destroy = helpers.maybe_implemented(stack_lib, 'stack_destroy', _Stack,
                                          [_Stack])

# stack_t stack_push(stack_t stack, stack_elem_t elem)
stack_push = helpers.maybe_implemented(stack_lib, 'stack_push', _Stack,
                                       [_Stack, _Edge])

# stack_t stack_pop(stack_t stack)
stack_pop = helpers.maybe_implemented(stack_lib, 'stack_pop', _Stack, [_Stack])

# stack_elem_t stack_top(stack_t stack)
stack_top = helpers.maybe_implemented(stack_lib, 'stack_top', _Edge, [_Stack])
예제 #3
0
# ctypes wrapper
heap_lib = helpers.get_lib('heap.so')


# TADs

class __Heap(ctypes.Structure):
    pass


_Heap = ctypes.POINTER(__Heap)


# heap_t heap_empty(unsigned int max_size)
heap_empty = helpers.maybe_implemented(
    heap_lib, 'heap_empty', _Heap, [ctypes.c_uint])


# heap_t heap_destroy(heap_t heap)
heap_destroy = helpers.maybe_implemented(
    heap_lib, 'heap_destroy', _Heap, [_Heap])


# heap_t heap_insert(heap_t heap, heap_elem_t elem)
heap_insert = helpers.maybe_implemented(
    heap_lib, 'heap_insert', _Heap, [_Heap, _Edge])


# heap_t heap_remove_minimum(heap_t heap)
heap_remove_minimum = helpers.maybe_implemented(
    heap_lib, 'heap_remove_minimum', _Heap, [_Heap])
예제 #4
0
# ctypes wrapper
uf_lib = helpers.get_lib('union_find.so')

# TADs


class __UnionFind(ctypes.Structure):
    pass


_UnionFind = ctypes.POINTER(__UnionFind)

# Wrappers

# union_find_t union_find_create(unsigned int max_size)
uf_create = helpers.maybe_implemented(uf_lib, 'union_find_create', _UnionFind,
                                      [ctypes.c_uint])

# union_find_t union_find_destroy(union_find_t uf)
uf_destroy = helpers.maybe_implemented(uf_lib, 'union_find_destroy',
                                       _UnionFind, [_UnionFind])

# union_find_t union_find_push(union_find_t uf, union_find_elem_t elem)
uf_push = helpers.maybe_implemented(uf_lib, 'union_find_push', _UnionFind,
                                    [_UnionFind, ctypes.c_uint])

# union_find_t union_find_union(union_find_t uf,
#                               union_find_class_t class1,
#                               union_find_class_t class2)
uf_union = helpers.maybe_implemented(
    uf_lib, 'union_find_union', _UnionFind,
    [_UnionFind, ctypes.c_uint, ctypes.c_uint])
예제 #5
0
# ctypes wrapper
pq_lib = helpers.get_lib('priority_queue.so')

# TADs


class __PriorityQueue(ctypes.Structure):
    pass


_PriorityQueue = ctypes.POINTER(__PriorityQueue)

# Wrappers

# priority_queue_t priority_queue_empty(unsigned int max_size)
pq_empty = helpers.maybe_implemented(pq_lib, 'priority_queue_empty',
                                     _PriorityQueue, [ctypes.c_uint])

# priority_queue_t priority_queue_destroy(priority_queue_t pq)
pq_destroy = helpers.maybe_implemented(pq_lib, 'priority_queue_destroy',
                                       _PriorityQueue, [_PriorityQueue])

# priority_queue_t priority_queue_enqueue(priority_queue_t pq,
#                                         priority_queue_elem_t elem)
pq_enqueue = helpers.maybe_implemented(pq_lib, 'priority_queue_enqueue',
                                       _PriorityQueue, [_PriorityQueue, _Edge])

# priority_queue_elem_t priority_queue_first(priority_queue_t pq)
pq_first = helpers.maybe_implemented(pq_lib, 'priority_queue_first', _Edge,
                                     [_PriorityQueue])

# priority_queue_t priority_queue_dequeue(priority_queue_t pq)
예제 #6
0
# TADs


class __Dictionary(ctypes.Structure):
    pass


_Dictionary = ctypes.POINTER(__Dictionary)
_Word = ctypes.c_char_p
_Definition = ctypes.c_char_p

# Wrappers

# dict_t dict_empty(void)
dict_empty = helpers.maybe_implemented(dict_lib, 'dict_empty', _Dictionary, [])

# dict_t dict_destroy(dict_t dict)
dict_destroy = helpers.maybe_implemented(dict_lib, 'dict_destroy', _Dictionary,
                                         [_Dictionary])

# unsigned int dict_length(dict_t dict)
dict_length = helpers.maybe_implemented(dict_lib, 'dict_length', ctypes.c_uint,
                                        [_Dictionary])

# bool dict_is_equal(dict_t dict, dict_t other)
dict_is_equal = helpers.maybe_implemented(dict_lib, 'dict_is_equal',
                                          ctypes.c_bool,
                                          [_Dictionary, _Dictionary])

# bool dict_exists(dict_t dict, word_t word)
예제 #7
0
class __Vertex(ctypes.Structure):
    pass


_Vertex = ctypes.POINTER(__Vertex)


class __Edge(ctypes.Structure):
    pass


_Edge = ctypes.POINTER(__Edge)

# vertex_t vertex_create(label_t label)
vertex_create = helpers.maybe_implemented(graph_lib, 'vertex_create', _Vertex,
                                          [ctypes.c_uint])

# vertex_t vertex_destroy(vertex_t vertex)
vertex_destroy = helpers.maybe_implemented(graph_lib, 'vertex_destroy',
                                           _Vertex, [_Vertex])

# vertex_t vertex_copy(vertex_t vertex)
vertex_copy = helpers.maybe_implemented(graph_lib, 'vertex_copy', _Vertex,
                                        [_Vertex])

# label_t vertex_label(vertex_t vertex)
vertex_label = helpers.maybe_implemented(graph_lib, 'vertex_label',
                                         ctypes.c_uint, [_Vertex])

# edge_t edge_create(vertex_t left, vertex_t right, unsigned int weight)
edge_create = helpers.maybe_implemented(graph_lib, 'edge_create', _Edge,
예제 #8
0
import ctypes

import helpers


# ctypes wrapper
sort_lib = helpers.get_lib('sort.so')


# void selection_sort(int *a, unsigned int length);
selection_sort = helpers.maybe_implemented(
    sort_lib, 'selection_sort', None, [helpers.int_ptr, ctypes.c_uint])

# void insertion_sort(int *a, unsigned int length);
insertion_sort = helpers.maybe_implemented(
    sort_lib, 'insertion_sort', None, [helpers.int_ptr, ctypes.c_uint])

# void quick_sort(int *a, unsigned int length);
quick_sort = helpers.maybe_implemented(
    sort_lib, 'quick_sort', None, [helpers.int_ptr, ctypes.c_uint])

# void rand_quick_sort(int *a, unsigned int length);
rand_quick_sort = helpers.maybe_implemented(
    sort_lib, 'rand_quick_sort', None, [helpers.int_ptr, ctypes.c_uint])

# void bubble_sort(int *a, unsigned int length);
bubble_sort = helpers.maybe_implemented(
    sort_lib, 'bubble_sort', None, [helpers.int_ptr, ctypes.c_uint])

# unsigned long int get_comp_counter(void);
get_comp_counter = helpers.maybe_implemented(
예제 #9
0
import list_wrapper

# ctypes wrapper
bst_lib = helpers.get_lib('bst.so')

# TADs


class __BST(ctypes.Structure):
    pass


_BST = ctypes.POINTER(__BST)

# bst_t bst_empty(void);
bst_empty = helpers.maybe_implemented(bst_lib, 'bst_empty', _BST, [])

# bst_t bst_destroy(bst_t bst);
bst_destroy = helpers.maybe_implemented(bst_lib, 'bst_destroy', _BST, [_BST])

# unsigned int bst_length(bst_t bst);
bst_length = helpers.maybe_implemented(bst_lib, 'bst_length', ctypes.c_uint,
                                       [_BST])

# bool bst_is_equal(bst_t bst, bst_t other);
bst_is_equal = helpers.maybe_implemented(bst_lib, 'bst_is_equal',
                                         ctypes.c_bool, [_BST, _BST])

# data_t bst_search(bst_t bst, index_t index);
bst_search = helpers.maybe_implemented(bst_lib, 'bst_search',
                                       base_wrapper._Data,