Giter Club home page Giter Club logo

lists's Introduction

Lists.h

This library offers the utility of runtime variable length arrays that support items of variable type.

AKA: an auto-resizable array that can hold many different types simultaneously!

Usage

List list = makelist(5); /* Initial size. */
/* makelist(register size_t iniSize) */
placelist(3, &list, sizeof("10"), (void*)"10"); /* Resizes the array pointer to fit the data. */
/* extern char placelist(register size_t index, List* list, register size_t size, void* data) */
/* The 'size' parameter is obsolete and can be used as ID for the user's convenience. */
int i = 10;
void* ip = &i;
pushlist(2, &list, sizeof(i), ip); /* Same as 'placelist' but instead of overriding the data, it pushes all items after the index one slot to the right. */
printf("%s", (char*)list.data[4]); /* 12 */
rmlist(3, &list); /* Removes item at specified index, shifts all items after the index one slot left and returns the removed item pointer. */
/* extern void* rmlist(register size_t index, List* list) */
scanindex(ip, &list); /* index of first occurence of 'ip'. */
/* extern size_t scanindex(const void * const data, const List * const list) */
printf("%s", printlist(&list)); /* print the list. */
/* extern char* printlist(const List* const list)  */

/**
	typedef struct List {
		size_t length;
		size_t* lengths; /* Size of each item */
		void** data; /* Each item... */
	} List;
*/

Make sure to always deallocate all outputs!

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.