1 / 12
Télécharger la présentation
Dynamic Arrays
An Image/Link below is provided (as is) to download presentation
Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.
Content is provided to you AS IS for your information and personal use only.
Download presentation by click this link.
While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.
During download, if you can't get a presentation, the file might be deleted by the publisher.
E N D
Presentation Transcript
Dynamic Arrays CS580u - Spring 19
Initializing a Vector Classwork
Vector Implementation typedef struct Vector{ int max_size; //initialize to 0 int current_size; //initialize to 0 Data * list; //initialize to NULL void (*insert)(struct * Vector, Data d, int index); void (*remove)(struct * Vector, int index); Data * d (*read)(struct * Vector, int index); } Vector;
Vector insert insert(vector, index, value){ if(index>=vector.max_size) vector.max_size = index * 2; //geometric expansion new_list = array[vector.max_size] copy vector.list -> new_list delete vector.list vector.list = new listif(index >= vector.current_size) vector.current_size = index + 1 vector.list[index] = value }
Deleting From a Vector Classwork
More Related