BEAST/BSE - Better Audio System and Sound Engine
0.8.2
|
00001 // Licensed GNU LGPL v2.1 or later: http://www.gnu.org/licenses/lgpl.html 00002 #ifndef __SFI_RING_H__ 00003 #define __SFI_RING_H__ 00004 00005 #include <sfi/sfitypes.hh> 00006 00007 G_BEGIN_DECLS; 00008 00009 00010 /* --- basic comparisons --- */ 00011 typedef gint (*SfiCompareFunc) (gconstpointer value1, 00012 gconstpointer value2, 00013 gpointer data); 00014 gint sfi_pointer_cmp (gconstpointer value1, 00015 gconstpointer value2, 00016 gpointer dummy); 00017 00018 00019 /* --- ring (circular-list) --- */ 00020 typedef gpointer (*SfiRingDataFunc) (gpointer data, 00021 gpointer func_data); 00022 typedef struct SfiRing SfiRing; 00023 struct SfiRing 00024 { 00025 gpointer data; 00026 SfiRing *next; 00027 SfiRing *prev; 00028 }; 00029 SfiRing* sfi_ring_prepend (SfiRing *head, 00030 gpointer data); 00031 SfiRing* sfi_ring_prepend_uniq (SfiRing *head, 00032 gpointer data); 00033 SfiRing* sfi_ring_append (SfiRing *head, 00034 gpointer data); 00035 SfiRing* sfi_ring_append_uniq (SfiRing *head, 00036 gpointer data); 00037 SfiRing* sfi_ring_insert (SfiRing *head, 00038 gpointer data, 00039 gint position); 00040 SfiRing* sfi_ring_insert_before (SfiRing *head, 00041 SfiRing *sibling, 00042 gpointer data); 00043 gint sfi_ring_position (const SfiRing *head, 00044 const SfiRing *node); 00045 gint sfi_ring_index (const SfiRing *head, 00046 gconstpointer data); 00047 SfiRing* sfi_ring_nth (const SfiRing *head, 00048 guint n); 00049 gpointer sfi_ring_nth_data (const SfiRing *head, 00050 guint n); 00051 SfiRing* sfi_ring_find (const SfiRing *head, 00052 gconstpointer data); 00053 SfiRing* sfi_ring_remove_node (SfiRing *head, 00054 SfiRing *node); 00055 SfiRing* sfi_ring_remove (SfiRing *head, 00056 gpointer data); 00057 guint sfi_ring_length (const SfiRing *head); 00058 gint sfi_ring_cmp_length (const SfiRing *head, 00059 guint test_length); 00060 SfiRing* sfi_ring_copy (const SfiRing *head); 00061 SfiRing* sfi_ring_copy_deep (const SfiRing *head, 00062 SfiRingDataFunc copy, 00063 gpointer func_data); 00064 SfiRing* sfi_ring_copy_rest (const SfiRing *ring, 00065 const SfiRing *head); 00066 SfiRing* sfi_ring_concat (SfiRing *head1, 00067 SfiRing *head2); 00068 SfiRing* sfi_ring_split (SfiRing *head1, 00069 SfiRing *head2); 00070 SfiRing* sfi_ring_reverse (SfiRing *head); 00071 gpointer sfi_ring_pop_head (SfiRing **head); 00072 gpointer sfi_ring_pop_tail (SfiRing **head); 00073 #define sfi_ring_push_head sfi_ring_prepend 00074 #define sfi_ring_push_tail sfi_ring_append 00075 void sfi_ring_free (SfiRing *head); 00076 void sfi_ring_free_deep (SfiRing *head, 00077 GDestroyNotify data_destroy); 00078 00079 SfiRing* sfi_ring_from_list (GList *list); 00080 SfiRing* sfi_ring_from_list_and_free (GList *list); 00081 SfiRing* sfi_ring_from_slist (GSList *slist); 00082 SfiRing* sfi_ring_from_slist_and_free (GSList *slist); 00083 #define sfi_ring_tail(head) ((head) ? (head)->prev : NULL) 00084 #define sfi_ring_walk(node,head_bound) ((node)->next != (head_bound) ? (node)->next : NULL) 00085 #define sfi_ring_next(node,head_bound) sfi_ring_walk (node, head_bound) 00086 00087 00088 /* ring-modifying cmp-based operations */ 00089 SfiRing* sfi_ring_insert_sorted (SfiRing *head, 00090 gpointer insertion_data, 00091 SfiCompareFunc cmp, 00092 gpointer cmp_data); 00093 SfiRing* sfi_ring_merge_sorted (SfiRing *head1, 00094 SfiRing *head2, 00095 SfiCompareFunc cmp, 00096 gpointer data); 00097 SfiRing* sfi_ring_sort (SfiRing *head, 00098 SfiCompareFunc cmp, 00099 gpointer data); 00100 SfiRing* sfi_ring_uniq (SfiRing *sorted_ring1, 00101 SfiCompareFunc cmp, 00102 gpointer data); 00103 SfiRing* sfi_ring_uniq_free_deep (SfiRing *sorted_ring1, 00104 SfiCompareFunc cmp, 00105 gpointer data, 00106 GDestroyNotify data_destroy); 00107 SfiRing* sfi_ring_reorder (SfiRing *unordered_ring, 00108 const SfiRing *new_ring_order); 00109 /* ring-copying cmp-based operations */ 00110 SfiRing* sfi_ring_copy_deep_uniq (const SfiRing *sorted_ring1, 00111 SfiRingDataFunc copy, 00112 gpointer copy_data, 00113 SfiCompareFunc cmp, 00114 gpointer cmp_data); 00115 SfiRing* sfi_ring_copy_uniq (const SfiRing *sorted_ring1, 00116 SfiCompareFunc cmp, 00117 gpointer data); 00118 SfiRing* sfi_ring_union (const SfiRing *sorted_set1, 00119 const SfiRing *sorted_set2, 00120 SfiCompareFunc cmp, 00121 gpointer data); 00122 SfiRing* sfi_ring_intersection (const SfiRing *sorted_set1, 00123 const SfiRing *sorted_set2, 00124 SfiCompareFunc cmp, 00125 gpointer data); 00126 SfiRing* sfi_ring_difference (const SfiRing *sorted_set1, 00127 const SfiRing *sorted_set2, 00128 SfiCompareFunc cmp, 00129 gpointer data); 00130 SfiRing* sfi_ring_symmetric_difference (const SfiRing *sorted_set1, 00131 const SfiRing *sorted_set2, 00132 SfiCompareFunc cmp, 00133 gpointer data); 00134 /* const-result cmp-based operations */ 00135 gboolean sfi_ring_includes (const SfiRing *sorted_super_set, 00136 const SfiRing *sorted_sub_set, 00137 SfiCompareFunc cmp, 00138 gpointer data); 00139 gboolean sfi_ring_mismatch (SfiRing **sorted_ring1_p, 00140 SfiRing **sorted_ring2_p, 00141 SfiCompareFunc cmp, 00142 gpointer data); 00143 gboolean sfi_ring_equals (const SfiRing *sorted_set1, 00144 const SfiRing *sorted_set2, 00145 SfiCompareFunc cmp, 00146 gpointer data); 00147 SfiRing* sfi_ring_min_node (const SfiRing *head, 00148 SfiCompareFunc cmp, 00149 gpointer data); 00150 SfiRing* sfi_ring_max_node (const SfiRing *head, 00151 SfiCompareFunc cmp, 00152 gpointer data); 00153 gpointer sfi_ring_min (const SfiRing *head, 00154 SfiCompareFunc cmp, 00155 gpointer data); 00156 gpointer sfi_ring_max (const SfiRing *head, 00157 SfiCompareFunc cmp, 00158 gpointer data); 00159 00160 G_END_DECLS; 00161 00162 #endif /* __SFI_RING_H__ */ 00163 00164 /* vim:set ts=8 sts=2 sw=2: */