~ubuntu-branches/ubuntu/feisty/renameutils/feisty

« back to all changes in this revision

Viewing changes to src/common/iterator.c

  • Committer: Bazaar Package Importer
  • Author(s): Francois Marier
  • Date: 2004-04-29 13:41:34 UTC
  • Revision ID: james.westby@ubuntu.com-20040429134134-vwe8r35v0mmk3s9m
Tags: 0.4.0-2
* Fixed a typo in the qmv manpage (Closes: #245196)
* Changed short and long description
* Fixed build error on 64-bit machines (Closes: #246179)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* iterator.c - The iterator support-data structure.
 
2
 *
 
3
 * Copyright (C) 2001  Oskar Liljeblad
 
4
 *
 
5
 * This file is part of the file renaming utilities (renameutils)
 
6
 * and regex-markup.
 
7
 *
 
8
 * This software is copyrighted work licensed under the terms of the
 
9
 * GNU General Public License. Please consult the file `COPYING' for
 
10
 * details.
 
11
 */
 
12
 
 
13
#include <config.h>
 
14
#include <stdlib.h>
 
15
#include "iterator.h"
 
16
#include "error.h"
 
17
 
 
18
bool
 
19
iterator_has_next(Iterator *it)
 
20
{
 
21
        return it->class->has_next(it);
 
22
}
 
23
 
 
24
void *
 
25
iterator_next(Iterator *it)
 
26
{
 
27
        return it->class->next(it);
 
28
}
 
29
 
 
30
void *
 
31
iterator_previous(Iterator *it)
 
32
{
 
33
        if (it->class->previous == NULL)
 
34
                internal_error("Called iterator_previous on iterator that doesn't support it");
 
35
        return it->class->previous(it);
 
36
}
 
37
 
 
38
void
 
39
iterator_remove(Iterator *it)
 
40
{
 
41
        if (it->class->remove == NULL)
 
42
                internal_error("Called iterator_remove on iterator that doesn't support it");
 
43
        it->class->remove(it);
 
44
}
 
45
 
 
46
void
 
47
iterator_add(Iterator *it, void *value)
 
48
{
 
49
        if (it->class->add == NULL)
 
50
                internal_error("Called iterator_add on iterator that doesn't support it");
 
51
        it->class->add(it, value);
 
52
}
 
53
 
 
54
void
 
55
iterator_restart(Iterator *it)
 
56
{
 
57
        it->class->restart(it);
 
58
}
 
59
 
 
60
void
 
61
iterator_free(Iterator *it)
 
62
{
 
63
        if (it->class->free == NULL)
 
64
                free(it);
 
65
        else 
 
66
                it->class->free(it);
 
67
}