File indexing completed on 2025-02-21 10:03:51
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022 #ifndef __GSL_MULTISET_H__
0023 #define __GSL_MULTISET_H__
0024
0025 #include <stdlib.h>
0026 #include <gsl/gsl_errno.h>
0027 #include <gsl/gsl_types.h>
0028 #include <gsl/gsl_inline.h>
0029 #include <gsl/gsl_check_range.h>
0030
0031 #undef __BEGIN_DECLS
0032 #undef __END_DECLS
0033 #ifdef __cplusplus
0034 # define __BEGIN_DECLS extern "C" {
0035 # define __END_DECLS }
0036 #else
0037 # define __BEGIN_DECLS
0038 # define __END_DECLS
0039 #endif
0040
0041 __BEGIN_DECLS
0042
0043 struct gsl_multiset_struct
0044 {
0045 size_t n;
0046 size_t k;
0047 size_t *data;
0048 };
0049
0050 typedef struct gsl_multiset_struct gsl_multiset;
0051
0052 gsl_multiset *gsl_multiset_alloc (const size_t n, const size_t k);
0053 gsl_multiset *gsl_multiset_calloc (const size_t n, const size_t k);
0054 void gsl_multiset_init_first (gsl_multiset * c);
0055 void gsl_multiset_init_last (gsl_multiset * c);
0056 void gsl_multiset_free (gsl_multiset * c);
0057 int gsl_multiset_memcpy (gsl_multiset * dest, const gsl_multiset * src);
0058
0059 int gsl_multiset_fread (FILE * stream, gsl_multiset * c);
0060 int gsl_multiset_fwrite (FILE * stream, const gsl_multiset * c);
0061 int gsl_multiset_fscanf (FILE * stream, gsl_multiset * c);
0062 int gsl_multiset_fprintf (FILE * stream, const gsl_multiset * c, const char *format);
0063
0064 size_t gsl_multiset_n (const gsl_multiset * c);
0065 size_t gsl_multiset_k (const gsl_multiset * c);
0066 size_t * gsl_multiset_data (const gsl_multiset * c);
0067
0068 int gsl_multiset_valid (gsl_multiset * c);
0069 int gsl_multiset_next (gsl_multiset * c);
0070 int gsl_multiset_prev (gsl_multiset * c);
0071
0072 INLINE_DECL size_t gsl_multiset_get (const gsl_multiset * c, const size_t i);
0073
0074 #ifdef HAVE_INLINE
0075
0076 INLINE_FUN
0077 size_t
0078 gsl_multiset_get (const gsl_multiset * c, const size_t i)
0079 {
0080 #if GSL_RANGE_CHECK
0081 if (GSL_RANGE_COND(i >= c->k))
0082 {
0083 GSL_ERROR_VAL ("index out of range", GSL_EINVAL, 0);
0084 }
0085 #endif
0086 return c->data[i];
0087 }
0088
0089 #endif
0090
0091 __END_DECLS
0092
0093 #endif