Advertisement
Phr0zen_Penguin

UnsortedLinkedList.h - VTC C++ Unsorted Linked List Header

Apr 19th, 2015
266
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.99 KB | None | 0 0
  1. /**
  2.  * [UnsortedLinkedList.h]
  3.  * The UnsortedLinkedList class declaration/specification.
  4.  */
  5.  
  6. #ifndef UNSORTEDLINKEDLIST_H
  7. #define UNSORTEDLINKEDLIST_H
  8.  
  9. #include <iostream>
  10.  
  11. /**
  12.  * THE Unsorted Linked List NODE STRUCTURE:
  13.  */
  14. struct Node
  15. {
  16.     float   element;    // representing each element in the unsorted linked list
  17.     Node    *next;      // the node connecting each element in the unsorted linked list
  18. };
  19.  
  20.  
  21. /**
  22.  * THE Unsorted Linked List CLASS SPECIFICATION:
  23.  */
  24. class UnsortedLinkedList
  25. {
  26.     /**
  27.      * Everything under public can be accessed by all other programs or classes.
  28.      */
  29.     public:
  30.         /**
  31.          * Constructor(s):
  32.          */
  33.         UnsortedLinkedList();       // the unsorted linked list's default constructor
  34.  
  35.         /**
  36.          * Mutators:
  37.          */
  38.         void InsertItem(float);     // inserts an item into the list
  39.         void DeleteItem(float);     // deletes an item from the list
  40.  
  41.         /**
  42.          * Accessors:
  43.          */
  44.         float GetNextItem(void);    // returns the next item in the list
  45.  
  46.         /**
  47.          * General Use:
  48.          */
  49.         bool IsEmpty(void);             // returns true if the list is empty
  50.         bool IsFull(void);              // returns true if the list is full
  51.         void ResetList(void);           // resets the list (brings the current position back the the beginning)
  52.         void MakeEmpty(void);
  53.         int LengthIs(void);             // returns the length of the list
  54.         bool IsInTheList(float);    // returns true if the provided item is in the list
  55.         void Print(void);
  56.  
  57.     /**
  58.      * Everything under protected can be accessed only by the class itself or (derived) subclasses,
  59.      * as in the case of inheritance.
  60.      */
  61.     protected:
  62.  
  63.     /**
  64.      * (Private) DATA MEMBERS/PROPERTIES:
  65.      *
  66.      * Everything under private can only be accessed by the class itself (the code in the
  67.      * implementation file).
  68.      */
  69.     private:
  70.         Node    *data;              // a pointer to the beginning of the list (that can be used to access the next items)
  71.         int     length;             // the length of the list
  72.         Node    *currentPos;        // the current position of the list
  73. };
  74.  
  75. #endif // UNSORTEDLINKEDLIST_H
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement