BEAST - Free Software Audio Synthesizer and Tracker  0.10.0
sfiring.hh
Go to the documentation of this file.
1  // Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html
2 #ifndef __SFI_RING_H__
3 #define __SFI_RING_H__
4 
5 #include <sfi/sfitypes.hh>
6 
7 G_BEGIN_DECLS;
8 
9 
10 /* --- basic comparisons --- */
11 typedef gint (*SfiCompareFunc) (gconstpointer value1,
12  gconstpointer value2,
13  gpointer data);
14 gint sfi_pointer_cmp (gconstpointer value1,
15  gconstpointer value2,
16  gpointer dummy);
17 
18 
19 /* --- ring (circular-list) --- */
20 typedef gpointer (*SfiRingDataFunc) (gpointer data,
21  gpointer func_data);
22 typedef struct SfiRing SfiRing;
23 struct SfiRing
24 {
25  gpointer data;
26  SfiRing *next;
27  SfiRing *prev;
28 };
29 SfiRing* sfi_ring_prepend (SfiRing *head,
30  gpointer data);
31 SfiRing* sfi_ring_prepend_uniq (SfiRing *head,
32  gpointer data);
33 SfiRing* sfi_ring_append (SfiRing *head,
34  gpointer data);
35 SfiRing* sfi_ring_append_uniq (SfiRing *head,
36  gpointer data);
37 SfiRing* sfi_ring_insert (SfiRing *head,
38  gpointer data,
39  gint position);
40 SfiRing* sfi_ring_insert_before (SfiRing *head,
41  SfiRing *sibling,
42  gpointer data);
43 gint sfi_ring_position (const SfiRing *head,
44  const SfiRing *node);
45 gint sfi_ring_index (const SfiRing *head,
46  gconstpointer data);
47 SfiRing* sfi_ring_nth (const SfiRing *head,
48  guint n);
49 gpointer sfi_ring_nth_data (const SfiRing *head,
50  guint n);
51 SfiRing* sfi_ring_find (const SfiRing *head,
52  gconstpointer data);
53 SfiRing* sfi_ring_remove_node (SfiRing *head,
54  SfiRing *node);
55 SfiRing* sfi_ring_remove (SfiRing *head,
56  gpointer data);
57 guint sfi_ring_length (const SfiRing *head);
58 gint sfi_ring_cmp_length (const SfiRing *head,
59  guint test_length);
60 SfiRing* sfi_ring_copy (const SfiRing *head);
61 SfiRing* sfi_ring_copy_deep (const SfiRing *head,
62  SfiRingDataFunc copy,
63  gpointer func_data);
64 SfiRing* sfi_ring_copy_rest (const SfiRing *ring,
65  const SfiRing *head);
66 SfiRing* sfi_ring_concat (SfiRing *head1,
67  SfiRing *head2);
69  SfiRing *head2);
70 SfiRing* sfi_ring_reverse (SfiRing *head);
71 gpointer sfi_ring_pop_head (SfiRing **head);
72 gpointer sfi_ring_pop_tail (SfiRing **head);
73 #define sfi_ring_push_head sfi_ring_prepend
74 #define sfi_ring_push_tail sfi_ring_append
75 void sfi_ring_free (SfiRing *head);
76 void sfi_ring_free_deep (SfiRing *head,
77  GDestroyNotify data_destroy);
78 
79 SfiRing* sfi_ring_from_list (GList *list);
80 SfiRing* sfi_ring_from_list_and_free (GList *list);
81 SfiRing* sfi_ring_from_slist (GSList *slist);
82 SfiRing* sfi_ring_from_slist_and_free (GSList *slist);
83 #define sfi_ring_tail(head) ((head) ? (head)->prev : NULL)
84 #define sfi_ring_walk(node,head_bound) ((node)->next != (head_bound) ? (node)->next : NULL)
85 #define sfi_ring_next(node,head_bound) sfi_ring_walk (node, head_bound)
86 
87 
88 /* ring-modifying cmp-based operations */
89 SfiRing* sfi_ring_insert_sorted (SfiRing *head,
90  gpointer insertion_data,
91  SfiCompareFunc cmp,
92  gpointer cmp_data);
93 SfiRing* sfi_ring_merge_sorted (SfiRing *head1,
94  SfiRing *head2,
95  SfiCompareFunc cmp,
96  gpointer data);
97 SfiRing* sfi_ring_sort (SfiRing *head,
98  SfiCompareFunc cmp,
99  gpointer data);
100 SfiRing* sfi_ring_uniq (SfiRing *sorted_ring1,
101  SfiCompareFunc cmp,
102  gpointer data);
103 SfiRing* sfi_ring_uniq_free_deep (SfiRing *sorted_ring1,
104  SfiCompareFunc cmp,
105  gpointer data,
106  GDestroyNotify data_destroy);
107 SfiRing* sfi_ring_reorder (SfiRing *unordered_ring,
108  const SfiRing *new_ring_order);
109 /* ring-copying cmp-based operations */
110 SfiRing* sfi_ring_copy_deep_uniq (const SfiRing *sorted_ring1,
111  SfiRingDataFunc copy,
112  gpointer copy_data,
113  SfiCompareFunc cmp,
114  gpointer cmp_data);
115 SfiRing* sfi_ring_copy_uniq (const SfiRing *sorted_ring1,
116  SfiCompareFunc cmp,
117  gpointer data);
118 SfiRing* sfi_ring_union (const SfiRing *sorted_set1,
119  const SfiRing *sorted_set2,
120  SfiCompareFunc cmp,
121  gpointer data);
122 SfiRing* sfi_ring_intersection (const SfiRing *sorted_set1,
123  const SfiRing *sorted_set2,
124  SfiCompareFunc cmp,
125  gpointer data);
126 SfiRing* sfi_ring_difference (const SfiRing *sorted_set1,
127  const SfiRing *sorted_set2,
128  SfiCompareFunc cmp,
129  gpointer data);
130 SfiRing* sfi_ring_symmetric_difference (const SfiRing *sorted_set1,
131  const SfiRing *sorted_set2,
132  SfiCompareFunc cmp,
133  gpointer data);
134 /* const-result cmp-based operations */
135 gboolean sfi_ring_includes (const SfiRing *sorted_super_set,
136  const SfiRing *sorted_sub_set,
137  SfiCompareFunc cmp,
138  gpointer data);
139 gboolean sfi_ring_mismatch (SfiRing **sorted_ring1_p,
140  SfiRing **sorted_ring2_p,
141  SfiCompareFunc cmp,
142  gpointer data);
143 gboolean sfi_ring_equals (const SfiRing *sorted_set1,
144  const SfiRing *sorted_set2,
145  SfiCompareFunc cmp,
146  gpointer data);
147 SfiRing* sfi_ring_min_node (const SfiRing *head,
148  SfiCompareFunc cmp,
149  gpointer data);
150 SfiRing* sfi_ring_max_node (const SfiRing *head,
151  SfiCompareFunc cmp,
152  gpointer data);
153 gpointer sfi_ring_min (const SfiRing *head,
154  SfiCompareFunc cmp,
155  gpointer data);
156 gpointer sfi_ring_max (const SfiRing *head,
157  SfiCompareFunc cmp,
158  gpointer data);
159 
160 G_END_DECLS;
161 
162 #endif /* __SFI_RING_H__ */
163 
164 /* vim:set ts=8 sts=2 sw=2: */
gpointer sfi_ring_min(const SfiRing *head, SfiCompareFunc cmp, gpointer data)
Definition: sfiring.cc:1132
SfiRing * sfi_ring_min_node(const SfiRing *head, SfiCompareFunc cmp, gpointer data)
Definition: sfiring.cc:1082
SfiRing * sfi_ring_max_node(const SfiRing *head, SfiCompareFunc cmp, gpointer data)
Definition: sfiring.cc:1107
SfiRing * sfi_ring_symmetric_difference(const SfiRing *sorted_set1, const SfiRing *sorted_set2, SfiCompareFunc cmp, gpointer data)
Definition: sfiring.cc:860
SfiRing * sfi_ring_difference(const SfiRing *sorted_set1, const SfiRing *sorted_set2, SfiCompareFunc cmp, gpointer data)
Definition: sfiring.cc:819
gboolean sfi_ring_equals(const SfiRing *sorted_set1, const SfiRing *sorted_set2, SfiCompareFunc cmp, gpointer data)
Definition: sfiring.cc:1022
SfiRing * sfi_ring_union(const SfiRing *sorted_set1, const SfiRing *sorted_set2, SfiCompareFunc cmp, gpointer data)
Definition: sfiring.cc:734
Definition: sfiring.hh:23
SfiRing * sfi_ring_reorder(SfiRing *unordered_ring, const SfiRing *new_ring_order)
Definition: sfiring.cc:933
SfiRing * sfi_ring_split(SfiRing *head1, SfiRing *head2)
Definition: sfiring.cc:243
gboolean sfi_ring_mismatch(SfiRing **sorted_ring1_p, SfiRing **sorted_ring2_p, SfiCompareFunc cmp, gpointer data)
Definition: sfiring.cc:1050
SfiRing * sfi_ring_intersection(const SfiRing *sorted_set1, const SfiRing *sorted_set2, SfiCompareFunc cmp, gpointer data)
Definition: sfiring.cc:781
gpointer sfi_ring_max(const SfiRing *head, SfiCompareFunc cmp, gpointer data)
Definition: sfiring.cc:1150