mirror of
https://github.com/SpacehuhnTech/esp8266_deauther.git
synced 2025-12-23 15:38:18 -08:00
Updated SimpleList
This commit is contained in:
@@ -282,6 +282,17 @@ void SimpleList<T>::swap(int x, int y){
|
||||
y = h;
|
||||
}
|
||||
|
||||
// When data is small, copy it
|
||||
if(sizeof(T) < 24){
|
||||
Node<T>* nodeA = getNode(x);
|
||||
Node<T>* nodeB = getNode(y);
|
||||
T h = nodeA->data;
|
||||
nodeA->data = nodeB->data;
|
||||
nodeB->data = h;
|
||||
}
|
||||
|
||||
// otherwise change the pointers
|
||||
else {
|
||||
// Example: a -> b -> c -> ... -> g -> h -> i
|
||||
// we want to swap b with h
|
||||
Node<T>* nodeA = getNode(x - 1); // x.prev
|
||||
@@ -313,6 +324,7 @@ void SimpleList<T>::swap(int x, int y){
|
||||
nodeG->next = nodeB;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
template<typename T>
|
||||
void SimpleList<T>::sort(bool (*cmp)(T &a, T &b)) {
|
||||
|
||||
Reference in New Issue
Block a user