Giter Club home page Giter Club logo

deque's Introduction

Deque

Header

DEQUE is a macro will automatically defines 2 new types: and COLLECTION type and a ELEMENT type. The names for these types is specified by the variable names of the first two parameters to the DEQUE macro call, respectively. For example:

DEQUE(collectionName, elementName);

In addition to a COLLECTION name and an ELEMENT name, any number of optional variable declarations can be provided to DEQUE. These variable declarations describe the ELEMENT's fields / represent the values that the ELEMENT type will have in its struct. Declarations should be delimited / terminated with a ;

In the following example, we'll name our COLLECTION type 'itemList' and our ELEMENT type 'item'. In addition, each 'item' ELEMENT will have an integer field called value and a float field called weight:

import "deque.h"

DEQUE(itemList,
      item,
      int value; // item->value items have a an int value member
      float weight; // item->weight items have a float weight member
      );

Application

Once a new DEQUE macro has completed and its types (the COLLECTION and ELEMENT) have been created, it can be used within an application by using the following API:

Method Description
COLLECTION_new() Create and Intantiate / Allocate a new COLLECTION
COLLECTION_add(ELEMENT) Push a ELEMENT## at the head of the Deque (like stack)
COLLECTION_push(ELEMENT) Push a ELEMENT## at the tail of the Deque (like queue)

Example

In the example/ directory, the following working example is provided:

include "item.h"

int main(int argc, char *argv[])
{
  itemDequeue ideq = new_itemDequeue();
  item i = new_item();
  i->value = 4;
  itemDequeue_add(ideq, i);
  itemDequeue_print(ideq);
  return 1;
}

TODO

Soon, the COLLECTIONS will have map and reduce inline function which accepts a lambda (a void* function pointer) enabling them to be suitable for functional programming.

deque's People

Contributors

mekarpeles avatar

Stargazers

 avatar

Watchers

 avatar  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.