mod_musicindex
1.4.1
|
Sorting routines. More...
#include "sort.h"
Go to the source code of this file.
Typedefs | |
typedef short(* | inf_ptr )(const mu_ent *const restrict, const mu_ent *const restrict) |
sort function pointer type |
Functions | |
static short | inf_by_rand (const mu_ent *const restrict first, const mu_ent *const restrict second) |
static short | inf_by_track (const mu_ent *const restrict first, const mu_ent *const restrict second) |
static short | inf_by_posn (const mu_ent *const restrict first, const mu_ent *const restrict second) |
static short | inf_by_date (const mu_ent *const restrict first, const mu_ent *const restrict second) |
static short | inf_by_length (const mu_ent *const restrict first, const mu_ent *const restrict second) |
static short | inf_by_bitrate (const mu_ent *const restrict first, const mu_ent *const restrict second) |
static short | inf_by_freq (const mu_ent *const restrict first, const mu_ent *const restrict second) |
Sorts by samplerate. | |
static short | inf_by_size (const mu_ent *const restrict first, const mu_ent *const restrict second) |
static short | inf_by_mtime (const mu_ent *const restrict first, const mu_ent *const restrict second) |
Sorts by mtime. | |
static short | inf_by_artist (const mu_ent *const restrict first, const mu_ent *const restrict second) |
static short | inf_by_album (const mu_ent *const restrict first, const mu_ent *const restrict second) |
static short | inf_by_title (const mu_ent *const restrict first, const mu_ent *const restrict second) |
static short | inf_by_filetype (const mu_ent *const restrict first, const mu_ent *const restrict second) |
static short | inf_by_file (const mu_ent *const restrict first, const mu_ent *const restrict second) |
static short | inf_by_uri (const mu_ent *const restrict first, const mu_ent *const restrict second) |
static short | inf_by_genre (const mu_ent *const restrict first, const mu_ent *const restrict second) |
static short | inf_by_dir (const mu_ent *const restrict first, const mu_ent *const restrict second) |
static short | inf_global (const mu_ent *const first, const mu_ent *const second, const unsigned char *const order) |
void | sort_mergesort (mu_pack *const pack, const unsigned char *const order) |
Sorts the list of musical entries. | |
static short | inf_global (const mu_ent *const first, const mu_ent *const second, const unsigned char *const restrict order) |
Returns the "difference" between 2 entries. |
Variables | |
static const inf_ptr const | sort_order_functions [] |
This array is used in conjonction with mu_config->order which acts as a hash table for the user to specify their desired sort order. |
Sorting routines.
All the functions in this file are time-critical. They will be used very extensively during any module operation.
To ensure stability, inf_by_*() functions must return a <= 0 number if first is equal to second.
Definition in file sort.c.
|
inlinestatic |
Definition at line 370 of file sort.c.
Referenced by inf_global().
|
inlinestatic |
Referenced by sort_mergesort().
|
inlinestatic |
Returns the "difference" between 2 entries.
If one entry is a dir, put it first. If both are, sort them by alpahbetic order. Then, compare according to each different parameter designed.
Optimizations:
This function should be tuned as much as possible, it's the one doing all the dirty work while sorting.
first | The first entry |
second | The second entry |
order | The order hash table for the inf_by functions array |
Definition at line 451 of file sort.c.
References mu_ent::filetype, inf_by_title(), sort_order_functions, and unlikely.
void sort_mergesort | ( | mu_pack *const | pack, |
const unsigned char *const | order | ||
) |
Sorts the list of musical entries.
This is a home-made, non-recursive, mergesort implementation.
It presents several advantages over quicksort:
Given the implementation of inf_global(), directories will always be at the top of the pack.
pack | The pack to be sorted |
order | The order hash table for the inf_by functions array |
Definition at line 181 of file sort.c.
References mu_pack::dirnb, mu_pack::fhead, mu_pack::filenb, mu_ent::filetype, mu_pack::head, inf_global(), likely, and mu_ent::next.
|
static |
This array is used in conjonction with mu_config->order which acts as a hash table for the user to specify their desired sort order.
Definition at line 136 of file sort.c.
Referenced by inf_global().