11.07.2014 Views

Flute acoustics: measurement, modelling and design - School of ...

Flute acoustics: measurement, modelling and design - School of ...

Flute acoustics: measurement, modelling and design - School of ...

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

APPENDIX B. PROGRAM LISTINGS 303<br />

/*<br />

Vector.h<br />

By Andrew Botros, 2001-2003<br />

Listing B.27: Vector.h<br />

Vector.c is a Vector ADT.<br />

*/<br />

#ifndef VECTOR_H_PROTECTOR<br />

#define VECTOR_H_PROTECTOR<br />

/* Node: { pointer to data struct, pointer to next Node } */<br />

typedef struct Node_str {<br />

void* object;<br />

struct Node_str* next;<br />

} *Node;<br />

/* Vector:<br />

{ size count, pointer to head Node, pointer to tail Node } */<br />

typedef struct Root_str {<br />

int num;<br />

Node head;<br />

Node tail;<br />

} *Vector;<br />

Vector createVector(void);<br />

/*<br />

Initialises a vector with num = 0, head = NULL, tail = NULL.<br />

Returns:<br />

A Vector if successful, NULL otherwise.<br />

*/<br />

void addElement(Vector v, void* object);<br />

/*<br />

Adds a data structure pointer to the end <strong>of</strong> the given vector.<br />

Parameters:<br />

v: the Vector to add to.<br />

object: a pointer to the data structure to be added.<br />

*/<br />

void insertAt(Vector v, void* object, int index);<br />

/*<br />

Inserts a data structure pointer within the given vector at the<br />

given position.<br />

All following pointers in the Vector are shifted right by index +1.<br />

Parameters:<br />

v: the Vector to add to.<br />

object: a pointer to the data structure to be added.<br />

index: the position <strong>of</strong> the inserted pointer (head is index 0).<br />

NOTE: no bounds checking is performed.<br />

*/<br />

void setAt(Vector v, void* object, int index);<br />

/*<br />

Sets the data structure pointer within the given vector at the given

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!