Beast - Music Synthesizer and Composer  0.11.1+10.g2da35
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 
8 /* --- basic comparisons --- */
9 typedef gint (*SfiCompareFunc) (gconstpointer value1,
10  gconstpointer value2,
11  gpointer data);
12 gint sfi_pointer_cmp (gconstpointer value1,
13  gconstpointer value2,
14  gpointer dummy);
15 
16 
17 /* --- ring (circular-list) --- */
18 typedef gpointer (*SfiRingDataFunc) (gpointer data,
19  gpointer func_data);
20 typedef struct SfiRing SfiRing;
21 struct SfiRing
22 {
23  gpointer data;
24  SfiRing *next;
25  SfiRing *prev;
26 };
27 SfiRing* sfi_ring_prepend (SfiRing *head,
28  gpointer data);
29 SfiRing* sfi_ring_prepend_uniq (SfiRing *head,
30  gpointer data);
31 SfiRing* sfi_ring_append (SfiRing *head,
32  gpointer data);
33 SfiRing* sfi_ring_append_uniq (SfiRing *head,
34  gpointer data);
35 SfiRing* sfi_ring_insert (SfiRing *head,
36  gpointer data,
37  gint position);
38 SfiRing* sfi_ring_insert_before (SfiRing *head,
39  SfiRing *sibling,
40  gpointer data);
41 gint sfi_ring_position (const SfiRing *head,
42  const SfiRing *node);
43 gint sfi_ring_index (const SfiRing *head,
44  gconstpointer data);
45 SfiRing* sfi_ring_nth (const SfiRing *head,
46  guint n);
47 gpointer sfi_ring_nth_data (const SfiRing *head,
48  guint n);
49 SfiRing* sfi_ring_find (const SfiRing *head,
50  gconstpointer data);
51 SfiRing* sfi_ring_remove_node (SfiRing *head,
52  SfiRing *node);
53 SfiRing* sfi_ring_remove (SfiRing *head,
54  gpointer data);
55 guint sfi_ring_length (const SfiRing *head);
56 gint sfi_ring_cmp_length (const SfiRing *head,
57  guint test_length);
58 SfiRing* sfi_ring_copy (const SfiRing *head);
59 SfiRing* sfi_ring_copy_deep (const SfiRing *head,
60  SfiRingDataFunc copy,
61  gpointer func_data);
62 SfiRing* sfi_ring_copy_rest (const SfiRing *ring,
63  const SfiRing *head);
64 SfiRing* sfi_ring_concat (SfiRing *head1,
65  SfiRing *head2);
67  SfiRing *head2);
68 SfiRing* sfi_ring_reverse (SfiRing *head);
69 gpointer sfi_ring_pop_head (SfiRing **head);
70 gpointer sfi_ring_pop_tail (SfiRing **head);
71 #define sfi_ring_push_head sfi_ring_prepend
72 #define sfi_ring_push_tail sfi_ring_append
73 void sfi_ring_free (SfiRing *head);
74 void sfi_ring_free_deep (SfiRing *head,
75  GDestroyNotify data_destroy);
76 
77 SfiRing* sfi_ring_from_list (GList *list);
78 SfiRing* sfi_ring_from_list_and_free (GList *list);
79 SfiRing* sfi_ring_from_slist (GSList *slist);
80 SfiRing* sfi_ring_from_slist_and_free (GSList *slist);
81 #define sfi_ring_tail(head) ((head) ? (head)->prev : NULL)
82 #define sfi_ring_walk(node,head_bound) ((node)->next != (head_bound) ? (node)->next : NULL)
83 #define sfi_ring_next(node,head_bound) sfi_ring_walk (node, head_bound)
84 
85 
86 /* ring-modifying cmp-based operations */
87 SfiRing* sfi_ring_insert_sorted (SfiRing *head,
88  gpointer insertion_data,
89  SfiCompareFunc cmp,
90  gpointer cmp_data);
91 SfiRing* sfi_ring_merge_sorted (SfiRing *head1,
92  SfiRing *head2,
93  SfiCompareFunc cmp,
94  gpointer data);
95 SfiRing* sfi_ring_sort (SfiRing *head,
96  SfiCompareFunc cmp,
97  gpointer data);
98 SfiRing* sfi_ring_uniq (SfiRing *sorted_ring1,
99  SfiCompareFunc cmp,
100  gpointer data);
101 SfiRing* sfi_ring_uniq_free_deep (SfiRing *sorted_ring1,
102  SfiCompareFunc cmp,
103  gpointer data,
104  GDestroyNotify data_destroy);
105 SfiRing* sfi_ring_reorder (SfiRing *unordered_ring,
106  const SfiRing *new_ring_order);
107 /* ring-copying cmp-based operations */
108 SfiRing* sfi_ring_copy_deep_uniq (const SfiRing *sorted_ring1,
109  SfiRingDataFunc copy,
110  gpointer copy_data,
111  SfiCompareFunc cmp,
112  gpointer cmp_data);
113 SfiRing* sfi_ring_copy_uniq (const SfiRing *sorted_ring1,
114  SfiCompareFunc cmp,
115  gpointer data);
116 SfiRing* sfi_ring_union (const SfiRing *sorted_set1,
117  const SfiRing *sorted_set2,
118  SfiCompareFunc cmp,
119  gpointer data);
120 SfiRing* sfi_ring_intersection (const SfiRing *sorted_set1,
121  const SfiRing *sorted_set2,
122  SfiCompareFunc cmp,
123  gpointer data);
124 SfiRing* sfi_ring_difference (const SfiRing *sorted_set1,
125  const SfiRing *sorted_set2,
126  SfiCompareFunc cmp,
127  gpointer data);
128 SfiRing* sfi_ring_symmetric_difference (const SfiRing *sorted_set1,
129  const SfiRing *sorted_set2,
130  SfiCompareFunc cmp,
131  gpointer data);
132 /* const-result cmp-based operations */
133 gboolean sfi_ring_includes (const SfiRing *sorted_super_set,
134  const SfiRing *sorted_sub_set,
135  SfiCompareFunc cmp,
136  gpointer data);
137 gboolean sfi_ring_mismatch (SfiRing **sorted_ring1_p,
138  SfiRing **sorted_ring2_p,
139  SfiCompareFunc cmp,
140  gpointer data);
141 gboolean sfi_ring_equals (const SfiRing *sorted_set1,
142  const SfiRing *sorted_set2,
143  SfiCompareFunc cmp,
144  gpointer data);
145 SfiRing* sfi_ring_min_node (const SfiRing *head,
146  SfiCompareFunc cmp,
147  gpointer data);
148 SfiRing* sfi_ring_max_node (const SfiRing *head,
149  SfiCompareFunc cmp,
150  gpointer data);
151 gpointer sfi_ring_min (const SfiRing *head,
152  SfiCompareFunc cmp,
153  gpointer data);
154 gpointer sfi_ring_max (const SfiRing *head,
155  SfiCompareFunc cmp,
156  gpointer data);
157 
158 #endif /* __SFI_RING_H__ */
159 
160 /* 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:21
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