-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Labels
enhancementNew feature or requestNew feature or request
Description
- https://stackoverflow.blog/2017/06/15/developers-use-spaces-make-money-use-tabs/, use spaces instead of tabs.
Line 1 in c9027c5
| #include "node.h" |
- one does not simple use "node.h" without uploading it to GitHub
- use
.hppor.hxxto explicitly state that this is C++ only header file,.hmeans its C compatible header which it's not (you're using templates)
Line 14 in c9027c5
| int size = 0; |
- datatype should be
size_t, you don't want negatives there (make itunsigned long long)
Lines 13 to 18 in c9027c5
| SNode<T>* tptr = head(); | |
| int size = 0; | |
| while(tptr) { | |
| size++; | |
| tptr = tptr->nptr(); | |
| } |
iteris more standard thantptrin STL
Lines 32 to 33 in c9027c5
| if(head()) throw std::underflow_error("Can't get front value. List is empty"); | |
| return head()->val(); |
- Can i use GIF's in GH issuse.
Lines 37 to 39 in c9027c5
| SNode<T>* tptr = head(); | |
| while(tptr->nptr()) tptr->nptr(tptr->nptr); | |
| return tptr->val(); |
- Explain, what's going on here?
Line 46 in c9027c5
| if(idx == 0 || !head()) { |
idx == 0 || !head()is same asidx == 0 or empty()(more easy to understand)
Line 50 in c9027c5
| else if (idx > 0) { |
- Make it size_t, and stop worrying about negative values.
Line 54 in c9027c5
| while(idx_count < idx - 1 && tptr) { |
- Always check pointers first, and then any other condition, it'll save an head-ache later.
Line 64 in c9027c5
| delete new_node; |
- Really, why made it in the first place?
Line 70 in c9027c5
| if(idx < 0) throw std::invalid_argument("index value should be in range [0, size of list]"); |
- But you didn't check for second condition, that is
size of list, confusing...
Line 84 in c9027c5
| while(idx_count < idx - 1 && tptr->nptr()) { |
- simplify the logic here,
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request
Projects
Status
Backlog