Monday, 2 November 2015

Session 6

Shared pointers - access same memory with different pointers
A weak pointer checks if the data that a shared pointer points to is valid

Casting is making a variable act like a different type of variable (for one single operation), for example, you can tell the computer to interpret a number as a char instead. The char output should be the equivalent of the number... based on ASCII value?
Implicit (implied) conversions are automatically performed when a value is copied to a compatible type

Libraries are good because they're made by the experts; saves time and effort

When a vector is created, 3 pointers are also made - a beginning, end and last used. Example: array of size 10, 1-7 are in use. There will be pointers to 1, 10 and 7 as beginning end and last (in that order).
Size vs capacity - the size is the number of objects, whereas capacity is how much space there is for objects altogether
Consider using vectors instead of arrays as they are fast and efficient, but similar to use (ease)

A contiguous memory block benefits caching and prevents fragmentation
An iterator is any object that points to an element in a container, like ++ and -- (increment and decrement)

Erase-remove process, must do both. Remove-erase is the correct order...
Linked list - loads of nodes that link to each other
Linked list can go backwards and forwards
Memory is allocated node by node, and can be assigned anywhere but if it isn't contiguous it might end up going to RAM (which is slower)
As long as there are pointers to the next item, that item can be anything at all
Removal - nodes removed have their memory location automatically deallocated
Easy to add or remove new items by breaking chains within linked lists
Link lists are good for performance as there is no overhead other than the allocation/deallocation
Adding and removing new items is easy because other items don't have to be shifted left or right

Double-ended containers can be expanded or contracted at either end
They are similar to vectors but items may be modified at the front and end
Efficient for adding/removing new items
Memory is not guaranteed to be contiguous.

No comments:

Post a Comment