Main Page | Class List | File List | Class Members | File Members

comb.h

Go to the documentation of this file.
00001 /* COMB.H */
00002 
00003 #ifndef _COMB_H_
00004 #define _COMB_H_
00005 
00006 
00007 typedef struct {
00008   int *numbers;
00009   int n;
00010   int *curr;
00011   int *next;
00012   int r;
00013   int *x;
00014   int last;
00015 } combinations; 
00016 
00017 
00018 combinations *new_combinations(int numbers[], int n, int r);
00019 /*
00020  * Makes a combinations record which can be used in successive calls
00021  *   to next_combination() in order to go through all the combinations
00022  *   of length r from a set of numbers of length n.
00023  */
00024 
00025 static int incr(int *x, int n, int r);
00026 /*
00027  * Increments combination pointers.
00028  *   Returns 0 iff the input was the last combination.
00029  */
00030 
00031 int *next_combination(combinations *bob);
00032 /*
00033  * Returns a pointer to an array of integers describing the next
00034  *   combination of the array of numbers stored in (bob).
00035  */
00036 
00037 void close_combinations(combinations *bob);
00038 /*
00039  * Frees some memory.
00040  */
00041 
00042 #endif

Generated on Sun Jul 16 16:27:45 2006 by  doxygen 1.3.9.1