X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Falgorithm.h;h=10e589a1e4f43eb147062f33e2644c5b1ece38ac;hb=a29bbbe97388bb6f9c9b4df36b448dfe5023363c;hp=f8f2b84d877dd8c43ea5a01055ce587a71aefe2c;hpb=f9d47b5bba8416419cf3bcd3aa23c2d40a05fcac;p=pspp diff --git a/src/algorithm.h b/src/algorithm.h index f8f2b84d87..10e589a1e4 100644 --- a/src/algorithm.h +++ b/src/algorithm.h @@ -1,5 +1,5 @@ -#ifndef SORT_ALGO_H -#define SORT_ALGO_H 1 +#ifndef ALGORITHM_H +#define ALGORITHM_H 1 #include @@ -95,6 +95,25 @@ size_t copy_if (const void *array, size_t count, size_t size, void *result, algo_predicate_func *predicate, void *aux); +/* Removes N elements starting at IDX from ARRAY, which consists + of COUNT elements of SIZE bytes each, by shifting the elements + following them, if any, into its position. */ +void remove_range (void *array, size_t count, size_t size, + size_t idx, size_t n); + +/* Removes element IDX from ARRAY, which consists of COUNT + elements of SIZE bytes each, by shifting the elements + following it, if any, into its position. */ +void remove_element (void *array, size_t count, size_t size, + size_t idx); + +/* Moves an element in ARRAY, which consists of COUNT elements of + SIZE bytes each, from OLD_IDX to NEW_IDX, shifting around + other elements as needed. Runs in O(abs(OLD_IDX - NEW_IDX)) + time. */ +void move_element (void *array, size_t count, size_t size, + size_t old_idx, size_t new_idx); + /* Removes elements equal to ELEMENT from ARRAY, which consists of COUNT elements of SIZE bytes each. Returns the number of remaining elements. AUX is passed to COMPARE as auxiliary @@ -190,4 +209,4 @@ int is_heap (const void *array, size_t count, size_t size, algo_compare_func *compare, void *aux); -#endif /* sort-algo.h */ +#endif /* algorithm.h */