X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Flibpspp%2Fllx.c;h=43704e314ea2080c833d4745dc4e6b85e4557604;hb=2a88ed46e4bf5a240b9fe425598edf6bb158d66b;hp=c58f840c40a6db106d250e0cb6b5a9dec39efa5f;hpb=7c08a6e1009cf60847e770a77a73c650e9326379;p=pspp diff --git a/src/libpspp/llx.c b/src/libpspp/llx.c index c58f840c40..43704e314e 100644 --- a/src/libpspp/llx.c +++ b/src/libpspp/llx.c @@ -1,5 +1,5 @@ /* PSPP - a program for statistical analysis. - Copyright (C) 2006, 2009 Free Software Foundation, Inc. + Copyright (C) 2006, 2009, 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 @@ -28,9 +28,8 @@ #include #endif -#include -#include "compiler.h" -#include +#include "libpspp/llx.h" +#include "libpspp/compiler.h" #include /* Destroys LIST and frees all of its nodes using MANAGER. @@ -165,7 +164,7 @@ llx_remove_range (struct llx *r0, struct llx *r1, { struct llx *llx; - for (llx = r0; llx != r1; ) + for (llx = r0; llx != r1;) llx = llx_remove (llx, manager); } @@ -182,7 +181,7 @@ llx_remove_equal (struct llx *r0, struct llx *r1, const void *target, size_t count; count = 0; - for (x = r0; x != r1; ) + for (x = r0; x != r1;) if (compare (llx_data (x), target, aux) == 0) { x = llx_remove (x, manager); @@ -207,7 +206,7 @@ llx_remove_if (struct llx *r0, struct llx *r1, size_t count; count = 0; - for (x = r0; x != r1; ) + for (x = r0; x != r1;) if (predicate (llx_data (x), aux)) { x = llx_remove (x, manager); @@ -219,6 +218,20 @@ llx_remove_if (struct llx *r0, struct llx *r1, return count; } +/* Returns the first node in R0...R1 that has data TARGET. + Returns NULL if no node in R0...R1 equals TARGET. */ +struct llx * +llx_find (const struct llx *r0, const struct llx *r1, const void *target) +{ + const struct llx *x; + + for (x = r0; x != r1; x = llx_next (x)) + if (llx_data (x) == target) + return CONST_CAST (struct llx *, x); + + return NULL; +} + /* Returns the first node in R0...R1 that equals TARGET according to COMPARE given auxiliary data AUX. Returns R1 if no node in R0...R1 equals TARGET. */