From be79b91b42e0d4c6c30ea1a395cb22a5d5cf86c6 Mon Sep 17 00:00:00 2001 From: Jidong Xiao Date: Tue, 7 Jan 2025 17:20:51 -0500 Subject: [PATCH] renaming labs --- labs/12_hash_tables/README.md | 91 ------- labs/12_hash_tables/good_number.cpp | 23 -- .../test_longest_consecutive_sequence.cpp | 23 -- labs/13_exceptions_inheritance/README.md | 89 ------- labs/13_exceptions_inheritance/cp1/input.txt | 31 --- .../cp2/output_simple.txt | 8 - labs/13_exceptions_inheritance/cp2/simple.txt | 7 - .../cp2/simple_main.cpp | 168 ------------- .../13_exceptions_inheritance/cp2/utilities.h | 120 ---------- labs/13_exceptions_inheritance/cp3/main.cpp | 223 ------------------ labs/13_exceptions_inheritance/cp3/quads.txt | 9 - .../cp3/triangles.txt | 9 - .../images/multiple_inheritance.png | Bin 25098 -> 0 bytes .../images/single_inheritance.png | Bin 14139 -> 0 bytes labs/14_smart_memory/README.md | 72 ------ labs/14_smart_memory/ds_smart_pointers.h | 77 ------ labs/14_smart_memory/main_smart_pointers.cpp | 208 ---------------- labs/14_smart_memory/main_stop_and_copy.cpp | 58 ----- labs/14_smart_memory/stop_and_copy.cpp | 96 -------- labs/14_smart_memory/stop_and_copy.h | 53 ----- 20 files changed, 1365 deletions(-) delete mode 100644 labs/12_hash_tables/README.md delete mode 100644 labs/12_hash_tables/good_number.cpp delete mode 100644 labs/12_hash_tables/test_longest_consecutive_sequence.cpp delete mode 100644 labs/13_exceptions_inheritance/README.md delete mode 100644 labs/13_exceptions_inheritance/cp1/input.txt delete mode 100644 labs/13_exceptions_inheritance/cp2/output_simple.txt delete mode 100644 labs/13_exceptions_inheritance/cp2/simple.txt delete mode 100644 labs/13_exceptions_inheritance/cp2/simple_main.cpp delete mode 100644 labs/13_exceptions_inheritance/cp2/utilities.h delete mode 100644 labs/13_exceptions_inheritance/cp3/main.cpp delete mode 100644 labs/13_exceptions_inheritance/cp3/quads.txt delete mode 100644 labs/13_exceptions_inheritance/cp3/triangles.txt delete mode 100644 labs/13_exceptions_inheritance/images/multiple_inheritance.png delete mode 100644 labs/13_exceptions_inheritance/images/single_inheritance.png delete mode 100644 labs/14_smart_memory/README.md delete mode 100644 labs/14_smart_memory/ds_smart_pointers.h delete mode 100644 labs/14_smart_memory/main_smart_pointers.cpp delete mode 100644 labs/14_smart_memory/main_stop_and_copy.cpp delete mode 100644 labs/14_smart_memory/stop_and_copy.cpp delete mode 100644 labs/14_smart_memory/stop_and_copy.h diff --git a/labs/12_hash_tables/README.md b/labs/12_hash_tables/README.md deleted file mode 100644 index aee8943..0000000 --- a/labs/12_hash_tables/README.md +++ /dev/null @@ -1,91 +0,0 @@ -# Lab 12 — Hash Tables - - - -In this lab, you will practice using std::unordered_set, std::unordered_map, and construct your own separate-chaining-based hash table. - - - -## Checkpoint 1: Using std::unordered_set and std::unordered_map - -*estimate: 15-30 minutes* - -Complete the *isGood* function in this [program](good_number.cpp). This function determines if a number n is good or not. You can assume 1<=n<50000. You must write two versions of the function, one version uses std::unordered_set, the other version uses std::unordered_map. - -A good number is a number defined by the following process: - -- Starting with any positive integer, replace the number by the sum of the squares of its digits. -- Repeat the process until the number equals 1 (where it will stay), or it loops endlessly in a cycle which does not include 1. -- Those numbers for which this process ends in 1 are good. - -Return true if n is a good number, and false if not. Here are some examples: - -```console -Example 1: - -Input: n = 19 -Output: true - -Explanation: -1^2 + 9^2 = 82 -8^2 + 2^2 = 68 -6^2 + 8^2 = 100 -1^2 + 0^2 + 0^2 = 1 -``` - -```console -Example 2: - -Input: n = 2 -Output: false -``` - - - -**To complete this checkpoint**: Show a TA the two versions of your program and the test results. - -## Checkpoint 2: Separate Chaining Hash Table - -*estimate: 30-40 minutes* - - - -Complete the *isGood* function using separate chaining. Do not use any of these: std::unordered_map, std::unordered_set, std::map, std::set. - -**To complete this checkpoint**: Show a TA these additions and the test output. - - -## Checkpoint 3 - -*estimate: 30-40 minutes* - -Form a team of two members. Complete the *longestConsecutive* function in this [program](test_longest_consecutive_sequence.cpp). You must use a separate-chaining-based hash table. Do not use any of these: std::unordered_map, std::unordered_set, std::map, std::set. - -The *longestConsecutive* function takes an unsorted std::vector of integers, and returns the length of the longest consecutive elements sequence. - -```console -Example 1: - -Input: nums = [100,4,200,1,3,2] -Output: 4 -Explanation: The longest consecutive elements sequence is [1, 2, 3, 4]. Therefore its length is 4. -``` - -```console -Example 2: - -Input: nums = [0,3,7,2,5,8,4,6,0,1] -Output: 9 -Explanation: The longest consecutive elements sequence is [0, 1, 2, 3, 4, 5, 6, 7, 8]. Therefore its length is 9. -``` - -**To complete this checkpoint**: Show a TA your program and the test results. - - - diff --git a/labs/12_hash_tables/good_number.cpp b/labs/12_hash_tables/good_number.cpp deleted file mode 100644 index 8034056..0000000 --- a/labs/12_hash_tables/good_number.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include - -bool isGood(int n) { -} - -int main() { - // Test cases - // 2, 4, 5, 6, 17, 18, 20 are not good numbers. - // 1, 7, 10, 13, 19, 23, 28, 68 are good numbers. - - int testCases[] = {2,4,5,6,17,18,20,1,7,10,13,19,23,28,68}; - - for (int n : testCases) { - if (isGood(n)) { - std::cout << n << " is a good number." << std::endl; - } else { - std::cout << n << " is not a good number." << std::endl; - } - } - - return 0; -} - diff --git a/labs/12_hash_tables/test_longest_consecutive_sequence.cpp b/labs/12_hash_tables/test_longest_consecutive_sequence.cpp deleted file mode 100644 index 3bcb50e..0000000 --- a/labs/12_hash_tables/test_longest_consecutive_sequence.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include -#include - -int longestConsecutive(std::vector& nums) { -} - -int main() { - //std::vector nums = {100, 4, 200, 1, 3, 2}; - std::vector nums = {100, 4, 200, 1, 3, 2, 2, 2, 2, 3}; - //std::vector nums = {100, 4, 200, 1, 3, 2, 5, 6}; - //std::vector nums = {0,3,7,2,5,8,4,6,0,1}; - //std::vector nums = {100, 4, 200, 201, 202, 203, 205, 204, 1, 3, 2}; - //std::vector nums = {-3,0,1,2,3,-2,-1,-5}; - int size = nums.size(); - std::cout<< "for vector {"; - for(int i=0;i - -Note how in the single inheritance example below, G only explicitly calls a constructor for F. - -![alt text](images/single_inheritance.png "Single Inheritance") - - - -Label the virtual inheritance paths in your diagram. Hint: 6 of the inheritance arrows will be labeled virtual. - -**To complete this checkpoint**: Present your class inheritance diagram and your shape sketches to one of the TAs. - -## Checkpoint 2: - -*estimate: 20-40 minutes* - -To start the implementation, we’ll focus on just 7 of those shapes: Polygon, Triangle, Quadrilateral, Isosceles Triangle, Equilateral Triangle, Rectangle, and Square. This subset will allow us to initially ignore the multiple inheritance diamond property and the need for virtual inheritance it causes. - -Download the code and initial example: [simple_main.cpp](cp2/simple_main.cpp), [utilities.h](cp2/utilities.h), [simple.txt](cp2/simple.txt), [output_simple.txt](cp2/output_simple.txt). -The program expects 2 command line arguments, the names of the input and output files. Each line of the input file begins with a string name followed by 3 or more 2D coordinate vertices. The output categorizes each shape into one or more classes, and into groups with equal angles, equal edges, and/or a right angle. The provided code includes code to call the constructors of the different classes, generally ordered from most specific/constrained to least specific. For example, the program will try to create a Square with the data first, and only if that constructor fails (throws an exception) then it will try to create a Rectangle. We also include a utilities.h file with a number of simple geometric operations: e.g., calculate the distance between two points, calculate the angle between two edges, and compare two distances or two angles and judge if they are sufficiently close to be called “equal”. Remember that you usually don’t want to check if two floating point numbers are equal; instead, check if the difference is below an appropriate tolerance. - -Create a polygons.h file (and optionally a polygons.cpp file). Create the 7 classes for these shapes deriving classes from the other classes as appropriate. In each constructor write code to check whether the vertices passed in meet the requirements for that shape. Throw an exception if you find a problem. Note: Just throw a value of type integer. The value thrown is unimportant in this program – it will be ignored. - -**To complete this checkpoint**: Compile, run, and debug your program. Study the output and confirm that your program is correctly labeling the shapes in simple.txt. - -## Checkpoint 3: - -*estimate: 20-30 minutes* - -Now tackle the problem of multiple inheritance and the diamond property. Focus on either the [triangles](cp3/triangles.txt) or the [quadrilaterals](cp3/quads.txt) (more challenging). Here is a revised [main.cpp](cp3/main.cpp) for all shapes (comment out the portions you are not implementing). - -In organizing your code for this lab, try to avoid unnecessarily duplicating code. For example, don’t implement the HasARightAngle function in every class. Also, you don’t need to check if the Rectangle has 4 vertices (the constructor for its base class will do that). Instead, allow the derived class to rely on the implementation of that function in its parent class. Similarly, don’t recalculate measurement data if you can deduce information from properties of that shape. For example, when a Rectangle is asked if it HasARightAngle, no calculation is necessary — the answer is guaranteed to be true. - -**To complete this checkpoint**: Be sure to ask your TAs for help if you get stuck. Near the end of lab period show a TA your progress. diff --git a/labs/13_exceptions_inheritance/cp1/input.txt b/labs/13_exceptions_inheritance/cp1/input.txt deleted file mode 100644 index a5164a6..0000000 --- a/labs/13_exceptions_inheritance/cp1/input.txt +++ /dev/null @@ -1,31 +0,0 @@ -black (1,0) (0.5,0.866) (1,1.732) (3,1.732) (3.5,0.866) (3,0) -blue (0,0) (0,1) (1,1) (1,0) -brown (2,0) (0,1) (3,3) -cyan (0,0) (0,2) (1,0) -green (0,0) (0,1) (1,0) -grey (1,0) (1.5,0.866) (1,1.732) (2,1.732) (2.5,0.866) (2,0) -magenta (0,0) (1,1) (4,1) (3,0) -olive (0,0) (1,2) (6,3) (4,0) -orange (0,0) (0,3) (2,3) (2,0) -pink (1,0) (0,2) (4,2) (3,0) -purple (0,0) (0,2) (3,1) -red (0,0) (0.5,0.866) (1,0) -teal (1,0) (0,3) (1,4) (2,3) -white (2,0) (0,1) (3,4) (6,1) (4,0) -yellow (0,1) (2,2) (4,1) (2,0) - - - - - - - - - - - - - - - - diff --git a/labs/13_exceptions_inheritance/cp2/output_simple.txt b/labs/13_exceptions_inheritance/cp2/output_simple.txt deleted file mode 100644 index c4eda00..0000000 --- a/labs/13_exceptions_inheritance/cp2/output_simple.txt +++ /dev/null @@ -1,8 +0,0 @@ -7 Polygon(s): blue brown grey olive orange purple red -3 Triangle(s): brown purple red -2 IsoscelesTriangle(s): purple red -1 EquilateralTriangle(s): red -3 Quadrilateral(s): blue olive orange -2 Rectangle(s): blue orange -1 Square(s): blue -3 Shape(s) with all equal sides: blue grey red diff --git a/labs/13_exceptions_inheritance/cp2/simple.txt b/labs/13_exceptions_inheritance/cp2/simple.txt deleted file mode 100644 index 353859c..0000000 --- a/labs/13_exceptions_inheritance/cp2/simple.txt +++ /dev/null @@ -1,7 +0,0 @@ -blue (0,0) (0,1) (1,1) (1,0) -brown (2,0) (0,1) (3,3) -grey (1,0) (1.5,0.866) (1,1.732) (2,1.732) (2.5,0.866) (2,0) -olive (0,0) (1,2) (6,3) (4,0) -orange (0,0) (0,3) (2,3) (2,0) -purple (0,0) (0,2) (3,1) -red (0,0) (0.5,0.866) (1,0) diff --git a/labs/13_exceptions_inheritance/cp2/simple_main.cpp b/labs/13_exceptions_inheritance/cp2/simple_main.cpp deleted file mode 100644 index d3ebe2d..0000000 --- a/labs/13_exceptions_inheritance/cp2/simple_main.cpp +++ /dev/null @@ -1,168 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -#include "polygons.h" - -// helper function prototypes -Polygon* CreatePolygon(const std::string &name, const std::vector &points); -void OutputStats(const std::vector &polygons, std::ofstream &ostr); - -// ------------------------------------------------------------------------------ - -int main(int argc, char* argv[]) { - - // command line arguments & opening files - if (argc != 3) { - std::cerr << "Usage: " << argv[0] << " input.txt output.txt" << std::endl; - exit(1); - } - std::ifstream istr(argv[1]); - if (!istr) { - std::cerr << "ERROR: could not open " << argv[1] << std::endl; - exit(1); - } - std::ofstream ostr(argv[2]); - if (!ostr) { - std::cerr << "ERROR: could not open " << argv[2] << std::endl; - exit(1); - } - - // the master container of polygons - std::vector polygons; - - // read the input file one line at a time - std::string line; - while (getline(istr,line)) { - std::stringstream ss(line); - std::string name, token; - if (!(ss >> name)) continue; - std::vector points; - while (ss >> token) { - std::stringstream ss2(token); - char c; - double x,y; - ss2 >> c; - assert (c == '('); - ss2 >> x; - ss2 >> c; - assert (c == ','); - ss2 >> y; - ss2 >> c; - assert (c == ')'); - points.push_back(Point(x,y)); - } - assert (points.size() >= 3); - Polygon* p = CreatePolygon(name,points); - // add the new polygon to the master container - polygons.push_back(p); - } - - // write out the statistics - OutputStats(polygons,ostr); - - // delete the dynamically allocated polygons - for (int i = 0; i < polygons.size(); i++) { - delete polygons[i]; - } -} - -// ------------------------------------------------------------------------------ - -// This function determines the most specific type of shape that can -// be created from the sequence of points. It does this by process of -// elimination. Note that the order in which it attempts to create -// the shapes is important. - -Polygon* CreatePolygon(const std::string &name, const std::vector &points) { - Polygon *answer = NULL; - try{ - answer = new EquilateralTriangle(name,points); - } - catch (int) { - try { - answer= new IsoscelesTriangle(name,points); - } - catch (int) { - try { - answer= new Triangle(name,points); - } - catch (int) { - try { - answer= new Square(name,points); - } - catch (int) { - try { - answer= new Rectangle(name,points); - } - catch (int) { - try { - answer= new Quadrilateral(name,points); - } - catch (int) { - answer= new Polygon(name,points); - } - } - } - } - } - } - assert (answer != NULL); - return answer; -} - -// ------------------------------------------------------------------------------ - -// This function prints the output. C++ macros are used to abbreviate -// some repetitive code. The function call-like macros are actually -// replaced using substitution by the preprocessor before the code is -// given to the compiler. (You are not required to understand the -// details of the macros. You do not need to edit this code.) - -void OutputStats(const std::vector &polygons, std::ofstream &ostr) { - - // define and initialize variables -# define InitializeCount(type) std::vector all_##type - InitializeCount(Polygon); - InitializeCount(Triangle); - InitializeCount(IsoscelesTriangle); - InitializeCount(EquilateralTriangle); - InitializeCount(Quadrilateral); - InitializeCount(Rectangle); - InitializeCount(Square); - std::vector equal_sides; - - // count & record the names of shapes in each category - for (std::vector::const_iterator i = polygons.begin(); i!=polygons.end(); ++i) { -# define IncrementCount(type) if (dynamic_cast (*i)) all_##type.push_back((*i)->getName()) - IncrementCount(Polygon); - IncrementCount(Triangle); - IncrementCount(IsoscelesTriangle); - IncrementCount(EquilateralTriangle); - IncrementCount(Quadrilateral); - IncrementCount(Rectangle); - IncrementCount(Square); - if ((*i)->HasAllEqualSides()) equal_sides.push_back((*i)->getName()); - } - - - // output data for each category, sorted alphabetically by the shape's name -# define PrintVector(vecname) std::sort((vecname).begin(),(vecname).end()); \ - for (unsigned int j = 0; j < (vecname).size(); j++) { ostr << " " << (vecname)[j]; } ostr << std::endl -# define PrintCount(type) do { ostr << all_##type.size() << " " #type"(s): "; PrintVector(all_##type); } while (0) - PrintCount(Polygon); - PrintCount(Triangle); - PrintCount(IsoscelesTriangle); - PrintCount(EquilateralTriangle); - PrintCount(Quadrilateral); - PrintCount(Rectangle); - PrintCount(Square); - ostr << equal_sides.size() << " Shape(s) with all equal sides: "; - PrintVector(equal_sides); -} - -// ------------------------------------------------------------------------------ diff --git a/labs/13_exceptions_inheritance/cp2/utilities.h b/labs/13_exceptions_inheritance/cp2/utilities.h deleted file mode 100644 index e0d1ec6..0000000 --- a/labs/13_exceptions_inheritance/cp2/utilities.h +++ /dev/null @@ -1,120 +0,0 @@ -// ========================================= -// -// IMPORTANT NOTE: DO NOT EDIT THIS FILE -// -// ========================================= - -#ifndef _UTILITIES_H_ -#define _UTILITIES_H_ - -#include -#include -#include - -// epsilon values used in comparing the edge lengths & angles between -// edges note that these values are dependent on the precision of -// the coordinates and the overall scale of the objects -#define DISTANCE_EPSILON 0.0001 -#define ANGLE_EPSILON 0.1 - -// ----------------------------------------------------------------- - -// Stores a 2D coordinate -class Point { -public: - Point(double _x, double _y) : x(_x),y(_y) {} - double x; - double y; -}; - -// Stores a 2D vector, constructed from 2 Points -class Vector { -public: - Vector(const Point &a, const Point &b) { dx = b.x-a.x; dy = b.y-a.y; } - double Length() const { return sqrt(dx*dx+dy*dy); } - void Normalize() { - // make this a unit vector (length = 1) - double length = Length(); - if (length < DISTANCE_EPSILON) throw std::string("LENGTH = 0"); - assert (length > DISTANCE_EPSILON); - dx /= length; - dy /= length; - } - // representation - double dx; - double dy; -}; - - -inline std::ostream& operator<< (std::ostream &ostr, const Vector &v) { - ostr << "<" << v.dx << "," << v.dy << ">"; - return ostr; -} - - -// ----------------------------------------------------------------- - -// calculate the length of an edge, the distance between 2 points -inline double DistanceBetween(const Point &a, const Point &b) { - Vector v(a,b); - return v.Length(); -} - -// Calculate the angle at vertex b in degrees, that is, the angle -// between edges ab and bc. This will return a positive number -// measured as the clockwise rotation in the xy plane from point c to -// point a (rotating around point b). -inline double Angle(const Point &a, const Point &b, const Point &c) { - // make unit vector along each of the edges - Vector ba(b,a); ba.Normalize(); - Vector bc(b,c); bc.Normalize(); - // calculate the angle in radians - double dot_product = ba.dx * bc.dx + ba.dy * bc.dy; - - if (dot_product < -1 || dot_product > 1) throw std::string("DOT PRODUCT RANGE"); - - assert (dot_product >= -1 && dot_product <= 1); - float perpDot = ba.dx * bc.dy - ba.dy * bc.dx; - // using atan2 to ensure than we get a signed answer. - double angle_in_radians = atan2(perpDot, dot_product); - // convert to degrees - double answer = angle_in_radians * 180.0 / M_PI; - if (answer < 0) { - answer += 360; - } - assert (answer >= 0 && answer <= 360); - return answer; -} - -// returns true if these two vectors are parallel -inline bool Parallel(const Vector &a, const Vector &b) { - Vector a2 = a; a2.Normalize(); - Vector b2 = b; b2.Normalize(); - double dot_product = a2.dx * b2.dx + a2.dy * b2.dy; - // parallel vectors have dot product == 1 - if (fabs(dot_product) > 1-DISTANCE_EPSILON) return true; - return false; -} - - -// ----------------------------------------------------------------- -// simple functions for angles & sides - -inline bool EqualSides(double a, double b) { - return (fabs(a-b) < DISTANCE_EPSILON); -} - -inline bool EqualAngles(double a, double b) { - assert (a >= 0.0 && a < 360.0); - assert (b >= 0.0 && b < 360.0); - return (fabs(a-b) < ANGLE_EPSILON); -} - -inline bool RightAngle(double a) { - assert (a >= 0.0 && a < 360.0); - return (fabs(a-90.0) < ANGLE_EPSILON); -} - -// ----------------------------------------------------------------- - -#endif diff --git a/labs/13_exceptions_inheritance/cp3/main.cpp b/labs/13_exceptions_inheritance/cp3/main.cpp deleted file mode 100644 index 9c7028e..0000000 --- a/labs/13_exceptions_inheritance/cp3/main.cpp +++ /dev/null @@ -1,223 +0,0 @@ -#include -#include -#include -#include -#include -#include -#include - -#include "polygons.h" - -// helper function prototypes -Polygon* CreatePolygon(const std::string &name, const std::vector &points); -void OutputStats(const std::vector &polygons, std::ofstream &ostr); - -// ------------------------------------------------------------------------------ - -int main(int argc, char* argv[]) { - - // command line arguments & opening files - if (argc != 3) { - std::cerr << "Usage: " << argv[0] << " input.txt output.txt" << std::endl; - exit(1); - } - std::ifstream istr(argv[1]); - if (!istr) { - std::cerr << "ERROR: could not open " << argv[1] << std::endl; - exit(1); - } - std::ofstream ostr(argv[2]); - if (!ostr) { - std::cerr << "ERROR: could not open " << argv[2] << std::endl; - exit(1); - } - - // the master container of polygons - std::vector polygons; - - // read the input file one line at a time - std::string line; - while (getline(istr,line)) { - std::stringstream ss(line); - std::string name, token; - if (!(ss >> name)) continue; - std::vector points; - while (ss >> token) { - std::stringstream ss2(token); - char c; - double x,y; - ss2 >> c; - assert (c == '('); - ss2 >> x; - ss2 >> c; - assert (c == ','); - ss2 >> y; - ss2 >> c; - assert (c == ')'); - points.push_back(Point(x,y)); - } - assert (points.size() >= 3); - Polygon* p = CreatePolygon(name,points); - // add the new polygon to the master container - polygons.push_back(p); - } - - // write out the statistics - OutputStats(polygons,ostr); - - // delete the dynamically allocated polygons - for (int i = 0; i < polygons.size(); i++) { - delete polygons[i]; - } -} - -// ------------------------------------------------------------------------------ - -// This function determines the most specific type of shape that can -// be created from the sequence of points. It does this by process of -// elimination. Note that the order in which it attempts to create -// the shapes is important. - -Polygon* CreatePolygon(const std::string &name, const std::vector &points) { - Polygon *answer = NULL; - try{ - answer = new EquilateralTriangle(name,points); - } - catch (int) { - try { - answer= new IsoscelesRightTriangle(name,points); - } - catch (int) { - try { - answer= new RightTriangle(name,points); - } - catch (int) { - try { - answer= new IsoscelesTriangle(name,points); - } - catch (int) { - try { - answer= new Triangle(name,points); - } - catch (int) { - try { - answer= new Square(name,points); - } - catch (int) { - try { - answer= new Rectangle(name,points); - } - catch (int) { - try { - answer= new Rhombus(name,points); - } - catch (int) { - try { - answer= new Parallelogram(name,points); - } - catch (int) { - try { - answer= new Kite(name,points); - } - catch (int) { - try { - answer= new Trapezoid(name,points); - } - catch (int) { - try { - answer= new Quadrilateral(name,points); - } - catch (int) { - answer= new Polygon(name,points); - } - } - } - } - } - } - } - } - } - } - } - } - assert (answer != NULL); - return answer; -} - -// ------------------------------------------------------------------------------ - -// This function prints the output. C++ macros are used to abbreviate -// some repetitive code. The function call-like macros are actually -// replaced using substitution by the preprocessor before the code is -// given to the compiler. (You are not required to understand the -// details of the macros. You do not need to edit this code.) - -void OutputStats(const std::vector &polygons, std::ofstream &ostr) { - - // define and initialize variables -# define InitializeCount(type) std::vector all_##type - InitializeCount(Polygon); - InitializeCount(Triangle); - InitializeCount(IsoscelesTriangle); - InitializeCount(RightTriangle); - InitializeCount(IsoscelesRightTriangle); - InitializeCount(EquilateralTriangle); - InitializeCount(Quadrilateral); - InitializeCount(Trapezoid); - InitializeCount(Kite); - InitializeCount(Parallelogram); - InitializeCount(Rhombus); - InitializeCount(Rectangle); - InitializeCount(Square); - std::vector equal_sides; - std::vector equal_angles; - std::vector right_angle; - - // count & record the names of shapes in each category - for (std::vector::const_iterator i = polygons.begin(); i!=polygons.end(); ++i) { -# define IncrementCount(type) if (dynamic_cast (*i)) all_##type.push_back((*i)->getName()) - IncrementCount(Polygon); - IncrementCount(Triangle); - IncrementCount(IsoscelesTriangle); - IncrementCount(RightTriangle); - IncrementCount(IsoscelesRightTriangle); - IncrementCount(EquilateralTriangle); - IncrementCount(Quadrilateral); - IncrementCount(Trapezoid); - IncrementCount(Kite); - IncrementCount(Parallelogram); - IncrementCount(Rhombus); - IncrementCount(Rectangle); - IncrementCount(Square); - if ((*i)->HasAllEqualSides()) equal_sides.push_back((*i)->getName()); - if ((*i)->HasAllEqualAngles()) equal_angles.push_back((*i)->getName()); - if ((*i)->HasARightAngle()) right_angle.push_back((*i)->getName()); - } - - // output data for each category, sorted alphabetically by the shape's name -# define PrintVector(vecname) std::sort((vecname).begin(),(vecname).end()); \ - for (unsigned int j = 0; j < (vecname).size(); j++) { ostr << " " << (vecname)[j]; } ostr << std::endl -# define PrintCount(type) do { ostr << all_##type.size() << " " #type"(s): "; PrintVector(all_##type); } while (0) - PrintCount(Polygon); - PrintCount(Triangle); - PrintCount(IsoscelesTriangle); - PrintCount(RightTriangle); - PrintCount(IsoscelesRightTriangle); - PrintCount(EquilateralTriangle); - PrintCount(Quadrilateral); - PrintCount(Trapezoid); - PrintCount(Kite); - PrintCount(Parallelogram); - PrintCount(Rhombus); - PrintCount(Rectangle); - PrintCount(Square); - ostr << equal_sides.size() << " Shape(s) with all equal sides: "; - PrintVector(equal_sides); - ostr << equal_angles.size() << " Shape(s) with all equal angles: "; - PrintVector(equal_angles); - ostr << right_angle.size() << " Shape(s) with a right angle: "; - PrintVector(right_angle); -} - -// ------------------------------------------------------------------------------ diff --git a/labs/13_exceptions_inheritance/cp3/quads.txt b/labs/13_exceptions_inheritance/cp3/quads.txt deleted file mode 100644 index 2bdf20c..0000000 --- a/labs/13_exceptions_inheritance/cp3/quads.txt +++ /dev/null @@ -1,9 +0,0 @@ -blue (0,0) (0,1) (1,1) (1,0) -orange (0,0) (0,3) (2,3) (2,0) -yellow (0,1) (2,2) (4,1) (2,0) -magenta (0,0) (1,1) (4,1) (3,0) -pink (1,0) (0,2) (4,2) (3,0) -teal (1,0) (0,3) (1,4) (2,3) -olive (0,0) (1,2) (6,3) (4,0) - - diff --git a/labs/13_exceptions_inheritance/cp3/triangles.txt b/labs/13_exceptions_inheritance/cp3/triangles.txt deleted file mode 100644 index b623368..0000000 --- a/labs/13_exceptions_inheritance/cp3/triangles.txt +++ /dev/null @@ -1,9 +0,0 @@ -red (0,0) (0.5,0.866) (1,0) -green (0,0) (0,1) (1,0) -cyan (0,0) (0,2) (1,0) -purple (0,0) (0,2) (3,1) -brown (2,0) (0,1) (3,3) - - - - diff --git a/labs/13_exceptions_inheritance/images/multiple_inheritance.png b/labs/13_exceptions_inheritance/images/multiple_inheritance.png deleted file mode 100644 index 3212bbb5f6db6c7eb5823af027e3e1eccadd1a53..0000000000000000000000000000000000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8opC;eJ{*H1sR|PW1C0tFUxQ297yTD*mwvYtClU znoN}Ip|=YaLs!G0we?GH9-<7f=KB`nE*YX2W&$}6CbRBVPZHq-^M7ab2(^)aQ_?oq zf8n+_ZD!qlm`6->w}J5zKy^71=KwWF?kpX!k*viU8+a~^@wr+{H`B5PrfFO zMSkUVYJYLXO2o4@DU#Gvcx z53{XOK}L19=u;6aU6%KhHvJ(ME-@z_WXRRjhcWj%M|t(IQe%zNfSX=N@Lr2L@mF;q zw$OG@1gfU3uVm4^S?##DGUIR8HCjC!a$K-3(L|UUwBZ6<@y;1Xy_WqN97KqhBxre< z_Udx^xsLATD!K%mN6CUaEjVM)?BT?SL{Fyot;#g~>w8vGJ>t3j|ANvd(lp}qwPRYh zdYqn&$M4ZQcevaJH>|S5#59XVvn3h zc%CuuC^Pj_L(LE=C#R5f2TnbDG4bPyDj0{wje;Eh!ss_`#D8B7-#}xXDYZdLUD3&R zAp&juDUX-vhVQ*{yxuY-F%M`! zK&THtr_|(t68Wf7PoC3GQ^T>D)%EpCE-pM$dLCQb+ZH=h#kYj7P%0ko3Gb-m=Xpvgj diff --git a/labs/13_exceptions_inheritance/images/single_inheritance.png b/labs/13_exceptions_inheritance/images/single_inheritance.png deleted file mode 100644 index 9ab52617982bdb67d6796ab3bcabc72d6eec630e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 14139 zcmbuGWmFv9wyu-l?$9*u?(QEh!QI^n(zp}cA-H>>ad&q~(4fIBxVv-v+xw1v_dfUB zA9tJ|HG5Q7^{nn1U2DDbneU2JR+L6T1R{R;@Bu|uMnd(&hmWw34H+I1KTuZ#bRjPv zT~wvTK2%Q<9zu4Ytwa?>KYXZ*M|v@Vf$SqV$>_Lz_<%a__x5qbvDEy-2kvQE2~l-V z!_ze+{n+q#xQlp2>?*pjS{yTsg6t&aJ$CGC4wEkfd-c@Mv328)mS-FttuYhnbtVqQ zrVS*wEeG4oB6NphlByCs22+RG*RLY`*&~C8M~RBv=U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+)f{*)kdQMH1NKp7b z$PjZ*BuF|Y^PXwJF)wyfW#qgm-|U2K$Cy1ErwV9CJQO~_)ET}DoI->Du|pb41^EQN zq@(Q4ET`uNxbUpmPrub7pZX)0Cx6gwpN?l98-gqep@dpCRi?N`bL_k~fJR*Q`jG#+{l}rX7Xe1`fpgs){2oL>Q!i5#Rm$1pfC~0t1lXPZyl@?%ue%;j(u>KDANQ=^ zkFwH*?}<)Rz9!-Zv!2e@IoaCqhN}Q7n2;^Y$~Kx9_<=}c`7zS!$^Kde9Y;cr)hOt5 zj=ixG03R7xEaXIPM`QIGsZy|9-^X{eO(E#vT*86hlc`JnF26?(97?3F7QD1E`eu5U zl1!BaHmBMc!#0`&iaIWBeECc%Q=tupf(3A3WVM{sT*&)nR4?fihPB&}Pe!xZmSbK% z7GMNyF?hhZcg~`)cz6uxod<+uaCEYoq;r_7iA`Hxv7fBAK-Z*t-375};tx2efX9bZ z(s}h|r=;p4VRV~MLniGRiS-0r98^YfHDH^EE5qLsVGq` IW*qdt0G*sXU;qFB diff --git a/labs/14_smart_memory/README.md b/labs/14_smart_memory/README.md deleted file mode 100644 index d56f831..0000000 --- a/labs/14_smart_memory/README.md +++ /dev/null @@ -1,72 +0,0 @@ -# Lab 14 — Garbage Collection & Smart Pointers - -## Checkpoint 0 - -If you haven’t done so already, please complete your course evaluation for Data Structures (your honest & anonymous feedback is very important!). Have the webpage receipt saying “completed” open in your browser to receive credit for Checkpoint 0. - -## Checkpoint 1: - -*estimate: 20-40 minutes* - -For the first checkpoint, download, compile, and run these files: [stop_and_copy.h](stop_and_copy.h), [stop_and_copy.cpp](stop_and_copy.cpp), [main_stop_and_copy.cpp](main_stop_and_copy.cpp) - -In Lecture, we stepped through the Stop and Copy garbage collection algorithm on a small example. -Examine the output of the program to see a computer simulation of this same example. Verify that the -program behaves as we predicted in lecture. - -Continuing with the same example, 3 more nodes have been added and the garbage collector must be run -again. Draw a “box and pointer” diagram (the more usual human-friendly version of the interconnected -node structure with few or no crossing pointer arrows) of the memory accessible from the root pointer after -these 3 nodes are added and work through the Stop and Copy algorithm for this example on paper. When -you are finished, uncomment the simulation and check your work. - -**To complete this checkpoint**: Show (and explain to) one of the TAs your box and pointer diagram. - -## Checkpoint 2: - -*estimate: 20-40 minutes* - -The theme for this checkpoint are the helium filled balloons for the Macy’s Thanksgiving Day parade. These -balloons are held in place by one or more ropes held by people on the ground. Alternately, balloons may -be connected to other balloons that are held by people! People can swap which balloon they are holding -on to, but if everyone holding on to the ropes for a particular balloon lets go, we will have a big problem! -Download, compile, and run these files: [ds_smart_pointers.h](ds_smart_pointers.h) and [main_smart_pointers.cpp](main_smart_pointers.cpp). -Use Dr. Memory or Valgrind to inspect the initial code for memory errors and/or memory leaks. - -Carefully examine the example allocations in the main function of the provided code. Draw simple pictures -to help keep track of which objects have been allocated with new, and which variables currently point to -each dynamically allocated object. - -To fix the memory leaks in this program, you will need to add explicit deallocation for the non-smart pointer -examples (marked CHECKPOINT 2A and 2B). For comparison, the code includes simple examples of smart -pointers for these objects as well! When we know that just one person will hold on to a Balloon at a time -(one owner) we can use a dsAutoPtr (see also the STL auto_ptr or STL unique_ptr, depending on your -version of g++/clang/STL). When multiple people might hold ropes to the same Balloon, we should use a -dsSharedPtr (see also STL shared_ptr or Boost shared_ptr). A shared pointer uses reference counting! -When the last person disconnects from a Balloon using a shared pointer, the Balloon is automatically deleted. - -Re-compile & re-run with the memory debugger to confirm you have fixed the simple leaks. For the final -piece of this checkpoint (marked CHECKPOINT 2C), you must also re-rewrite the interconnected balloon -example to use shared pointers. You will need to modify the Balloon class to use dsSharedPointer as well. - -**To complete this checkpoint**: Explain to your TA the code you needed to add and/or modify to correct -the memory leaks in the provided code. Show your TA the result of the memory debugger on your finished -implementation. - -## Checkpoint 3: - -*estimate: 20-40 minutes* - -For the last checkpoint, let’s consider cyclic balloon structures. A simple example is included at the bottom -of main_smart_pointer.cpp. Draw a diagram of this structure on paper. The provided code has memory -leaks for this example. We could try to re-write this example to use the shared smart pointer. However, a -reference counting smart pointer will still have a problem on this cyclic example. Why? - -Instead, let’s write a helper function to explicitly deallocate a general cyclic structure of Balloon objects. (We -will not use smart pointers for this checkpoint). You should switch back to the original Balloon class (if you -modified it for Checkpoint 2). You will first need to collect all nodes that are reachable from the provided -argument. Make sure that you do not enter an infinite loop when tracing through the structure! You may -find std::set helpful. Once you have identified all of the nodes that are accessible from the input argument, -you can call delete on each Node. Write additional test cases to confirm that your code is debugged. - -**To complete this checkpoint**: Show the TA cyclic memory diagram, your debugged implementation, and the memory debugger output to confirm that your code has no memory errors or leaks. diff --git a/labs/14_smart_memory/ds_smart_pointers.h b/labs/14_smart_memory/ds_smart_pointers.h deleted file mode 100644 index 7f19b7a..0000000 --- a/labs/14_smart_memory/ds_smart_pointers.h +++ /dev/null @@ -1,77 +0,0 @@ -#include - -// ============================================================================== -// basic auto pointer implementation -// see also http://ootips.org/yonat/4dev/smart-pointers.html - -template -class dsAutoPtr { -public: - explicit dsAutoPtr(T* p = NULL) : ptr(p) {} /* prevents cast/conversion */ - ~dsAutoPtr() { delete ptr; } - T& operator*() { return *ptr; } - T* operator->() { return ptr; } -private: - T* ptr; -}; - - -// ============================================================================== -// basic reference counting pointer borrowed from: -// http://www.codeproject.com/Articles/15351/Implementing-a-simple-smart-pointer-in-c - -class ReferenceCount { -public: - ReferenceCount() { count = 0; } - void addReference() { count++; } - int releaseReference() { return --count; } -private: - int count; -}; - - -template -class dsSharedPtr { -public: - dsSharedPtr(T* pValue = NULL) : pData(pValue) { - // Create a new reference counter & increment the count - reference = new ReferenceCount(); - reference->addReference(); - } - dsSharedPtr(const dsSharedPtr& sp) : pData(sp.pData), reference(sp.reference) { - // use the same reference counter, increment the count - reference->addReference(); - } - dsSharedPtr& operator= (const dsSharedPtr& sp) { - if (this != &sp) { - // Decrement the old reference count - // if reference become zero delete the old data - if(reference->releaseReference() == 0) { - delete pData; - delete reference; - } - // Copy the data and reference pointer - // and increment the reference count - pData = sp.pData; - reference = sp.reference; - reference->addReference(); - } - return *this; - } - // destructor - ~dsSharedPtr() { - if (reference->releaseReference() == 0) { - delete pData; - delete reference; - } - } - bool operator== (const dsSharedPtr& sp) { return pData == sp.pData; } - T& operator* () { return *pData; } - T* operator-> () { return pData; } -private: - // REPRESENTATION - T* pData; - ReferenceCount* reference; -}; - -// ============================================================================== diff --git a/labs/14_smart_memory/main_smart_pointers.cpp b/labs/14_smart_memory/main_smart_pointers.cpp deleted file mode 100644 index 709789d..0000000 --- a/labs/14_smart_memory/main_smart_pointers.cpp +++ /dev/null @@ -1,208 +0,0 @@ -#include -#include -#include - -// simple homemade smart pointers -#include "ds_smart_pointers.h" - - -// ==================================================== -// BALLOON: a toy class with dynamically allocated memory -// ==================================================== - -#define MAX_NUM_ROPES 10 - -class Balloon { -public: - // CONSTRUCTOR & DESTRUCTOR - Balloon(const std::string& name_) : name(name_) { - std::cout << "Balloon constructor " << name << std::endl; - num_ropes = 0; - ropes = new Balloon*[MAX_NUM_ROPES]; - } - ~Balloon() { - std::cout << "Balloon destructor " << name << std::endl; - // don't try to destroy attached balloons, just delete array - delete [] ropes; - } - - // ACCESSORS - const std::string& getName() const { return name; } - int numRopes() const { return num_ropes; } - const Balloon* getRope(int i) const { return ropes[i]; } - - // print the balloons we are attached to - void print() { - std::cout << "Balloon " << name << " is connected to: "; - for (int i = 0; i < num_ropes; i++) { - std::cout << ropes[i]->name << " "; - } - if (num_ropes == 0) std::cout << "nothing"; - std::cout << std::endl; - } - // add a rope connecting this balloon to another - void addRope(Balloon* b) { - assert (num_ropes < MAX_NUM_ROPES); - ropes[num_ropes] = b; - num_ropes++; - } - // detach a rope connecting this balloon to another - void removeRope(Balloon* b) { - for (int i = 0; i < MAX_NUM_ROPES; i++) { - if (ropes[i] == b) { ropes[i] = ropes[num_ropes-1]; num_ropes--; break; } - } - } - -private: - std::string name; - int num_ropes; - // a dynamically allocated C-style array of ropes connecting to other Balloons - Balloon** ropes; -}; - - -// ==================================================== -// ==================================================== - -int main() { - - std::cout << "start of main" << std::endl; - - // ==================================================== - // SINGLE OWNER SMART POINTERS - // ==================================================== - - // first, without smart pointers! - Balloon* alice(new Balloon("Hello Kitty")); - - // now, with our homemade single owner smart pointer - dsAutoPtr bob(new Balloon("Spiderman")); - - // both alice & bob work like regular pointers... - alice->print(); - bob->print(); - - - - // - // CHECKPOINT 2A: INSERT NECESSARY EXPLICIT DEALLOCATION - // - - - - // ==================================================== - // SIMPLE SHARED POINTERS - // ==================================================== - - // first, without smart pointers - Balloon* cathy(new Balloon("Buzz Lightyear")); - Balloon* daniel(cathy); - Balloon* elaine(new Balloon("Pokemon")); - Balloon* fred(elaine); - daniel = fred; - fred = NULL; - elaine = cathy; - cathy = NULL; - - - - // - // CHECKPOINT 2B: INSERT NECESSARY EXPLICIT DEALLOCATION - // - - - - daniel = NULL; - elaine = NULL; - - - // now, with our homemade shared pointer - dsSharedPtr cathy2(new Balloon("Buzz Lightyear2")); - dsSharedPtr daniel2(cathy2); - dsSharedPtr elaine2(new Balloon("Pokemon2")); - dsSharedPtr fred2(elaine2); - daniel2 = fred2; - fred2 = NULL; - elaine2 = cathy2; - cathy2 = NULL; - // NOTE: no explicit destruction required! - daniel2 = NULL; - elaine2 = NULL; - - - // ==================================================== - // SHARED POINTERS WITH INTERCONNECTED STRUCTURES - // ==================================================== - - Balloon* georgette(new Balloon("Mr Potato Head")); - Balloon* henry(new Balloon("Snoopy")); - - georgette->addRope(henry); - henry = new Balloon("Tigger"); - georgette->addRope(henry); - georgette->print(); - henry->print(); - - Balloon* isabelle(new Balloon("Shrek")); - henry->addRope(isabelle); - isabelle = new Balloon("Barney the Purple Dinosaur"); - georgette->addRope(isabelle); - - henry->print(); - georgette->print(); - isabelle->print(); - - - // - // CHECKPOINT 2C: REWRITE THE ABOVE EXAMPLE TO USE SHARED POINTERS - // - - - - // ==================================================== - // CYCLIC STRUCTURES - // ==================================================== - - - // FOR CHECKPOINT 3 - - - /* - Balloon* jacob(new Balloon("Dora the Explorer")); - Balloon* katherine(new Balloon("Kung Fu Panda")); - Balloon* larry(new Balloon("Scooby Doo")); - Balloon* miranda(new Balloon("SpongeBob SquarePants")); - Balloon* nicole(new Balloon("Papa Smurf")); - - jacob->addRope(katherine); - katherine->addRope(larry); - larry->addRope(jacob); - miranda->addRope(jacob); - nicole->addRope(miranda); - larry->addRope(nicole); - - katherine = NULL; - larry = NULL; - miranda = NULL; - nicole = NULL; - - // jacob points to a cyclic structure! - - // to cleanup this structure: - deleteAll(jacob); - - jacob = NULL; - */ - - - - std::cout << "end of main" << std::endl; - return 0; - - // - // NOTE: when smart pointers go out of scope, the destructors for - // those objects will be called automatically - // -} - -// ==================================================== diff --git a/labs/14_smart_memory/main_stop_and_copy.cpp b/labs/14_smart_memory/main_stop_and_copy.cpp deleted file mode 100644 index 80e62e5..0000000 --- a/labs/14_smart_memory/main_stop_and_copy.cpp +++ /dev/null @@ -1,58 +0,0 @@ -#include -#include -#include "stop_and_copy.h" - - -int main() { - - StopAndCopy m; - std::cout << "TESTING StopAndCopy" << std::endl; - std::cout << std::endl << "empty memory:" << std::endl << m; - - // create an interesting data structure - m.root = m.my_new('a',MY_NULL,MY_NULL); - m.my_new('b',MY_NULL,m.root); - m.root = m.my_new('c',m.root,MY_NULL); - m[m.root].right = m.my_new('d',m[m.root].left,MY_NULL); - - std::cout << std::endl << "4 cells allocated:" << std::endl << m; - - m.root = m.my_new('e',MY_NULL,m.root); - m[m.root].right = m.my_new('f',m[m.root].right,MY_NULL); - m[m[m.root].right].right = m.my_new('g',m[m.root].right,MY_NULL); - m.root = m.my_new('h',m.root,MY_NULL); - m.root = m[m[m.root].left].right; - - std::cout << std::endl << "8 cells allocated:" << std::endl << m; - - // force garbage collection - m.collect_garbage(); - std::cout << std::endl << "after forced garbage collection:" << std::endl << m; - - // allocate more cells to force garbage collection - m[m.root].left = m.my_new('i',m.root,MY_NULL); - m.root = m.my_new('j',m.root,MY_NULL); - m.root = m.my_new('k',m.root,MY_NULL); - - std::cout << std::endl << "after adding 3 more cells:" << std::endl << m; - - - // Walk through the Stop And Copy garbage collection algorithm on - // the memory at this point in the program. Draw a pencil & paper - // diagram to show your work. - - - // UNCOMMENT THESE LINES AFTER YOU FINISH CHECKPOINT 1 (to check your work) - /* - m.root = m.my_new('l',m.root,MY_NULL); - std::cout << std::endl << "adding another cell triggers automatic garbage collection:" << std::endl << m; - - // "forget" the root pointer - m.root = MY_NULL; - m.collect_garbage(); - std::cout << std::endl << "root set to null & forced garbage collection:" << std::endl << m; - */ - -} - -// ============================================================================== diff --git a/labs/14_smart_memory/stop_and_copy.cpp b/labs/14_smart_memory/stop_and_copy.cpp deleted file mode 100644 index 5c4b90c..0000000 --- a/labs/14_smart_memory/stop_and_copy.cpp +++ /dev/null @@ -1,96 +0,0 @@ -#include "stop_and_copy.h" - - -// Return the node corresponding to a particular address -Node& StopAndCopy::operator[](Address addr) { - if (addr == MY_NULL) { - std::cerr << "ERROR: NULL POINTER EXCEPTION!" << std::endl; exit(1); } - if (addr < OFFSET || addr >= OFFSET+CAPACITY) { - std::cerr << "ERROR: SEGMENTATION FAULT!" << std::endl; exit(1); } - return memory[addr-OFFSET]; -} - - -Address StopAndCopy::my_new(char v, Address l, Address r) { - // if we are out of memory, collect garbage - if (next == partition_offset+CAPACITY/2) { - collect_garbage(); - // update the addresses (since memory has been shuffled!) - if (l != MY_NULL) l = memory[l-OFFSET].left; - if (r != MY_NULL) r = memory[r-OFFSET].left; - } - // if we are still out of memory, we can't continue - if (next == partition_offset+CAPACITY/2) { - std::cerr << "ERROR: OUT OF MEMORY!" << std::endl; exit(1); } - // assign the next available node - memory[next].value = v; - memory[next].left = l; - memory[next].right = r; - return OFFSET + next++; -} - - -// Print function for debugging -std::ostream& operator<<(std::ostream &ostr, StopAndCopy &m) { - ostr << "root-> " << m.root << std::endl; - for (int i = 0; i < CAPACITY; i++) { - ostr.width(4); ostr << i+OFFSET << " "; } - ostr << std::endl; - for (int i = 0; i < CAPACITY; i++) { - ostr << " "; ostr.width(1); ostr << m.memory[i].value << " "; } - ostr << std::endl; - for (int i = 0; i < CAPACITY; i++) { - ostr.width(4); ostr << m.memory[i].left << " "; } - ostr << std::endl; - for (int i = 0; i < CAPACITY; i++) { - ostr.width(4); ostr << m.memory[i].right << " "; } - ostr << std::endl; - // print "FREE" or "used" for each node in the current partition - for (int i = 0; i < CAPACITY; i++) { - if (i >= m.next && i < m.partition_offset+CAPACITY/2) - ostr << "FREE "; - else if (i >= m.partition_offset && i < m.partition_offset+CAPACITY/2) - ostr << "used "; - else // print nothing for the other half of memory - ostr << " "; } - ostr << std::endl; - return ostr; -} - - -void StopAndCopy::collect_garbage() { - // switch to the other partition - partition_offset = (partition_offset == 0) ? CAPACITY/2 : 0; - // scan & next start at the beginning of the new partition - Address scan; - next = scan = partition_offset; - // copy the root - copy_help(root); - // scan through the newly copied nodes - while (scan != next) { - // copy the left & right pointers - copy_help(memory[scan].left); - copy_help(memory[scan].right); - scan++; - } -} - - -void StopAndCopy::copy_help(Address &old) { - // do nothing for NULL Address - if (old == MY_NULL) return; - // look for a valid forwarding address to the new partition - int forward = memory[old-OFFSET].left; - if (forward-OFFSET >= partition_offset && - forward-OFFSET < partition_offset+CAPACITY/2) { - // if already copied, change pointer to new address - old = forward; - return; - } - // otherwise copy it to a free slot and leave a forwarding address - memory[next] = memory[old-OFFSET]; - memory[old-OFFSET].left = next+OFFSET; - old = next+OFFSET; - next++; -} - diff --git a/labs/14_smart_memory/stop_and_copy.h b/labs/14_smart_memory/stop_and_copy.h deleted file mode 100644 index 4523bb2..0000000 --- a/labs/14_smart_memory/stop_and_copy.h +++ /dev/null @@ -1,53 +0,0 @@ -#include - -// size of memory available for this process -#define CAPACITY 16 -// first valid address for this process -#define OFFSET 100 -#define MY_NULL 0 - - -typedef int Address; - - -// A helper class for the StopAndCopy memory system -class Node { -public: - Node() { value='?'; left=-1; right=-1; } // initialized with "garbage" values - char value; - Address left; - Address right; -}; - - -// A simple implementation of the basic StopAndCopy garbage collector -class StopAndCopy { -public: - StopAndCopy() { - root = MY_NULL; - partition_offset = 0; - next = 0; - } - // Return the node corresponding to a particular address - Node& operator[](Address addr); - // allocate a new node - Address my_new(char v, Address l, Address r); - // a print function for debugging - friend std::ostream& operator<<(std::ostream &ostr, StopAndCopy &m); - // force automatic memory management - void collect_garbage(); - // REPRESENTATION -public: - // the user must set this value such that all useful memory is - // reachable starting from root (NOTE: publicly accessible) - Address root; -private: - // total machine memory - Node memory[CAPACITY]; - // which half of the memory is active - int partition_offset; - // next available node - int next; - // a private helper function - void copy_help(Address &old_address); -};