---- v21_project_1_linked_lists This just covers a few notes from start ---- v22_stacks_and_queues Stack: First In, Last Out Queuing : First In, First Out Stacks and queues: Our linked list is already a stack It can be a queue too We could keep a pointer to the end, for adding only Why not pop from the end? But is it really the best way? Pointers, and content Linked data structures are more efficient with large items ---- v23_example_stack_use Maze solving example from the game engine ---- v24_fast_enqueue Adding a pointer to the last item Adding an item ot the end in O(1) time And reasons we can't delete from the end in O(1) time A doubly-linked list would allow us to do that But it would have twice as many pointers ---- v25_contiguous_vs_discontiguous Example from game engines where contiguous storage is important General notes on contiguous vs. discontiguous storage ---- v26_dynamic_array_start How would we store data for a dynamic array? new[] / delete[] - no resize - calls constructors mmap + allows easy storage on the hard drive - might or might not work on Windows malloc / realloc / free + has resize + doesn't call constructors, so we can resize - doesn't call destructors, so we might need to do that ourselves Adding methods: push_back operator+= operator[] items ---- v27_dynamic_array_debugging Finding a bug with a debugger: Break where things seem to go wrong Narrow the problem down as far as possible Just one line in this case Look for memory errors, with valgrind in this case It's not the only tool that does that I'm not sure what the visual studio equivalent is Study the line and figure out why it's wrong In this case, size was given to realloc in items instead of bytes ---- v28_dynamic_array_methods More methods: pop_back reserve trim plus operator ---- v29_copy_constructor A copy constructor: It should make a deep copy of the queue If that was unwanted, a reference or pointer should have been used Having two objects that "own" data can be a problem Especially if they have properties that refer to said data ---- v30_dynamic_array_destructors new to place in a specific spot: new (spot) T(old one) About those destructors! destructible demo Store something that has a destructor See if it's called figure out a way to make it be called! ---- Not up yet, probably I'll record the rest of this on Monday Could our dynamic array be a queue? To be a good queue, we need O(1) access to the front Either additions or deletions would be fine We can do this, but we'll need to track the front AND the back Inside our allocation ---- Inheritance demo Alright...a function that can take either queue And is NOT a template function We can inherit from a base "generic_queue" type ---- The midterm next week Create review guide