PKUOS - Pintos
Pintos source browser for PKU Operating System course
|
#include <stddef.h>
Go to the source code of this file.
Functions | |
int | atoi (const char *) |
Standard functions. More... | |
void | qsort (void *array, size_t cnt, size_t size, int(*compare)(const void *, const void *)) |
Sorts ARRAY, which contains CNT elements of SIZE bytes each, using COMPARE. More... | |
void * | bsearch (const void *key, const void *array, size_t cnt, size_t size, int(*compare)(const void *, const void *)) |
Searches ARRAY, which contains CNT elements of SIZE bytes each, for the given KEY. More... | |
void | sort (void *array, size_t cnt, size_t size, int(*compare)(const void *, const void *, void *aux), void *aux) |
Nonstandard functions. More... | |
void * | binary_search (const void *key, const void *array, size_t cnt, size_t size, int(*compare)(const void *, const void *, void *aux), void *aux) |
lib/stdlib.h More... | |
int atoi | ( | const char * | s | ) |
void * binary_search | ( | const void * | key, |
const void * | array, | ||
size_t | cnt, | ||
size_t | size, | ||
int(*)(const void *, const void *, void *aux) | compare, | ||
void * | aux | ||
) |
Returns a match is found, otherwise a null pointer. If there are multiple matches, returns an arbitrary one of them.
ARRAY must be sorted in order according to COMPARE.
Uses COMPARE to compare elements, passing AUX as auxiliary data. When COMPARE is passed a pair of elements A and B, respectively, it must return a strcmp()-type result, i.e. less than zero if A < B, zero if A == B, greater than zero if A > B.
Definition at line 185 of file stdlib.c.
References NULL.
Referenced by bsearch().
void * bsearch | ( | const void * | key, |
const void * | array, | ||
size_t | cnt, | ||
size_t | size, | ||
int(*)(const void *, const void *) | compare | ||
) |
Searches ARRAY, which contains CNT elements of SIZE bytes each, for the given KEY.
Returns a match is found, otherwise a null pointer. If there are multiple matches, returns an arbitrary one of them.
ARRAY must be sorted in order according to COMPARE.
Uses COMPARE to compare elements. When COMPARE is passed a pair of elements A and B, respectively, it must return a strcmp()-type result, i.e. less than zero if A < B, zero if A == B, greater than zero if A > B.
Definition at line 166 of file stdlib.c.
References binary_search(), and compare_thunk().
Referenced by verify_bsearch().
Sorts ARRAY, which contains CNT elements of SIZE bytes each, using COMPARE.
When COMPARE is passed a pair of elements A and B, respectively, it must return a strcmp()-type result, i.e. less than zero if A < B, zero if A == B, greater than zero if A > B. Runs in O(n lg n) time and O(1) space in CNT.
Definition at line 58 of file stdlib.c.
References compare_thunk(), and sort().
Referenced by test().
void sort | ( | void * | array, |
size_t | cnt, | ||
size_t | size, | ||
int(*)(const void *, const void *, void *aux) | compare, | ||
void * | aux | ||
) |
Nonstandard functions.
Nonstandard functions.
When COMPARE is passed a pair of elements A and B, respectively, it must return a strcmp()-type result, i.e. less than zero if A < B, zero if A == B, greater than zero if A > B. Runs in O(n lg n) time and O(1) space in CNT.
Definition at line 132 of file stdlib.c.
References ASSERT, do_swap(), heapify(), and NULL.
Referenced by qsort().