FastLED 3.9.15
Loading...
Searching...
No Matches

◆ sort() [2/2]

template<typename T>
template<typename Compare>
void fl::list< T >::sort ( Compare comp)
inline

Definition at line 529 of file list.h.

529 {
530 // Insertion sort with custom comparator
531 if (mSize <= 1) {
532 return;
533 }
534
535 Node* sorted_end = mHead->next;
536
537 while (sorted_end->next != mHead) {
538 Node* current = sorted_end->next;
539
540 // Find insertion point in sorted portion
541 Node* insert_pos = mHead->next;
542 while (insert_pos != sorted_end->next && comp(insert_pos->data, current->data)) {
543 insert_pos = insert_pos->next;
544 }
545
546 // If current is already in correct position
547 if (insert_pos == current) {
549 } else {
550 // Remove current from its position
552 // Insert before insert_pos
554 }
555 }
556 }
Node * mHead
Definition list.h:32
void link_before(Node *pos, Node *node)
Definition list.h:69
void unlink(Node *node)
Definition list.h:76
fl::size mSize
Definition list.h:33
A doubly-linked list container.
Definition list.h:21

References fl::list< T >::Node::data, link_before(), mHead, mSize, fl::list< T >::Node::next, and unlink().

+ Here is the call graph for this function: