Skip to content

Some nitpicking, more nitpicking. #1

@nyx-4

Description

@nyx-4
  1. https://stackoverflow.blog/2017/06/15/developers-use-spaces-make-money-use-tabs/, use spaces instead of tabs.

#include "node.h"

  1. one does not simple use "node.h" without uploading it to GitHub
  2. use .hpp or .hxx to explicitly state that this is C++ only header file, .h means its C compatible header which it's not (you're using templates)

int size = 0;

  1. datatype should be size_t, you don't want negatives there (make it unsigned long long)

dstruct/slist.cpp

Lines 13 to 18 in c9027c5

SNode<T>* tptr = head();
int size = 0;
while(tptr) {
size++;
tptr = tptr->nptr();
}

  1. iter is more standard than tptr in STL

dstruct/slist.cpp

Lines 32 to 33 in c9027c5

if(head()) throw std::underflow_error("Can't get front value. List is empty");
return head()->val();

  1. Can i use GIF's in GH issuse.
Image

dstruct/slist.cpp

Lines 37 to 39 in c9027c5

SNode<T>* tptr = head();
while(tptr->nptr()) tptr->nptr(tptr->nptr);
return tptr->val();

  1. Explain, what's going on here?

if(idx == 0 || !head()) {

  1. idx == 0 || !head() is same as idx == 0 or empty() (more easy to understand)

else if (idx > 0) {

  1. Make it size_t, and stop worrying about negative values.

while(idx_count < idx - 1 && tptr) {

  1. Always check pointers first, and then any other condition, it'll save an head-ache later.

delete new_node;

  1. Really, why made it in the first place?

if(idx < 0) throw std::invalid_argument("index value should be in range [0, size of list]");

  1. But you didn't check for second condition, that is size of list, confusing...

while(idx_count < idx - 1 && tptr->nptr()) {

  1. simplify the logic here,

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

Status

Backlog

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions