source: trunk/third/gstreamer/gst/gstfilter.c @ 21005

Revision 21005, 1.7 KB checked in by ghudson, 20 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r21004, which included commits to RCS files with non-trunk default branches.
Line 
1/* GStreamer
2 * Copyright (C) <1999> Erik Walthinsen <omega@cse.ogi.edu>
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Library General Public
6 * License as published by the Free Software Foundation; either
7 * version 2 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12 * Library General Public License for more details.
13 *
14 * You should have received a copy of the GNU Library General Public
15 * License along with this library; if not, write to the
16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
17 * Boston, MA 02111-1307, USA.
18 */
19
20#include "gst_private.h"
21#include <gst/gstfilter.h>
22
23/**
24 * gst_filter_run:
25 * @list: a linked list
26 * @func: the function to execute for each item
27 * @first: flag to stop execution after a successful item
28 * @user_data: user data
29 *
30 * Iterates over the elements in @list, calling @func with the
31 * list item data for each item.  If @func returns TRUE, @data is
32 * prepended to the list of results returned.  If @first is true,
33 * the search is halted after the first result is found.
34 *
35 * Returns: the list of results
36 */
37GList *
38gst_filter_run (const GList * list, GstFilterFunc func, gboolean first,
39    gpointer user_data)
40{
41  const GList *walk = list;
42  GList *result = NULL;
43
44  while (walk) {
45    gboolean res = TRUE;
46    gpointer data = walk->data;
47
48    walk = g_list_next (walk);
49
50    if (func)
51      res = func (data, user_data);
52
53    if (res) {
54      result = g_list_prepend (result, data);
55
56      if (first)
57        break;
58    }
59  }
60
61  return result;
62}
Note: See TracBrowser for help on using the repository browser.