You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@@ -158,11 +158,11 @@ Notice that we didn't have to make any calls to `delete`! The RAII behaviour of
158
158
> ##### `short_answer.txt`
159
159
> **Q3:** This method of recursive deallocation through RAII works great for small lists, but may pose a problem for longer lists. Why? Hint: what is the limit for how "deep" a recursive function's call stack can grow?
160
160
161
-
**Your task is to implement the function`create_list` which converts a `std::vector<T>` into a `unique_ptr<ListNode<T>>`.** The order of elements in the vector should be preserved in the list, and `nullptr` should be returned foran empty vector. There are many ways you could go about this; one is to construct the listin reverse (starting at the tail and working towards the head). Here is an algorithm you should follow in your implementation:
161
+
**Your task is to implement the function`create_list` which converts a `std::vector<T>` into a `unique_ptr<ListNode<T>>`.** The order of elements in the vector should be preserved in the list, and `nullptr` should be returned foran empty vector. There are many ways you could go about this; one is to construct the listin reverse (starting at the tail and working towards the head). **Note that you must use the `cs106l::unique_ptr` under the `cs106l` namespace, and not the `std::unique_ptr`!**Here is an algorithm you should follow in your implementation:
162
162
163
-
1. Initialize a `unique_ptr<ListNode<T>> head = nullptr`.
163
+
1. Initialize a `cs106l::unique_ptr<ListNode<T>> head = nullptr`.
164
164
2. Iterate through the `std::vector`**backwards.** For each element in the vector:
165
-
- 2a. Create a new `unique_ptr<ListNode<T>> node` whose value is the element in the vector.
165
+
- 2a. Create a new `cs106l::unique_ptr<ListNode<T>> node` whose value is the element in the vector.
0 commit comments