Skip to content

Instantly share code, notes, and snippets.

@ArnonEilat
ArnonEilat / stack.c
Created January 6, 2013 23:02
Very simple stack implementation in C with usage example.
#include <stdio.h>
#include <stdlib.h>
#define FALSE 0
#define TRUE 1
typedef struct {
int info;
} DATA;
@ArnonEilat
ArnonEilat / singlyLinkedList.c
Last active November 10, 2023 21:52
Very simple singly linked list implementation in C with usage example.
#include <stdio.h>
#include <stdlib.h>
typedef struct {
int info;
} DATA;
typedef struct node {
DATA data;
struct node* next;
@ArnonEilat
ArnonEilat / CircularlyLinkedList.c
Created January 6, 2013 23:34
Very simple circularly linked list implementation in C. Usage example included.
#include <stdio.h>
#include <stdlib.h>
typedef struct {
int info;
} DATA;
typedef struct node {
DATA data;
struct node *next;
@ArnonEilat
ArnonEilat / linkedList.c
Created January 6, 2013 23:49
Simple C implementation of linked list with pointer to the first node and pointer the last node. Usage example included.
#include <stdio.h>
#include <stdlib.h>
typedef struct {
int info;
} DATA;
typedef struct node {
DATA data;
struct node * prev;
@ArnonEilat
ArnonEilat / twoDimQS.c
Created January 6, 2013 23:59
Implementation of quick sort to sort an two dimensional array. Usage example included.
#include <stdio.h>
#include <stdlib.h>
#define N 4
void swap(int *a, int *b) {
int temp;
temp = *a;
*a = *b;
*b = temp;
}
@ArnonEilat
ArnonEilat / columnSort.c
Last active December 10, 2015 17:58
Sort of a column in two dimensional array. Usage example included. I will add documentation someday.
#include <stdio.h>
#include <stdlib.h>
#define COLUMNS_NO 3
void sort_column(char matrix[][COLUMNS_NO], int lines_no, int col) {
int i, j;
char temp;
for (i = 0; i < lines_no - 1; i++) {
for (j = 0; j < lines_no - 1 - i; j++) {
@ArnonEilat
ArnonEilat / queue.c
Last active December 2, 2021 00:02
Simple C implementation of queue. Usage example included.
#include <stdlib.h>
#include <stdio.h>
#define TRUE 1
#define FALSE 0
/* a link in the queue, holds the info and point to the next Node*/
typedef struct {
int info;
} DATA;
@ArnonEilat
ArnonEilat / BinarySearchTree.c
Created January 23, 2013 18:17
Simple C implementation of Binary Search Tree. Usage example included.
#include "BinarySearchTree.h"
/*! \fn Tree * add(Tree *nod , int number)
* \param *nod pointer to <tt>Tree</tt> struct.
* \param number a <tt>int</tt> to add.
* \return pointer to <tt>Tree</tt> struct.
*/
Tree * add(Tree* nod, int number) {
if (nod == NULL) {
nod = (Tree*) malloc(sizeof (Tree));
@ArnonEilat
ArnonEilat / Array.prototype.js
Last active December 29, 2015 16:29
Array.prototype.js
Array.prototype.insert = function(index, item) {
this.splice(index, 0, item);
};
/***
* var swapTest=['a','b','c'];
* swapTest.swap('a','c')
* @param {type} first
* @param {type} second
@ArnonEilat
ArnonEilat / d3.js
Created May 10, 2014 14:24
d3 line chart with zoom and domain limit.
!function() {
var d3 = {
version: "3.4.5"
};
if (!Date.now) Date.now = function() {
return +new Date();
};
var d3_arraySlice = [].slice, d3_array = function(list) {
return d3_arraySlice.call(list);
};