-
Notifications
You must be signed in to change notification settings - Fork 19.9k
Create Unrolled Linked List #5835
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
Conversation
A linked list variant that stores multiple elements in each node to improve cache performance.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #5835 +/- ##
============================================
+ Coverage 65.99% 66.00% +0.01%
Complexity 4395 4395
============================================
Files 603 603
Lines 16799 16799
Branches 3226 3226
============================================
+ Hits 11086 11088 +2
+ Misses 5266 5265 -1
+ Partials 447 446 -1 ☔ View full report in Codecov by Sentry. |
private Node head; | ||
private int nodeCapacity; // Maximum capacity of each node | ||
|
||
// Constructor |
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.
Redundant comment. Will be better to remove it.
@@ -0,0 +1,52 @@ | |||
class UnrolledLinkedList { | |||
private Node head; | |||
private int nodeCapacity; // Maximum capacity of each node |
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 will be better move it to javadoc
nodeCapacity = capacity; | ||
} | ||
|
||
// Insert an element at the end |
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 also, will be better to have like javadoc
// Constructor | ||
public UnrolledLinkedList(int capacity) { | ||
head = null; | ||
nodeCapacity = capacity; |
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.
Need to add checking for wrong input.
public UnrolledLinkedList(int capacity) {
if (capacity <= 0) {
throw new IllegalArgumentException("Node capacity must be positive");
}
this.head = null;
this.nodeCapacity = capacity;
}
} | ||
|
||
// Display the unrolled linked list | ||
public void display() { |
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 redundant method because usually standard interface for List
data structure not include it. You can discover standard java List
interface.
@@ -0,0 +1,52 @@ | |||
class UnrolledLinkedList { |
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 is also very useful to have multiple Junit tests.
This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contribution! |
Please reopen this pull request once you have made the required changes. If you need help, feel free to ask in our Discord server or ping one of the maintainers here. Thank you for your contribution! |
A linked list variant that stores multiple elements in each node to improve cache performance.
clang-format -i --style=file path/to/your/file.java