File: zlist.api

package info (click to toggle)
czmq 4.2.1-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 9,912 kB
  • sloc: ansic: 30,811; cpp: 19,362; sh: 11,873; python: 11,814; pascal: 11,229; ruby: 8,818; java: 4,363; makefile: 299; perl: 151; javascript: 35
file content (158 lines) | stat: -rw-r--r-- 6,348 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
<class name = "zlist" state = "stable">
    <!--
    Copyright (c) the Contributors as noted in the AUTHORS file.
    This file is part of CZMQ, the high-level C binding for 0MQ:
    http://czmq.zeromq.org.

    This Source Code Form is subject to the terms of the Mozilla Public
    License, v. 2.0. If a copy of the MPL was not distributed with this
    file, You can obtain one at http://mozilla.org/MPL/2.0/.
    -->
    simple generic list container

    <callback_type name = "compare_fn">
        Comparison function e.g. for sorting and removing.
        <argument name = "item1" type = "anything" />
        <argument name = "item2" type = "anything" />
        <return type = "integer" />
    </callback_type>

    <callback_type name = "free_fn">
        Callback function for zlist_freefn method
        <argument name = "data" type = "anything" />
    </callback_type>

    <constructor>
        Create a new list container
    </constructor>

    <destructor>
        Destroy a list container
    </destructor>

    <method name = "first">
        Return the item at the head of list. If the list is empty, returns NULL.
        Leaves cursor pointing at the head item, or NULL if the list is empty.
        <return type = "anything" />
    </method>

    <method name = "next">
        Return the next item. If the list is empty, returns NULL. To move to
        the start of the list call zlist_first (). Advances the cursor.
        <return type = "anything" />
    </method>

    <method name = "last">
        Return the item at the tail of list. If the list is empty, returns NULL.
        Leaves cursor pointing at the tail item, or NULL if the list is empty.
        <return type = "anything" />
    </method>

    <method name = "head">
        Return first item in the list, or null, leaves the cursor
        <return type = "anything" />
    </method>

    <method name = "tail">
        Return last item in the list, or null, leaves the cursor
        <return type = "anything" />
    </method>

    <method name = "item">
        Return the current item of list. If the list is empty, returns NULL.
        Leaves cursor pointing at the current item, or NULL if the list is empty.
        <return type = "anything" />
    </method>

    <method name = "append">
        Append an item to the end of the list, return 0 if OK or -1 if this
        failed for some reason (out of memory). Note that if a duplicator has
        been set, this method will also duplicate the item.
        <argument name = "item" type = "anything" />
        <return type = "integer" />
    </method>

    <method name = "push">
        Push an item to the start of the list, return 0 if OK or -1 if this
        failed for some reason (out of memory). Note that if a duplicator has
        been set, this method will also duplicate the item.
        <argument name = "item" type = "anything" />
        <return type = "integer" />
    </method>

    <method name = "pop">
        Pop the item off the start of the list, if any
        <return type = "anything" />
    </method>

    <method name = "exists">
        Checks if an item already is present. Uses compare method to determine if
        items are equal. If the compare method is NULL the check will only compare
        pointers. Returns true if item is present else false.
        <argument name = "item" type = "anything" />
        <return type = "boolean" />
    </method>

    <method name = "remove">
        Remove the specified item from the list if present
        <argument name = "item" type = "anything" />
    </method>

    <method name = "dup">
        Make a copy of list. If the list has autofree set, the copied list will
        duplicate all items, which must be strings. Otherwise, the list will hold
        pointers back to the items in the original list. If list is null, returns
        NULL.
        <return type = "zlist" fresh = "1" />
    </method>

    <method name = "purge">
        Purge all items from list
    </method>

    <method name = "size">
        Return number of items in the list
        <return type = "size" />
    </method>

    <method name = "sort">
        Sort the list. If the compare function is null, sorts the list by
        ascending key value using a straight ASCII comparison. If you specify
        a compare function, this decides how items are sorted. The sort is not
        stable, so may reorder items with the same keys. The algorithm used is
        combsort, a compromise between performance and simplicity.
        <argument name = "compare" type = "zlist_compare_fn" callback = "1" />
    </method>

    <method name = "autofree">
        Set list for automatic item destruction; item values MUST be strings.
        By default a list item refers to a value held elsewhere. When you set
        this, each time you append or push a list item, zlist will take a copy
        of the string value. Then, when you destroy the list, it will free all
        item values automatically. If you use any other technique to allocate
        list values, you must free them explicitly before destroying the list.
        The usual technique is to pop list items and destroy them, until the
        list is empty.
    </method>

    <method name = "comparefn">
        Sets a compare function for this list. The function compares two items.
        It returns an integer less than, equal to, or greater than zero if the
        first item is found, respectively, to be less than, to match, or be
        greater than the second item.
        This function is used for sorting, removal and exists checking.
        <argument name = "fn" type = "zlist_compare_fn" callback = "1" />
    </method>

    <method name = "freefn">
        Set a free function for the specified list item. When the item is
        destroyed, the free function, if any, is called on that item.
        Use this when list items are dynamically allocated, to ensure that
        you don't have memory leaks. You can pass 'free' or NULL as a free_fn.
        Returns the item, or NULL if there is no such item.
        <argument name = "item" type = "anything" />
        <argument name = "fn" type = "zlist_free_fn" callback = "1" />
        <argument name = "at tail" type = "boolean" />
        <return type = "anything" />
    </method>
</class>