示例#1
0
void append_front_value_linked_list(struct linked_list_t *linked_list, void *value) {
    /* allocates space for the linked list node */
    struct linked_list_node_t *linked_list_node;

    /* creates the linked list node */
    create_linked_list_node(&linked_list_node);

    /* sets the value in the linked list node */
    linked_list_node->value = value;

    /* appends (front) the linked list node to the linked list */
    append_front_linked_list(linked_list, linked_list_node);
}
示例#2
0
void append_index_value_linked_list(
    struct linked_list_t *linked_list,
    void *value,
    size_t index
) {
    /* allocates space for a new linked list node and created it
    allocating its memory and starting its structures, then updates
    the value in it and adds the node at the requested index to the
    linked list that was passed as argument */
    struct linked_list_node_t *linked_list_node;
    create_linked_list_node(&linked_list_node);
    linked_list_node->value = value;
    append_index_linked_list(linked_list, linked_list_node, index);
}
示例#3
0
linked_list_node *prime_numbers_less_than(int n) {
  int cur = 3;
  linked_list_node * head = create_linked_list_node(2);

  while ((last_node(head))->data < n) {

    if (cur >= n) {
      break;
    } else if (!list_can_divide_num(head, cur)) {
      printf("%d\n", cur);
      append_to_list(head, cur);
    }

    cur ++;
  }

  return head;
}