Algorithms_in_C 1.0.0
Set of algorithms implemented in C.
|
This is a vector implemenation in C. More...
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
Data Structures | |
struct | Vector |
for IO operations More... | |
Functions | |
void | init (Vector *vec, int val) |
This function initilaizes the vector and gives it a size of 1 and initializes the first index to 0. More... | |
void | delete (Vector *vec) |
This function clears the heap memory allocated by the Vector. More... | |
void | clear (Vector *vec) |
This function clears the contents of the Vector. More... | |
int | len (Vector *vec) |
This function returns the length the Vector. More... | |
void | push (Vector *vec, int val) |
This function pushes a value to the end of the Vector. More... | |
int | get (Vector *vec, int index) |
This function get the item at the specified index of the Vector. More... | |
void | set (Vector *vec, int index, int val) |
This function sets an item at the specified index of the Vector. More... | |
int | next (Vector *vec) |
This function gets the next item from the Vector each time it's called. More... | |
void * | begin (Vector *vec) |
This function returns the pointer to the begining of the Vector. More... | |
void | print (Vector *vec) |
This function prints the entire Vector as a list. More... | |
static void | test () |
This function tests the functions used to work with Vectors. More... | |
int | main () |
Main function. More... | |
This is a vector implemenation in C.
A vector is an expandable array.
This vector implementation in C comes with some wrapper functions that lets the user work with data without having to worrying about memory.
void * begin | ( | Vector * | vec | ) |
void clear | ( | Vector * | vec | ) |
This function clears the contents of the Vector.
@params Vector* (a pointer to the Vector struct)
void delete | ( | Vector * | vec | ) |
int get | ( | Vector * | vec, |
int | index | ||
) |
void init | ( | Vector * | vec, |
int | val | ||
) |
This function initilaizes the vector and gives it a size of 1 and initializes the first index to 0.
@params Vector* (a pointer to the Vector struct) @params int (the actual data to be passed to the vector)
int len | ( | Vector * | vec | ) |
int main | ( | void | ) |
Main function.
int next | ( | Vector * | vec | ) |
void print | ( | Vector * | vec | ) |
void push | ( | Vector * | vec, |
int | val | ||
) |
void set | ( | Vector * | vec, |
int | index, | ||
int | val | ||
) |
|
static |
This function tests the functions used to work with Vectors.