@@ -215,12 +215,26 @@ class DSDoublyLL{
215215 DSDoublyLL<T> operator +(const DSDoublyLL<T>& other) const ;
216216
217217 /* *
218- * @brief operator += : combines this
219- * @param other
220- * @return
218+ * @brief operator + : returns a linked list combining this list with the given element
219+ * @param other - reference to given the element
220+ * @return combined linked list of this and given list
221+ */
222+ DSDoublyLL<T> operator +(const T& other) const ;
223+
224+ /* *
225+ * @brief operator += : combines this with the given linked list
226+ * @param other: referrence to the linked list to combine with this
227+ * @return this
221228 */
222229 DSDoublyLL<T>& operator +=(const DSDoublyLL<T>& other);
223230
231+ /* *
232+ * @brief operator += : returns a linked list combining this list with the given element
233+ * @param other - reference to the element to append to this
234+ * @return this
235+ */
236+ DSDoublyLL<T>& operator +=(const T& other);
237+
224238 /* *
225239 * @brief operator == : compares this list against another list
226240 * @param other - reference to target list
@@ -776,6 +790,24 @@ DSDoublyLL<T> DSDoublyLL<T>::operator+(const DSDoublyLL<T>& other) const{
776790 return result;
777791}
778792
793+ /* *
794+ * @brief operator + : returns a linked list combining this list with the given element
795+ * @param data - reference to given the element
796+ * @return combined linked list of this and given list
797+ */
798+ template <class T >
799+ DSDoublyLL<T> DSDoublyLL<T>::operator +(const T& data) const {
800+ DSDoublyLL<T> result;
801+
802+ for (DSNode<T>* current = this ->head ; current != nullptr ; current = current->next ){
803+ result.pushBack (current->data );
804+ }
805+
806+ result.pushBack (data);
807+
808+ return result;
809+ }
810+
779811/* *
780812 * @brief operator += : sets data equal to this and the given doubly linked list
781813 * @param other - the list to be added to this
@@ -790,6 +822,19 @@ DSDoublyLL<T>& DSDoublyLL<T>::operator+=(const DSDoublyLL<T>& other){
790822 return *this ;
791823}
792824
825+ /* *
826+ * @brief operator += : returns a linked list combining this list with the given element
827+ * @param other - reference to the element to append to this
828+ * @return data
829+ */
830+ template <class T >
831+ DSDoublyLL<T>& DSDoublyLL<T>::operator +=(const T& data){
832+ pushBack (data);
833+
834+ return *this ;
835+ }
836+
837+
793838/* *
794839 * @brief operator == : compares this list against another list
795840 * @param other - reference to target list
0 commit comments