aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConnor McDowell <[email protected]>2024-03-09 15:17:51 -0800
committerConnor McDowell <[email protected]>2024-03-09 15:17:51 -0800
commited8889834a081b3171bf96e6d94683d55c07f1eb (patch)
treebb9bd671b35b381439fe86ae628656ad2e55a48e
parentadded additional functions (diff)
downloadhomework-8-connormcdowell275-ed8889834a081b3171bf96e6d94683d55c07f1eb.tar.xz
homework-8-connormcdowell275-ed8889834a081b3171bf96e6d94683d55c07f1eb.zip
filling in classes
-rw-r--r--My structures/ContactList.hpp166
1 files changed, 146 insertions, 20 deletions
diff --git a/My structures/ContactList.hpp b/My structures/ContactList.hpp
index b17a9ab..ed3dde0 100644
--- a/My structures/ContactList.hpp
+++ b/My structures/ContactList.hpp
@@ -3,6 +3,9 @@
#include <algorithm>
+// NOTE: ALL USES OF TERM LIST REFER TO A SHORTHAND FORM OF ContactList, NOT AN ACTUAL LIST.
+// ContactList's DATA SAVING IS IN AN ARRAY FORMAT
+
namespace myStructures
{
template<class CList>
@@ -23,26 +26,27 @@ namespace myStructures
void Print() const; // print contact list calling print on each element
size_t Size() const; // return the size of the contact list
- void Append(const CList& data); //
- void Prepend(const CList& data);
- void RemoveLast();
- void RemoveFirst();
- void Extract(const CList& data);
- void InsertAfter(const CList& data, const CList& after);
- void InsertBefore(const CList& data, const CList& before);
- void Clear();
-
- CList& Last();
- CList Last() const;
- CList& First();
- CList First() const;
-
- CList& operator[](const int& index);
- CList operator[](const int& index) const;
- explicit operator bool() const;
-
- bool operator==(const ContactList<C>& rhs) const;
- bool Empty() const;
+ void Append(const CList& data); // add contact to back of list
+ void Prepend(const CList& data); // add contact to the front of the list (add as first)
+ void RemoveLast(); // delete last contact in the list
+ void RemoveFirst(); // delete first contact in the list
+ void Extract(const CList& data); // delete this contact (and return it)
+ void InsertAfter(const CList& data, const CList& after); // insert contact data after 'after' contact. search for specific contact and insert contact after it.
+ void InsertBefore(const CList& data, const CList& before); // same as after, but inserts contact in front of searched contact
+ void Clear(); // deletes all contacts, empties the list, and clears it all.
+
+ CList& Last(); // returning last contact reference in list
+ CList Last() const; // returns copy of the last contact in list
+ CList& First(); // returns first contact reference
+ CList First() const; // returns first contact copy
+
+ CList& operator[](const int& index); // returns contact reference via [] overload
+ CList operator[](const int& index) const; // returns contact copy via [] overload
+ explicit operator bool() const; // overloads ContactList to return true/false as boolean
+ // operator
+
+ bool operator==(const ContactList<CList>& rhs) const; //if(newContactList == oldContactList)
+ bool Empty() const; // is the list empty?
private:
CList* contacts_{ nullptr };
@@ -132,6 +136,128 @@ namespace myStructures
}
template <class CList>
+ void ContactList<CList>::Print() const
+ {
+
+ }
+
+ template <class CList>
+ size_t ContactList<CList>::Size() const
+ {
+
+ }
+
+ template <class CList>
+ void ContactList<CList>::Append(const CList& data)
+ {
+ // Add to the end of the array
+
+ contacts_[size_ - 1] = data;
+
+ // what ifs
+ // what if: end of the array is the beginning (empty)
+ // what if: in the body of the array
+ // what if: end of the array
+ // what if: the array is full
+ }
+
+ template <class CList>
+ void ContactList<CList>::Prepend(const CList& data)
+ {
+
+ }
+
+ template <class CList>
+ void ContactList<CList>::RemoveLast()
+ {
+
+ }
+
+ template <class CList>
+ void ContactList<CList>::RemoveFirst()
+ {
+
+ }
+
+ template <class CList>
+ void ContactList<CList>::Extract(const CList& data)
+ {
+
+ }
+
+ template <class CList>
+ void ContactList<CList>::InsertAfter(const CList& data, const CList& after)
+ {
+
+ }
+
+ template <class CList>
+ void ContactList<CList>::InsertBefore(const CList& data, const CList& before)
+ {
+
+ }
+
+ template <class CList>
+ void ContactList<CList>::Clear()
+ {
+
+ }
+
+ template <class CList>
+ CList& ContactList<CList>::Last()
+ {
+
+ }
+
+ template <class CList>
+ CList ContactList<CList>::Last() const
+ {
+
+ }
+
+ template <class CList>
+ CList& ContactList<CList>::First()
+ {
+
+ }
+
+ template <class CList>
+ CList ContactList<CList>::First() const
+ {
+
+ }
+
+ template <class CList>
+ CList& ContactList<CList>::operator[](const int& index)
+ {
+
+ }
+
+ template <class CList>
+ CList ContactList<CList>::operator[](const int& index) const
+ {
+
+ }
+
+ template <class CList>
+ ContactList<CList>::operator bool() const
+ {
+
+ }
+
+ template <class CList>
+ bool ContactList<CList>::operator==(const ContactList<CList>& rhs) const
+ {
+
+ }
+
+ template <class CList>
+ bool ContactList<CList>::Empty() const
+ {
+
+ }
+
+ template <class CList>
CList* ContactList<CList>::AllocateContactList(const size_t& length)
{
CList* storage = nullptr;