Skip to content

Instantly share code, notes, and snippets.

@fieldju
Created April 6, 2011 07:43
Show Gist options
  • Save fieldju/905289 to your computer and use it in GitHub Desktop.
Save fieldju/905289 to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include "bst.h"
#include "assert.h"
#include "structs.h"
#include "type.h"
/*----------------------------------------------------------------------------
very similar to the compareTo method in java or the strcmp function in c. it
returns an integer to tell you if the left value is greater then, less then, or
equal to the right value. you are comparing the number variable, letter is not
used in the comparison.
if left < right return -1
if left > right return 1
if left = right return 0
*/
/*Define this function type casting the value of void * to the desired type*/
int compare(TYPE left, TYPE right)
{
struct data *l = (struct data*)left;
struct data *r = (struct data*)right;
if(l->number==r->number)
return 0;
if(l->number<r->number)
return -1;
if(l->number>r->number)
return 1;
return 0;
}
/*Define this function type casting the value of void * to the desired type*/
void print_type(TYPE cVal)
{
struct data *val = (struct data*)cVal;
printf("%d",val->number);
}
@fieldju
Copy link
Author

fieldju commented Apr 6, 2011

needs syntax highlighting

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment