Giter VIP home page Giter VIP logo

c-linked-list's Introduction

C Linked List

Initialization

linked_list_t int_list = linked_list(INTEGER);
linked_list_t double_list = linked_list(DECIMAL);
linked_list_t string_list = linked_list(STRING);
linked_list_t char_list = linked_list(CHARACTER);

Inserting

list_add2top(list, &data);
list_add2base(list, &data);

// exemple
int ival = 1;
double dval = 1.0;
char cval = 'a';
char * sval = "hello";

list_add2top(string_list, sval);
list_add2top(char_list, &cval);
list_add2top(int_list, &ival);
list_add2top(double_list, &dval);

Deleting

list_delete_by_index(list, index);
list_delete_by_value(list, &value);

// exemple
list_delete_by_index(string_list, 1);
list_delete_by_index(char_list, 2);
list_delete_by_index(int_list, 3);
list_delete_by_index(double_list, 4);

list_delete_by_value(string_list, "hello");
list_delete_by_value(char_list, 'g');
list_delete_by_value(int_list, 34);
list_delete_by_value(double_list, 2.71);

Searching

list_get_value_by_index(list, index);
list_get_value_by_value(list, &value);
list_get_node_by_index(list, index);
list_get_node_by_value(list, &value);

// exemple
int ival = int_cast(list_get_value_by_index(int_list, 1));
int dval = double_cast(list_get_value_by_index(double_list, 2));
int cval = char_cast(list_get_value_by_index(char_list, 3));
int sval = string_cast(list_get_value_by_index(string_list, 4));

Iterate

void callback(callback_param_t data);

list_iterate(list, callback);

Manipulating

uint8_t filter(callback_param_t data);
void * mapper(callback_param_t data);

new_list = list_filter(list, filter_function);
new_list = list_filter_nfree(list, filter_function);
new_list = list_map(list, filter_function);
new_list = list_map_nfree(list, mapper_function);

Free Memory

free_list(list);

Functions

node_t node(value_type_t type, void * value, node_t previous, node_t posterior);

void list_iterate(linked_list_t list, void (*callback)(callback_param_t data));

linked_list_t list_filter(linked_list_t list, uint8_t (*test)(callback_param_t data));

linked_list_t list_filter_nfree(linked_list_t list, uint8_t (*test)(callback_param_t data));

linked_list_t list_map(linked_list_t list, void * (*mapper)(callback_param_t data));

linked_list_t list_map_nfree(linked_list_t list, void * (*mapper)(callback_param_t data));

callback_param_t list_get_value_by_index(linked_list_t list, uint32_t index);

callback_param_t list_get_value_by_value(linked_list_t list, void * value);

node_t list_get_node_by_index(linked_list_t list, uint32_t index);

node_t list_get_node_by_value(linked_list_t list, void * value);

void set_node_value(node_t node, value_type_t type, void * data);

linked_list_t linked_list(value_type_t type);

void free_list(linked_list_t list);

void list_add2top(linked_list_t list, void * value);

void list_add2base(linked_list_t list, void * value);

void list_delete_by_index(linked_list_t list, uint32_t index);

void list_delete_by_value(linked_list_t list, void * value);

void list_show_attributes(linked_list_t list);

c-linked-list's People

Contributors

franklopeslr avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.