CIS 1500 Chapter 11: vector header example

25 views1 pages
#ifndef VECTOR_H
#define VECTOR_H
// struct and typedef declaration for Vector ADT
typedef struct vector_struct {
int* elements;
unsigned int size;
} vector;
// interface for accessing Vector ADT
// Initialize vector
void vector_create(vector* v, unsigned int vectorSize);
// Destroy vector
void vector_destroy(vector* v);
// Resize the size of the vector
void vector_resize(vector* v, unsigned int vectorSize);
// Return pointer to element at specified index
int* vector_at(vector* v, unsigned int index);
// Insert new value at specified index
void vector_insert(vector* v, unsigned int index, int value);
// Insert new value at end of vector
void vector_push_back(vector* v, int value);
// Erase (remove) value at specified index
void vector_erase(vector* v, unsigned int index);
// Return number of elements within vector
int vector_size(vector* v);
#endif
find more resources at oneclass.com
find more resources at oneclass.com
Unlock document

This preview shows half of the first page of the document.
Unlock all 1 pages and 3 million more documents.

Already have an account? Log in

Document Summary

// struct and typedef declaration for vector adt typedef struct vector_struct { int* elements; unsigned int size; // initialize vector void vector_create(vector* v, unsigned int vectorsize); // resize the size of the vector void vector_resize(vector* v, unsigned int vectorsize); // return pointer to element at specified index int* vector_at(vector* v, unsigned int index); // insert new value at specified index void vector_insert(vector* v, unsigned int index, int value); // insert new value at end of vector void vector_push_back(vector* v, int value); // erase (remove) value at specified index void vector_erase(vector* v, unsigned int index); // return number of elements within vector int vector_size(vector* v);

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers