projects
/
pspp
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
file-handle-def.h (fh_ref): Add WARN_UNUSED_RESULT qualifier
[pspp]
/
src
/
math
/
extrema.c
diff --git
a/src/math/extrema.c
b/src/math/extrema.c
index 617c7ac72bb15ba646c2e9b7926188bcaa40bc04..1ff9eb199fd9bc323593db4e9f885e53f596df3b 100644
(file)
--- a/
src/math/extrema.c
+++ b/
src/math/extrema.c
@@
-1,5
+1,5
@@
/* PSPP - a program for statistical analysis.
/* PSPP - a program for statistical analysis.
- Copyright (C) 2008 Free Software Foundation, Inc.
+ Copyright (C) 2008
, 2011
Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@
-15,14
+15,18
@@
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <config.h>
along with this program. If not, see <http://www.gnu.org/licenses/>. */
#include <config.h>
-#include "extrema.h"
-#include <xalloc.h>
-#include <data/case.h>
-#include <data/val-type.h>
-#include <libpspp/compiler.h>
-#include <libpspp/ll.h>
+
+#include "math/extrema.h"
+
#include <stdlib.h>
#include <stdlib.h>
+#include "data/case.h"
+#include "data/val-type.h"
+#include "libpspp/compiler.h"
+#include "libpspp/ll.h"
+
+#include "gl/xalloc.h"
+
struct extrema
{
size_t capacity;
struct extrema
{
size_t capacity;
@@
-39,7
+43,7
@@
cmp_descending (const struct ll *a_, const struct ll *b_, void *aux UNUSED)
const struct extremum *a = ll_data (a_, struct extremum, ll);
const struct extremum *b = ll_data (b_, struct extremum, ll);
const struct extremum *a = ll_data (a_, struct extremum, ll);
const struct extremum *b = ll_data (b_, struct extremum, ll);
- if (
a->value > b->value) return -1;
+ if (a->value > b->value) return -1;
return (a->value < b->value);
}
return (a->value < b->value);
}
@@
-50,7
+54,7
@@
cmp_ascending (const struct ll *a_, const struct ll *b_, void *aux UNUSED)
const struct extremum *a = ll_data (a_, struct extremum, ll);
const struct extremum *b = ll_data (b_, struct extremum, ll);
const struct extremum *a = ll_data (a_, struct extremum, ll);
const struct extremum *b = ll_data (b_, struct extremum, ll);
- if (
a->value < b->value) return -1;
+ if (a->value < b->value) return -1;
return (a->value > b->value);
}
return (a->value > b->value);
}
@@
-62,7
+66,7
@@
extrema_create (size_t n, enum extreme_end end)
struct extrema *extrema = xzalloc (sizeof *extrema);
extrema->capacity = n;
struct extrema *extrema = xzalloc (sizeof *extrema);
extrema->capacity = n;
- if (
end == EXTREME_MAXIMA
)
+ if (
end == EXTREME_MAXIMA
)
extrema->cmp_func = cmp_descending;
else
extrema->cmp_func = cmp_ascending;
extrema->cmp_func = cmp_descending;
else
extrema->cmp_func = cmp_ascending;
@@
-99,7
+103,7
@@
extrema_add (struct extrema *extrema, double val,
e->location = location;
e->weight = weight;
e->location = location;
e->weight = weight;
- if (
val == SYSMIS)
+ if (val == SYSMIS)
{
free (e);
return;
{
free (e);
return;
@@
-108,7
+112,7
@@
extrema_add (struct extrema *extrema, double val,
ll_insert_ordered (ll_head (&extrema->list), ll_null (&extrema->list),
&e->ll, extrema->cmp_func, NULL);
ll_insert_ordered (ll_head (&extrema->list), ll_null (&extrema->list),
&e->ll, extrema->cmp_func, NULL);
- if (
extrema->n++ > extrema->capacity)
+ if (extrema->n++ > extrema->capacity)
{
struct ll *tail = ll_tail (&extrema->list);
struct extremum *et = ll_data (tail, struct extremum, ll);
{
struct ll *tail = ll_tail (&extrema->list);
struct extremum *et = ll_data (tail, struct extremum, ll);
@@
-132,7
+136,7
@@
extrema_top (const struct extrema *ex, double *v)
{
const struct extremum *top;
{
const struct extremum *top;
- if (
ll_is_empty (&ex->list))
+ if (ll_is_empty (&ex->list))
return false;
top = (const struct extremum *)
return false;
top = (const struct extremum *)