aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorConnor McDowell <[email protected]>2024-03-09 13:24:47 -0800
committerConnor McDowell <[email protected]>2024-03-09 13:24:47 -0800
commit9c9dc65c8539b773ed40282176842f5566c1349a (patch)
treea0d35ceaad87110cd3c01dd4aa8a300f890edf53
parentcontinuing work (diff)
downloadhomework-8-connormcdowell275-9c9dc65c8539b773ed40282176842f5566c1349a.tar.xz
homework-8-connormcdowell275-9c9dc65c8539b773ed40282176842f5566c1349a.zip
added additional functions
-rw-r--r--My structures/ContactList.hpp67
1 files changed, 48 insertions, 19 deletions
diff --git a/My structures/ContactList.hpp b/My structures/ContactList.hpp
index 61e5e7c..b17a9ab 100644
--- a/My structures/ContactList.hpp
+++ b/My structures/ContactList.hpp
@@ -9,23 +9,47 @@ namespace myStructures
class ContactList
{
public:
- ContactList() = default;
- ContactList(size_t length); //Creates contact list of this size
- ContactList(const CList* contacts, const size_t& length); //Makes a copy of another contact list
- ~ContactList();
+ ContactList() = default;
+ ContactList(size_t length); //Creates contact list of this size
+ ContactList(const CList* contacts, const size_t& length); //Makes a copy of another contact list
+ ~ContactList();
- ContactList(const ContactList& copy); //deep copy constructor
- ContactList& operator=(const ContactList& rhs); //deep copy assignment
+ ContactList(const ContactList& copy); //deep copy constructor
+ ContactList& operator=(const ContactList& rhs); //deep copy assignment
- ContactList(ContactList&& move) noexcept; //reference(move) constructor
- ContactList& operator=(ContactList&& rhs) noexcept; //reference(move) assignment
+ ContactList(ContactList&& move) noexcept; //reference(move) constructor
+ ContactList& operator=(ContactList&& rhs) noexcept; //reference(move) assignment
+
+ 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;
- private:
- CList* contacts_{ nullptr };
- size_t length_{ 0 }; // entire length of array
- size_t size_{ 0 }; // number of actual elements
+ private:
+ CList* contacts_{ nullptr };
+ size_t length_{ 0 }; // entire length of array
+ size_t size_{ 0 }; // number of actual elements
- CList* AllocateContactList(const size_t& length);
+ CList* AllocateContactList(const size_t& length);
};
@@ -93,7 +117,18 @@ namespace myStructures
template <class CList>
ContactList<CList>& ContactList<CList>::operator=(ContactList&& rhs) noexcept
{
+ if(this!= &rhs)
+ {
+ delete[] contacts_;
+ contacts_ = nullptr;
+ contacts_ = rhs.contacts_;
+ length_ = rhs.length_;
+ size_ = rhs.size_;
+
+ rhs.contacts_ = nullptr;
+
+ }
}
template <class CList>
@@ -108,10 +143,4 @@ namespace myStructures
return storage;
}
}
-
-
-
-
-
-
#endif CONTACT_LIST_HPP \ No newline at end of file