Linked Lists b - UAH CPE 212 Fundamentals of Software...

Info icon This preview shows pages 1–6. Sign up to view the full content.

View Full Document Right Arrow Icon
UAH CPE 212 Fundamentals of Software Engineering Agenda Class 11 Linked Lists 2 Linked Lists Application Key Concepts
Image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
UAH CPE 212 Today Last Time First Fundamental Structure, Linked Lists This Time Bagged Again
Image of page 2
UAH CPE 212 Linked List For Bag #ifndef LINK1_H #define LINK1_H #include <stdlib.h> // Provides size_t struct Node { typedef double Item; Item data; Node *link; }; // FUNCTIONS for the linked list toolkit size_t list_length(Node* head_ptr); void list_head_insert(Node*& head_ptr, const Node::Item& entry); void list_insert(Node* previous_ptr, const Node::Item& entry); Node* list_search(Node* head_ptr, const Node::Item& target); Node* list_locate(Node* head_ptr, size_t position); void list_head_remove(Node*& head_ptr); void list_remove(Node* previous_ptr); void list_clear(Node*& head_ptr); void list_copy(Node* source_ptr, Node*& head_ptr, Node*& tail_ptr); void list_piece(Node* start_ptr, Node* end_ptr, Node*& head_ptr, Node*& tail_ptr); #endif
Image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
UAH CPE 212 Bag 3 #ifndef BAG_H #define BAG_H #include <stdlib.h> // Provides size_t and NULL #include "link1.h" // Provides Node struct class Bag { public: // TYPEDEF typedef Node::Item Item; // CONSTRUCTORS and DESTRUCTOR Bag( ); Bag(const Bag& source); ~Bag( ); // MODIFICATION functions void insert(const Item& entry); void remove(const Item& target); void operator +=(const Bag& addend); void operator =(const Bag& source); // CONSTANT functions size_t size( ) const { return many_nodes; } size_t occurrences(const Item& target) const; Item grab( ) const; private: Node *head_ptr; // Head pointer for the list of items size_t many_nodes; // Number of nodes on the list }; //End of Class Bag // NONMEMBER functions for the Bag Bag operator +(const Bag& b1, const Bag& b2); #endif
Image of page 4
UAH CPE 212 Bag 3 2 // FILE: bag3.cxx // CLASS implemented: Bag (see bag3.h for documentation) // INVARIANT for the Bag ADT: // 1. The items in the Bag are stored on a linked list; // 2. The head pointer of the list is stored in the member variable head_ptr; // 3. The total number of items in the list is stored in the member variable // many_nodes.
Image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Image of page 6
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

What students are saying

  • Left Quote Icon

    As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

    Student Picture

    Kiran Temple University Fox School of Business ‘17, Course Hero Intern

  • Left Quote Icon

    I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

    Student Picture

    Dana University of Pennsylvania ‘17, Course Hero Intern

  • Left Quote Icon

    The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

    Student Picture

    Jill Tulane University ‘16, Course Hero Intern