Git Product home page Git Product logo

extra-array's Introduction

Generic array in C.

Download: header file.

structure

at : T*
size : size_t

usage

declare

// Declare array type.
// This defines structure and declares functions.
EARRAY_DECLARE(name, type)
// declare int array
EARRAY_DECLARE(AInt, int)

define

// Define array type.
// This defines functions.
EARRAY_DEFINE(name, type)
// define int space
EARRAY_DEFINE(AInt, int)

open

// Open with static memory.
#_open(array, at, size)
// define array and char buffer
AInt o;
char buffer[32];

// open with buffer
AInt_open(&o, buffer, 32/sizeof(int));

// print size of array
printf("%zu", o.size);

// write 0x0BADB055 at last index
o.at[o.size-1] = 0x0BADB055;

openHeap

// Open with heap memory.
#_openHeap(array, size)
// open of size 64
AInt_openHeap(&o, 64);

// print size of array
printf("%zu", o.size);

// write 0x600DB055 at last index
o.at[o.size-1] = 0x600DB055;

close

// Close, if opened with heap memory.
#_close(array)
// close array
AInt_close(&o);

resize

// Resize if opened with heap memory.
#_resize(array, size)
// open of size 128
AInt_openHeap(&o, 128);

// resize to size 256
AInt_resize(&o, 256);

// print size of array
printf("%zu", o.size);

// close array
AInt_close(&o);



cppf

extra-array's People

Contributors

wolfram77 avatar

Stargazers

 avatar

Watchers

 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.