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

◆ sort() [1/2]

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

Definition at line 499 of file list.h.

499 {
500 // Insertion sort for simplicity (appropriate for embedded systems)
501 if (mSize <= 1) {
502 return;
503 }
504
505 Node* sorted_end = mHead->next;
506
507 while (sorted_end->next != mHead) {
508 Node* current = sorted_end->next;
509
510 // Find insertion point in sorted portion
511 Node* insert_pos = mHead->next;
512 while (insert_pos != sorted_end->next && insert_pos->data < current->data) {
513 insert_pos = insert_pos->next;
514 }
515
516 // If current is already in correct position
517 if (insert_pos == current) {
519 } else {
520 // Remove current from its position
522 // Insert before insert_pos
524 }
525 }
526 }
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: