-
Notifications
You must be signed in to change notification settings - Fork 0
Data data structures #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: empty2
Are you sure you want to change the base?
Conversation
added several stack functions with tests
renamed test files and added in Queue function
…data-structures into day2DataStructures
…data-structures into day2DataStructures
* WIP for PQueue * WIP for PQueue * set WIP * WIP for Set * Linked List
Day2 data structures
added work for several structures
finished linkedList
finished double linked list
mantinone
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry I ran out of time! I can review your tests later if you like.
| insertAfter(item, data) { | ||
| const newNode = new Node(data) | ||
|
|
||
| if (this.find(item) === this.tail { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a syntax error here that had to be fixed before tests could be run. (the if statement is not enclosed)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, you left a couple console logs in here.
| return count | ||
| } | ||
|
|
||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! I would try using your own length function instead of the built in length property, just for the heck of it.
| forEach(func) { | ||
| this.elements = this.elements.map(func) | ||
| return this.elements | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I feel like this should be implemented differently for learning purposes. You have essentially used Map to implement Map.
| return count | ||
| } | ||
|
|
||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
| return index == self.indexOf(element); | ||
| }) | ||
| return unique | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a pretty clever way of doing it.
| } | ||
| return null | ||
| } | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're repeating this "Find the max" "Find the min" code a few times here. It would be a good idea to break these out into helper functions so they don't have to be repeated, and it helps make the code more easily readable, too.
| return this.find(item) !== -1 | ||
| } | ||
|
|
||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good.
| contains(item) { | ||
| return this.find(item) !== -1 | ||
| } | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks Good
jaredatron
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
wow this was a long review.
| @@ -1 +1,3 @@ | |||
| node_modules/ | |||
| lib/ | |||
| .gitignore | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not even sure you can ignore the .gitignore from within the .gitignore itself. That seems paradoxical :p
| _Provide a brief, high-level overview of what the final product (artifact) of this goal is. Include any relevant resources or dependencies here._ | ||
|
|
||
| Base repository for the [Core Data Structures](https://github.com/GuildCrafts/web-development-js/issues/127) goal. | ||
| Write tests and implementations for common data structures. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why change the readme?
| @@ -0,0 +1,156 @@ | |||
| 'use strict'; | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it looks like you've checked in a transpiled version of one of your source files. These generally are not committed.
| @@ -1 +1,3 @@ | |||
| node_modules/ | |||
| lib/ | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lib is in your git ignore but you are still tracking files within lib. git rm -df lib/* and then commit the removal of these files from tracking
| expect(doubleLinkedList.contains('foo')) | ||
| .to.be.true | ||
| expect(doubleLinkedList.contains('tap')) | ||
| .to.equal(false) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.to.be.false ?
| return true | ||
| } | ||
| return false | ||
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove whitespace
|
|
||
| } | ||
|
|
||
| contains(value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
contains(value) {
return this.elements.indexOf(value) !== -1
}|
|
||
| remove(value) { | ||
| if (this.elements.indexOf(value) > 0) { | ||
| return this.elements.splice(this.elements.indexOf(value),1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove(value) {
if (this.contains(value)) return false
this.elements = this.elements.filter(member => member !== value)
return true
}| } | ||
|
|
||
| forEach(func) { | ||
| this.elements = this.elements.map(func) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this would be better
forEach(iterator) {
this.elements.forEach(iterator)
return this
}This would be better for your learning
forEach(iterator) {
for (let i = this.length - 1; i >= 0; i--) {
iterator(this.elements[i], i)
}
return this
}| } | ||
|
|
||
| size() { | ||
| let count = 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for this exercise you should be tracking size so you don't have to rely on the elements array to calculate it
check out this data