ivanseidel / ivanseidel/LinkedList
Added swap(index, index1) method
- Dominant language
- C++
- Stars
- 364
- Forks
- 117
- PR merge metrics
- No merged PRs in 30d
Description
Added swap method as follow:
```
/*
Swap objects at index and index1;
*/
virtual bool swap(int index, int index1);
```
```
template
bool LinkedList::swap(int index, int index1){
// Check if index position is in bounds
if(index < 0 || index >= _size)
return false;
if(index1 < 0 || index1 >= _size)
return false;
T _t = getNode(index)->data;
getNode(index)->data = getNode(index1)->data;
getNode(index1)->data = _t;
return true;
}
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by locating the LinkedList class and its existing indexed-access behavior, then review how getNode and bounds checks are handled. Confirm that swap(index, index1) exchanges the two stored objects, rejects either out-of-range index, and reports success or failure consistently with the shown interface.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- embedded-iot
- Issue type
- Feature
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100