Skip to content
Snippets Groups Projects
Commit f18f8a08 authored by steffeno's avatar steffeno
Browse files

sorting ex. 2

parent e0e860ba
No related branches found
No related tags found
No related merge requests found
apps_targets += sort_playlist
sort_playlist: sort_playlist.o playlist.o
/* vim: set tabstop=4 expandtab shiftwidth=4 softtabstop=4: */
/**
* \file apps/playlist.c
*
* \brief Implementation of a type to represent playlists.
*
* \author Your Name
*
* \copyright 2015 University of Piemonte Orientale, Computer Science Institute
*
* This file is part of UPOalglib.
*
* UPOalglib is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* UPOalglib is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with UPOalglib. If not, see <http://www.gnu.org/licenses/>.
*/
#include <assert.h>
#include "playlist.h"
#include <stddef.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <upo/error.h>
#include <upo/io.h>
#include <upo/sort.h>
#define PLAYLIST_ENTRY_DELIMITER '|'
#define PLAYLIST_ENTRY_NUM_FIELDS 5
/** \brief Defines the type of an entry of a playlist. */
typedef struct {
char *artist; /**< The name of the artist */
char *album; /**< The name of the album */
int year; /**< The release year of the album */
int track_num; /**< The position of the song in the album */
char *track_title; /**< The title of the song */
} entry_t;
/** \brief Defines the type of a playlist. */
struct playlist_s
{
entry_t *entries;
size_t size;
};
/** \brief Destroys the given playlist entry. */
static void playlist_entry_destroy(entry_t *entry);
/** \brief Comparison function for playlist entries based on artist name */
static int by_artist_comparator(const void *a, const void *b);
/** \brief Comparison function for playlist entries based on album name */
static int by_album_comparator(const void *a, const void *b);
/** \brief Comparison function for playlist entries based on track number */
static int by_track_number_comparator(const void *a, const void *b);
/** \brief Comparison function for playlist entries based on track title */
static int by_track_title_comparator(const void *a, const void *b);
/** \brief Comparison function for playlist entries based on album release year */
static int by_year_comparator(const void *a, const void *b);
/** \brief Extracts a playlist entry from the given string. */
static int parse_entry(const char *str, entry_t *entry);
/**** EXERCISE #2 - BEGIN of SORTING PLAYLISTS ****/
int by_artist_comparator(const void *a, const void *b)
{
return strcmp(((entry_t *)a)->artist, ((entry_t *)b)->artist);
}
int by_album_comparator(const void *a, const void *b)
{
return strcmp(((entry_t *)a)->album, ((entry_t *)b)->album);
}
int by_year_comparator(const void *a, const void *b)
{
return (int)((entry_t *)a)->year - (int)((entry_t *)b)->year;
}
int by_track_number_comparator(const void *a, const void *b)
{
return (int)((entry_t *)a)->track_num - (int)((entry_t *)b)->track_num;
}
int by_track_title_comparator(const void *a, const void *b)
{
return strcmp(((entry_t *)a)->track_title, ((entry_t *)b)->track_title);
}
void playlist_sort(playlist_t playlist, playlist_sorting_criterion_t order_by)
{
int (*compar)(const void *, const void *);
switch (order_by) {
case playlist_by_artist_sorting_criterion:
compar = by_artist_comparator;
break;
case playlist_by_album_sorting_criterion:
compar = by_album_comparator;
break;
case playlist_by_year_sorting_criterion:
compar = by_year_comparator;
break;
case playlist_by_track_number_sorting_criterion:
compar = by_track_number_comparator;
break;
case playlist_by_track_title_sorting_criterion:
compar = by_track_title_comparator;
break;
default:
compar = NULL;
}
qsort(
playlist->entries,
playlist->size,
sizeof(*(playlist->entries)),
compar
);
}
/**** EXERCISE #2 - END of SORTING PLAYLISTS ****/
int parse_entry(const char *str, entry_t *entry)
{
char delim[] = {PLAYLIST_ENTRY_DELIMITER,'\0'};
char *aux_str = NULL;
char *loop_str = NULL;
char *token = NULL;
int ok = 0;
size_t num_fields = PLAYLIST_ENTRY_NUM_FIELDS;
size_t field_len = 0;
size_t field;
assert( str != NULL );
assert( entry != NULL );
/* We need to copy the original string since strtok modifies its first argument */
aux_str = malloc(strlen(str)+1);
if (aux_str == NULL)
{
upo_throw_sys_error("Unable to allocate memory for auxiliary string");
}
strcpy(aux_str, str);
/* Blanks the entry */
entry->artist = entry->album
= entry->track_title
= NULL;
entry->year = entry->track_num
= 0;
loop_str = aux_str;
ok = 1;
for (field = 0; field < num_fields && ok; ++field)
{
if (field > 0)
{
loop_str = NULL;
}
token = strtok(loop_str, delim);
if (token == NULL)
{
ok = 0;
}
else
{
switch (field)
{
case 0: /* artist */
field_len = strlen(token);
entry->artist = malloc(field_len+1);
if (entry->artist == NULL)
{
upo_throw_sys_error("Unable to allocate memory for artist name");
}
strcpy(entry->artist, token);
break;
case 1: /* album */
field_len = strlen(token);
entry->album = malloc(field_len+1);
if (entry->album == NULL)
{
upo_throw_sys_error("Unable to allocate memory for album name");
}
strcpy(entry->album, token);
break;
case 2: /* year */
entry->year = atoi(token);
break;
case 3: /* track number */
entry->track_num = atoi(token);
break;
case 4: /* track title */
field_len = strlen(token);
entry->track_title = malloc(field_len+1);
if (entry->track_title == NULL)
{
upo_throw_sys_error("Unable to allocate memory for track title");
}
strcpy(entry->track_title, token);
break;
case PLAYLIST_ENTRY_NUM_FIELDS: /* end-of-entry sentinel */
break;
}
}
}
/* Check data stored in the entry */
if (ok)
{
if (strlen(entry->artist) == 0
|| strlen(entry->album) == 0
|| entry->year <= 0
|| entry->track_num <= 0
|| strlen(entry->track_title) == 0)
{
ok = 0;
}
}
/* If something has gone wrong, cleans-up memory and blanks the entry */
if (!ok)
{
playlist_entry_destroy(entry);
}
free(aux_str);
return ok;
}
void playlist_entry_destroy(entry_t *entry)
{
assert( entry != NULL );
if (entry->artist != NULL)
{
free(entry->artist);
entry->artist = NULL;
}
if (entry->album != NULL)
{
free(entry->album);
entry->album = NULL;
}
entry->year = 0;
entry->track_num = 0;
if (entry->track_title != NULL)
{
free(entry->track_title);
entry->track_title = NULL;
}
}
playlist_t playlist_create_from_file(const char *file_name)
{
FILE *fp = NULL;
char *line = NULL;
size_t line_len = 0;
int ok = 0;
playlist_t playlist = NULL;
assert( file_name );
fp = fopen(file_name, "r");
if (fp == NULL)
{
upo_throw_sys_error("Unable to open playlist file");
}
playlist = malloc(sizeof(struct playlist_s));
if (playlist == NULL)
{
return NULL;
}
playlist->entries = NULL;
playlist->size = 0;
ok = 1;
while (upo_io_read_line(fp, &line, &line_len) > 0)
{
entry_t entry;
entry_t *tmp_entries = NULL;
if (line_len > 1 && line[line_len-2] == '\n')
{
line_len -= 2;
line[line_len] = '\0';
}
tmp_entries = realloc(playlist->entries, (playlist->size+1)*sizeof(entry_t));
if (tmp_entries == NULL)
{
ok = 0;
break;
}
playlist->entries = tmp_entries;
playlist->size += 1;
ok = parse_entry(line, &entry);
if (ok == 0)
{
break;
}
playlist->entries[playlist->size-1] = entry;
}
if (line != NULL)
{
free(line);
}
fclose(fp);
if (ok == 0)
{
playlist_destroy(playlist);
playlist = NULL;
}
return playlist;
}
void playlist_print(const playlist_t playlist, FILE *fp)
{
size_t i;
assert( playlist != NULL );
for (i = 0; i < playlist->size; ++i)
{
fprintf(fp, "%c%s%c%s%c%d%c%d%c%s%c\n", PLAYLIST_ENTRY_DELIMITER,
playlist->entries[i].artist,
PLAYLIST_ENTRY_DELIMITER,
playlist->entries[i].album,
PLAYLIST_ENTRY_DELIMITER,
playlist->entries[i].year,
PLAYLIST_ENTRY_DELIMITER,
playlist->entries[i].track_num,
PLAYLIST_ENTRY_DELIMITER,
playlist->entries[i].track_title,
PLAYLIST_ENTRY_DELIMITER);
}
}
void playlist_destroy(playlist_t playlist)
{
if (playlist != NULL)
{
if (playlist->entries != NULL)
{
size_t i;
for (i = 0; i < playlist->size; ++i)
{
playlist_entry_destroy(&(playlist->entries[i]));
}
free(playlist->entries);
}
free(playlist);
}
}
/* vim: set tabstop=4 expandtab shiftwidth=4 softtabstop=4: */
/**
* \file apps/playlist.h
*
* \brief Header file for the playlist type.
*
* \author Your Name
*
* \copyright 2015 University of Piemonte Orientale, Computer Science Institute
*
* This file is part of UPOalglib.
*
* UPOalglib is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* UPOalglib is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with UPOalglib. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef PLAYLIST_H
#define PLAYLIST_H
#include <stdio.h>
/** \brief Type playlist type. */
typedef struct playlist_s* playlist_t;
/** \brief Criteria to sort a playlist. */
typedef enum {
playlist_unknown_sorting_criterion, /**< Unknown sorting criterion. */
playlist_by_artist_sorting_criterion, /**< Sort by artist name. */
playlist_by_album_sorting_criterion, /**< Sort by album name. */
playlist_by_year_sorting_criterion, /**< Sort by year of release. */
playlist_by_track_number_sorting_criterion, /**< Sort by track number. */
playlist_by_track_title_sorting_criterion /**< Sort by track title. */
} playlist_sorting_criterion_t; /**< Sort by artist name. */
/**
* \brief Creates a playlist from the given file.
*
* \param file_name The name of the file from which reading the playlist.
* \return A new playlist built from the given file name.
*/
playlist_t playlist_create_from_file(const char* file_name);
/**
* \brief Destroys the given playlist.
*
* \param playlist The playlist to destroy.
*/
void playlist_destroy(playlist_t playlist);
/**
* \brief Prints the given playlist to the given output stream.
*
* \param playlist The playlist to print.
* \param fp The stream to which print the playlist.
*/
void playlist_print(const playlist_t playlist, FILE* fp);
/**
* \brief Sorts the given playlist with the given criterion.
*
* \param playlist The playlist to sort.
* \param order_by The sorting criterion.
*/
void playlist_sort(playlist_t playlist, playlist_sorting_criterion_t order_by);
#endif /* PLAYLIST_H */
/* vim: set tabstop=4 expandtab shiftwidth=4 softtabstop=4: */
/**
* \file apps/sort_playlist.c
*
* \brief An application to sort playlists.
*
* \author Your Name
*
* \copyright 2015 University of Piemonte Orientale, Computer Science Institute
*
* This file is part of UPOalglib.
*
* UPOalglib is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* UPOalglib is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with UPOalglib. If not, see <http://www.gnu.org/licenses/>.
*/
#include <assert.h>
#include "playlist.h"
#include <stdio.h>
#include <string.h>
#include <upo/error.h>
#include <upo/sort.h>
#define DEFAULT_OPT_ORDER_BY playlist_by_artist_sorting_criterion
#define DEFAULT_OPT_ORDER_BY_STR "artist"
#define DEFAULT_OPT_VERBOSE 0
/** \brief Extracts the sorting criterion from the given string. */
static playlist_sorting_criterion_t parse_sorting_criterion(const char *str);
/** \brief Prints the given sorting criterion to the given stream. */
static void print_sorting_criterion(FILE *fp, playlist_sorting_criterion_t order_by);
/** \brief Displays a help message. */
static void usage(const char *progname);
playlist_sorting_criterion_t parse_sorting_criterion(const char *str)
{
assert( str != NULL );
if (!strcmp("artist", str))
{
return playlist_by_artist_sorting_criterion;
}
if (!strcmp("album", str))
{
return playlist_by_album_sorting_criterion;
}
if (!strcmp("year", str))
{
return playlist_by_year_sorting_criterion;
}
if (!strcmp("title", str))
{
return playlist_by_track_title_sorting_criterion;
}
if (!strcmp("trackno", str))
{
return playlist_by_track_number_sorting_criterion;
}
return playlist_unknown_sorting_criterion;
}
void print_sorting_criterion(FILE *fp, playlist_sorting_criterion_t order_by)
{
assert( fp != NULL );
switch (order_by)
{
case playlist_by_artist_sorting_criterion:
fprintf(fp, "artist");
break;
case playlist_by_album_sorting_criterion:
fprintf(fp, "album");
break;
case playlist_by_year_sorting_criterion:
fprintf(fp, "year");
break;
case playlist_by_track_number_sorting_criterion:
fprintf(fp, "trackno");
break;
case playlist_by_track_title_sorting_criterion:
fprintf(fp, "title");
break;
case playlist_unknown_sorting_criterion:
fprintf(fp, "unknown");
break;
}
}
void usage(const char *progname)
{
fprintf(stderr, "Usage: %s <options>\n", progname);
fprintf(stderr, "Options:\n");
fprintf(stderr, "-h: Displays this message.\n");
fprintf(stderr, "-i <file name>: Specifies the name of the input playlist file.\n");
fprintf(stderr, "-s <value>: Specifies the sorting critertion to apply.\n"
" Possible values are:\n"
" - artist\n"
" - album\n"
" - title\n"
" - trackno\n"
" - year\n"
" [default: %s]\n", DEFAULT_OPT_ORDER_BY_STR);
fprintf(stderr, "-v: Enables output verbosity.\n"
" [default: <%s>]\n", (DEFAULT_OPT_VERBOSE ? "enabled" : "disabled"));
}
int main(int argc, char *argv[])
{
int opt_help = 0;
char *opt_input_file = NULL;
playlist_sorting_criterion_t opt_order_by = DEFAULT_OPT_ORDER_BY;
int opt_verbose = DEFAULT_OPT_VERBOSE;
int arg;
playlist_t playlist = NULL;
for (arg = 1; arg < argc; ++arg)
{
if (!strcmp("-i", argv[arg]))
{
++arg;
if (arg >= argc)
{
fprintf(stderr, "ERROR: expected playlist file name.\n");
usage(argv[0]);
return EXIT_FAILURE;
}
opt_input_file = argv[arg];
}
else if (!strcmp("-h", argv[arg]))
{
opt_help = 1;
}
else if (!strcmp("-s", argv[arg]))
{
char *str = NULL;
++arg;
if (arg >= argc)
{
fprintf(stderr, "ERROR: expected sorting criterion.\n");
usage(argv[0]);
return EXIT_FAILURE;
}
str = argv[arg];
opt_order_by = parse_sorting_criterion(str);
if (opt_order_by == playlist_unknown_sorting_criterion)
{
fprintf(stderr, "ERROR: unknown sorting criterion.\n");
usage(argv[0]);
return EXIT_FAILURE;
}
}
else if (!strcmp("-v", argv[arg]))
{
opt_verbose = 1;
}
}
if (opt_help)
{
usage(argv[0]);
return EXIT_SUCCESS;
}
if (opt_input_file == NULL)
{
fprintf(stderr, "ERROR: input playlist file has not been specified.\n");
usage(argv[0]);
return EXIT_FAILURE;
}
if (opt_verbose)
{
printf("-- Options:\n");
printf("* Playlist file name: %s\n", opt_input_file);
printf("* Sorting criterion: ");
print_sorting_criterion(stdout, opt_order_by);
printf("\n");
}
if (opt_verbose)
{
printf("Reading the playlist from '%s'...\n", opt_input_file);
}
playlist = playlist_create_from_file(opt_input_file);
if (playlist == NULL)
{
fprintf(stderr, "ERROR: problems while reading the input playlist.\n");
return EXIT_FAILURE;
}
if (opt_verbose)
{
playlist_print(playlist, stdout);
}
if (opt_verbose)
{
printf("Sorting the playlist with criterion '");
print_sorting_criterion(stdout, opt_order_by);
printf("'...\n");
}
playlist_sort(playlist, opt_order_by);
playlist_print(playlist, stdout);
playlist_destroy(playlist);
return EXIT_SUCCESS;
}
|Bruce Springsteen|Born in the U.S.A.|1984| 1|Born in the U.S.A.|
|Bruce Springsteen|Born in the U.S.A.|1984| 2|Cover Me|
|Bruce Springsteen|Born in the U.S.A.|1984| 3|Darlington County|
|Bruce Springsteen|Born in the U.S.A.|1984| 4|Working on the Highway|
|Bruce Springsteen|Born in the U.S.A.|1984| 5|Downbound Train|
|Bruce Springsteen|Born in the U.S.A.|1984| 6|I'm on Fire|
|Bruce Springsteen|Born in the U.S.A.|1984| 7|No Surrender|
|Bruce Springsteen|Born in the U.S.A.|1984| 8|Bobby Jean|
|Bruce Springsteen|Born in the U.S.A.|1984| 9|I'm Goin' Down|
|Bruce Springsteen|Born in the U.S.A.|1984|10|Glory Days|
|Bruce Springsteen|Born in the U.S.A.|1984|11|Dancing in the Dark|
|Bruce Springsteen|Born in the U.S.A.|1984|12|My Hometown|
|The Rolling Stones|Let It Bleed|1969| 1|Gimme Shelter|
|The Rolling Stones|Let It Bleed|1969| 2|Love in Vain|
|The Rolling Stones|Let It Bleed|1969| 3|Country Honk|
|The Rolling Stones|Let It Bleed|1969| 4|Live with Me|
|The Rolling Stones|Let It Bleed|1969| 5|Let It Bleed|
|The Rolling Stones|Let It Bleed|1969| 6|Midnight Rambler|
|The Rolling Stones|Let It Bleed|1969| 7|You Got the Silver|
|The Rolling Stones|Let It Bleed|1969| 8|Monkey Man|
|The Rolling Stones|Let It Bleed|1969| 9|You Can't Always Get What You Want|
|Stevie Ray Vaughan and Double Trouble|In Step|1989| 1|The House Is Rockin'|
|Stevie Ray Vaughan and Double Trouble|In Step|1989| 2|Crossfire|
|Stevie Ray Vaughan and Double Trouble|In Step|1989| 3|Tightrope|
|Stevie Ray Vaughan and Double Trouble|In Step|1989| 4|Let Me Love You Baby|
|Stevie Ray Vaughan and Double Trouble|In Step|1989| 5|Leave My Girl Alone|
|Stevie Ray Vaughan and Double Trouble|In Step|1989| 6|Travis Walk|
|Stevie Ray Vaughan and Double Trouble|In Step|1989| 7|Wall of Denial|
|Stevie Ray Vaughan and Double Trouble|In Step|1989| 8|Scratch-N-Sniff|
|Stevie Ray Vaughan and Double Trouble|In Step|1989| 9|Love Me Darlin'|
|Stevie Ray Vaughan and Double Trouble|In Step|1989|10|Riviera Paradise|
|Bob Marley and The Wailers|Catch a Fire|1973| 1|Concrete Jungle|
|Bob Marley and The Wailers|Catch a Fire|1973| 2|Slave Driver|
|Bob Marley and The Wailers|Catch a Fire|1973| 3|400 Years|
|Bob Marley and The Wailers|Catch a Fire|1973| 4|Stop That Train|
|Bob Marley and The Wailers|Catch a Fire|1973| 5|Baby We've Got a Date (Rock It Baby)|
|Bob Marley and The Wailers|Catch a Fire|1973| 6|Stir It Up|
|Bob Marley and The Wailers|Catch a Fire|1973| 7|Kinky Reggae|
|Bob Marley and The Wailers|Catch a Fire|1973| 8|No More Trouble|
|Bob Marley and The Wailers|Catch a Fire|1973| 9|Midnight Ravers|
|Bruce Springsteen|High Hopes|2014| 1|High Hopes|
|Bruce Springsteen|High Hopes|2014| 2|Harry's Place|
|Bruce Springsteen|High Hopes|2014| 3|American Skin (41 Shots)|
|Bruce Springsteen|High Hopes|2014| 4|Just Like Fire Would|
|Bruce Springsteen|High Hopes|2014| 5|Down In The Hole|
|Bruce Springsteen|High Hopes|2014| 6|Heaven's Wall|
|Bruce Springsteen|High Hopes|2014| 7|Frankie Fell In Love|
|Bruce Springsteen|High Hopes|2014| 8|This Is Your Sword|
|Bruce Springsteen|High Hopes|2014| 9|Hunter Of Invisible Game|
|Bruce Springsteen|High Hopes|2014|10|The Ghost Of Tom Joad|
|Bruce Springsteen|High Hopes|2014|11|The Wall|
|Bruce Springsteen|High Hopes|2014|12|Dream Baby Dream|
|Ben Harper and Charlie Musselwhite|Get Up!|2013| 1|Don't Look Twice|
|Ben Harper and Charlie Musselwhite|Get Up!|2013| 2|I'm In, I'm Out, I'm Gone|
|Ben Harper and Charlie Musselwhite|Get Up!|2013| 3|We Can't End This Way|
|Ben Harper and Charlie Musselwhite|Get Up!|2013| 4|I Don't Believe a Word You Say|
|Ben Harper and Charlie Musselwhite|Get Up!|2013| 5|You Found Another Lover (I Lost Another Friend)|
|Ben Harper and Charlie Musselwhite|Get Up!|2013| 6|I Ride at Dawn|
|Ben Harper and Charlie Musselwhite|Get Up!|2013| 7|Blood Side Out|
|Ben Harper and Charlie Musselwhite|Get Up!|2013| 8|Get Up!|
|Ben Harper and Charlie Musselwhite|Get Up!|2013| 9|She Got Kick|
|Ben Harper and Charlie Musselwhite|Get Up!|2013|10|All That Matters Now|
|Led Zeppelin|Led Zeppelin IV|1971| 1|Black Dog|
|Led Zeppelin|Led Zeppelin IV|1971| 2|Rock and Roll|
|Led Zeppelin|Led Zeppelin IV|1971| 3|The Battle of Evermore|
|Led Zeppelin|Led Zeppelin IV|1971| 4|Stairway to Heaven|
|Led Zeppelin|Led Zeppelin IV|1971| 5|Misty Mountain Hop|
|Led Zeppelin|Led Zeppelin IV|1971| 6|Four Sticks|
|Led Zeppelin|Led Zeppelin IV|1971| 7|Going to California|
|Led Zeppelin|Led Zeppelin IV|1971| 8|When the Levee Breaks|
......@@ -62,23 +62,4 @@ static void *upo_quick_sort_partition(
upo_sort_comparator_t cmp
);
/* TO STUDENTS:
*
* This file is currently "empty".
* Here you can put the prototypes of auxiliary "private" functions that are
* internally used by "public" functions.
* For instance, you can declare the prototype of the function that performs
* the "merge" operation in the merge-sort algorithm:
* static void upo_merge_sort_merge(void *base, size_t lo, size_t mid, size_t hi, size_t size, upo_sort_comparator_t cmp);
* Also, you can declare the prototype of the function that performs the
* the recursion in the merge-sort algorithm:
* static void upo_merge_sort_rec(void *base, size_t lo, size_t hi, size_t size, upo_sort_comparator_t cmp);
* Further, you can declare the prototype of the function that performs the
* "partition" operation in the quick-sort algorithm:
* static size_t upo_quick_sort_partition(void *base, size_t lo, size_t hi, size_t size, upo_sort_comparator_t cmp);
* And so on.
*
*/
#endif /* UPO_SORT_PRIVATE_H */
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment