1 /* timsort.c generated by valac 0.18.0, the Vala compiler
2 * generated from timsort.vala, do not modify */
6 * Copyright (C) 2009 Didier Villevalois
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
23 * Didier 'Ptitjes Villevalois <ptitjes@free.fr>
27 #include <glib-object.h>
31 #define GEE_TYPE_TIM_SORT (gee_tim_sort_get_type ())
32 #define GEE_TIM_SORT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_TIM_SORT, GeeTimSort))
33 #define GEE_TIM_SORT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEE_TYPE_TIM_SORT, GeeTimSortClass))
34 #define GEE_IS_TIM_SORT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_TIM_SORT))
35 #define GEE_IS_TIM_SORT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEE_TYPE_TIM_SORT))
36 #define GEE_TIM_SORT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEE_TYPE_TIM_SORT, GeeTimSortClass))
38 typedef struct _GeeTimSort GeeTimSort;
39 typedef struct _GeeTimSortClass GeeTimSortClass;
40 typedef struct _GeeTimSortPrivate GeeTimSortPrivate;
42 #define GEE_TYPE_TRAVERSABLE (gee_traversable_get_type ())
43 #define GEE_TRAVERSABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_TRAVERSABLE, GeeTraversable))
44 #define GEE_IS_TRAVERSABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_TRAVERSABLE))
45 #define GEE_TRAVERSABLE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GEE_TYPE_TRAVERSABLE, GeeTraversableIface))
47 typedef struct _GeeTraversable GeeTraversable;
48 typedef struct _GeeTraversableIface GeeTraversableIface;
50 #define GEE_TRAVERSABLE_TYPE_STREAM (gee_traversable_stream_get_type ())
52 #define GEE_TYPE_LAZY (gee_lazy_get_type ())
53 #define GEE_LAZY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_LAZY, GeeLazy))
54 #define GEE_LAZY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEE_TYPE_LAZY, GeeLazyClass))
55 #define GEE_IS_LAZY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_LAZY))
56 #define GEE_IS_LAZY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEE_TYPE_LAZY))
57 #define GEE_LAZY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEE_TYPE_LAZY, GeeLazyClass))
59 typedef struct _GeeLazy GeeLazy;
60 typedef struct _GeeLazyClass GeeLazyClass;
62 #define GEE_TYPE_ITERATOR (gee_iterator_get_type ())
63 #define GEE_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_ITERATOR, GeeIterator))
64 #define GEE_IS_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_ITERATOR))
65 #define GEE_ITERATOR_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GEE_TYPE_ITERATOR, GeeIteratorIface))
67 typedef struct _GeeIterator GeeIterator;
68 typedef struct _GeeIteratorIface GeeIteratorIface;
70 #define GEE_TYPE_ITERABLE (gee_iterable_get_type ())
71 #define GEE_ITERABLE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_ITERABLE, GeeIterable))
72 #define GEE_IS_ITERABLE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_ITERABLE))
73 #define GEE_ITERABLE_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GEE_TYPE_ITERABLE, GeeIterableIface))
75 typedef struct _GeeIterable GeeIterable;
76 typedef struct _GeeIterableIface GeeIterableIface;
78 #define GEE_TYPE_COLLECTION (gee_collection_get_type ())
79 #define GEE_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_COLLECTION, GeeCollection))
80 #define GEE_IS_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_COLLECTION))
81 #define GEE_COLLECTION_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GEE_TYPE_COLLECTION, GeeCollectionIface))
83 typedef struct _GeeCollection GeeCollection;
84 typedef struct _GeeCollectionIface GeeCollectionIface;
86 #define GEE_TYPE_LIST (gee_list_get_type ())
87 #define GEE_LIST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_LIST, GeeList))
88 #define GEE_IS_LIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_LIST))
89 #define GEE_LIST_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GEE_TYPE_LIST, GeeListIface))
91 typedef struct _GeeList GeeList;
92 typedef struct _GeeListIface GeeListIface;
94 #define GEE_TYPE_LIST_ITERATOR (gee_list_iterator_get_type ())
95 #define GEE_LIST_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_LIST_ITERATOR, GeeListIterator))
96 #define GEE_IS_LIST_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_LIST_ITERATOR))
97 #define GEE_LIST_ITERATOR_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GEE_TYPE_LIST_ITERATOR, GeeListIteratorIface))
99 typedef struct _GeeListIterator GeeListIterator;
100 typedef struct _GeeListIteratorIface GeeListIteratorIface;
101 typedef struct _GeeTimSortSlice GeeTimSortSlice;
102 #define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
104 #define GEE_TYPE_ABSTRACT_COLLECTION (gee_abstract_collection_get_type ())
105 #define GEE_ABSTRACT_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_ABSTRACT_COLLECTION, GeeAbstractCollection))
106 #define GEE_ABSTRACT_COLLECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEE_TYPE_ABSTRACT_COLLECTION, GeeAbstractCollectionClass))
107 #define GEE_IS_ABSTRACT_COLLECTION(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_ABSTRACT_COLLECTION))
108 #define GEE_IS_ABSTRACT_COLLECTION_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEE_TYPE_ABSTRACT_COLLECTION))
109 #define GEE_ABSTRACT_COLLECTION_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEE_TYPE_ABSTRACT_COLLECTION, GeeAbstractCollectionClass))
111 typedef struct _GeeAbstractCollection GeeAbstractCollection;
112 typedef struct _GeeAbstractCollectionClass GeeAbstractCollectionClass;
114 #define GEE_TYPE_ABSTRACT_LIST (gee_abstract_list_get_type ())
115 #define GEE_ABSTRACT_LIST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_ABSTRACT_LIST, GeeAbstractList))
116 #define GEE_ABSTRACT_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEE_TYPE_ABSTRACT_LIST, GeeAbstractListClass))
117 #define GEE_IS_ABSTRACT_LIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_ABSTRACT_LIST))
118 #define GEE_IS_ABSTRACT_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEE_TYPE_ABSTRACT_LIST))
119 #define GEE_ABSTRACT_LIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEE_TYPE_ABSTRACT_LIST, GeeAbstractListClass))
121 typedef struct _GeeAbstractList GeeAbstractList;
122 typedef struct _GeeAbstractListClass GeeAbstractListClass;
124 #define GEE_TYPE_ABSTRACT_BIDIR_LIST (gee_abstract_bidir_list_get_type ())
125 #define GEE_ABSTRACT_BIDIR_LIST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_ABSTRACT_BIDIR_LIST, GeeAbstractBidirList))
126 #define GEE_ABSTRACT_BIDIR_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEE_TYPE_ABSTRACT_BIDIR_LIST, GeeAbstractBidirListClass))
127 #define GEE_IS_ABSTRACT_BIDIR_LIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_ABSTRACT_BIDIR_LIST))
128 #define GEE_IS_ABSTRACT_BIDIR_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEE_TYPE_ABSTRACT_BIDIR_LIST))
129 #define GEE_ABSTRACT_BIDIR_LIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEE_TYPE_ABSTRACT_BIDIR_LIST, GeeAbstractBidirListClass))
131 typedef struct _GeeAbstractBidirList GeeAbstractBidirList;
132 typedef struct _GeeAbstractBidirListClass GeeAbstractBidirListClass;
134 #define GEE_TYPE_ARRAY_LIST (gee_array_list_get_type ())
135 #define GEE_ARRAY_LIST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_ARRAY_LIST, GeeArrayList))
136 #define GEE_ARRAY_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GEE_TYPE_ARRAY_LIST, GeeArrayListClass))
137 #define GEE_IS_ARRAY_LIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_ARRAY_LIST))
138 #define GEE_IS_ARRAY_LIST_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GEE_TYPE_ARRAY_LIST))
139 #define GEE_ARRAY_LIST_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GEE_TYPE_ARRAY_LIST, GeeArrayListClass))
141 typedef struct _GeeArrayList GeeArrayList;
142 typedef struct _GeeArrayListClass GeeArrayListClass;
143 #define _g_destroy_func0(var) (((var == NULL) || (g_destroy_func == NULL)) ? NULL : (var = (g_destroy_func (var), NULL)))
144 typedef struct _GeeAbstractCollectionPrivate GeeAbstractCollectionPrivate;
145 typedef struct _GeeAbstractListPrivate GeeAbstractListPrivate;
147 #define GEE_TYPE_BIDIR_LIST (gee_bidir_list_get_type ())
148 #define GEE_BIDIR_LIST(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_BIDIR_LIST, GeeBidirList))
149 #define GEE_IS_BIDIR_LIST(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_BIDIR_LIST))
150 #define GEE_BIDIR_LIST_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GEE_TYPE_BIDIR_LIST, GeeBidirListIface))
152 typedef struct _GeeBidirList GeeBidirList;
153 typedef struct _GeeBidirListIface GeeBidirListIface;
155 #define GEE_TYPE_BIDIR_ITERATOR (gee_bidir_iterator_get_type ())
156 #define GEE_BIDIR_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_BIDIR_ITERATOR, GeeBidirIterator))
157 #define GEE_IS_BIDIR_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_BIDIR_ITERATOR))
158 #define GEE_BIDIR_ITERATOR_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GEE_TYPE_BIDIR_ITERATOR, GeeBidirIteratorIface))
160 typedef struct _GeeBidirIterator GeeBidirIterator;
161 typedef struct _GeeBidirIteratorIface GeeBidirIteratorIface;
163 #define GEE_TYPE_BIDIR_LIST_ITERATOR (gee_bidir_list_iterator_get_type ())
164 #define GEE_BIDIR_LIST_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GEE_TYPE_BIDIR_LIST_ITERATOR, GeeBidirListIterator))
165 #define GEE_IS_BIDIR_LIST_ITERATOR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GEE_TYPE_BIDIR_LIST_ITERATOR))
166 #define GEE_BIDIR_LIST_ITERATOR_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GEE_TYPE_BIDIR_LIST_ITERATOR, GeeBidirListIteratorIface))
168 typedef struct _GeeBidirListIterator GeeBidirListIterator;
169 typedef struct _GeeBidirListIteratorIface GeeBidirListIteratorIface;
170 typedef struct _GeeAbstractBidirListPrivate GeeAbstractBidirListPrivate;
171 typedef struct _GeeArrayListPrivate GeeArrayListPrivate;
172 #define _gee_tim_sort_slice_free0(var) ((var == NULL) ? NULL : (var = (gee_tim_sort_slice_free (var), NULL)))
173 #define _vala_assert(expr, msg) if G_LIKELY (expr) ; else g_assertion_message_expr (G_LOG_DOMAIN, __FILE__, __LINE__, G_STRFUNC, msg);
176 GObject parent_instance;
177 GeeTimSortPrivate * priv;
180 struct _GeeTimSortClass {
181 GObjectClass parent_class;
184 typedef gboolean (*GeeForallFunc) (gpointer g, void* user_data);
186 GEE_TRAVERSABLE_STREAM_YIELD,
187 GEE_TRAVERSABLE_STREAM_CONTINUE,
188 GEE_TRAVERSABLE_STREAM_END
189 } GeeTraversableStream;
191 typedef GeeTraversableStream (*GeeStreamFunc) (GeeTraversableStream state, GeeLazy* g, GeeLazy** lazy, void* user_data);
192 struct _GeeIteratorIface {
193 GTypeInterface parent_iface;
194 gboolean (*next) (GeeIterator* self);
195 gboolean (*has_next) (GeeIterator* self);
196 gpointer (*get) (GeeIterator* self);
197 void (*remove) (GeeIterator* self);
198 gboolean (*get_valid) (GeeIterator* self);
199 gboolean (*get_read_only) (GeeIterator* self);
202 typedef gpointer (*GeeFoldFunc) (gpointer g, gpointer a, void* user_data);
203 typedef gpointer (*GeeMapFunc) (gpointer g, void* user_data);
204 typedef gboolean (*GeePredicate) (gconstpointer g, void* user_data);
205 struct _GeeTraversableIface {
206 GTypeInterface parent_iface;
207 GType (*get_g_type) (GeeTraversable* self);
208 GBoxedCopyFunc (*get_g_dup_func) (GeeTraversable* self);
209 GDestroyNotify (*get_g_destroy_func) (GeeTraversable* self);
210 gboolean (*foreach) (GeeTraversable* self, GeeForallFunc f, void* f_target);
211 GeeIterator* (*stream) (GeeTraversable* self, GType a_type, GBoxedCopyFunc a_dup_func, GDestroyNotify a_destroy_func, GeeStreamFunc f, void* f_target, GDestroyNotify f_target_destroy_notify);
212 gpointer (*fold) (GeeTraversable* self, GType a_type, GBoxedCopyFunc a_dup_func, GDestroyNotify a_destroy_func, GeeFoldFunc f, void* f_target, gpointer seed);
213 GeeIterator* (*map) (GeeTraversable* self, GType a_type, GBoxedCopyFunc a_dup_func, GDestroyNotify a_destroy_func, GeeMapFunc f, void* f_target);
214 GeeIterator* (*scan) (GeeTraversable* self, GType a_type, GBoxedCopyFunc a_dup_func, GDestroyNotify a_destroy_func, GeeFoldFunc f, void* f_target, gpointer seed);
215 GeeIterator* (*filter) (GeeTraversable* self, GeePredicate pred, void* pred_target, GDestroyNotify pred_target_destroy_notify);
216 GeeIterator* (*chop) (GeeTraversable* self, gint offset, gint length);
217 GType (*get_element_type) (GeeTraversable* self);
220 struct _GeeIterableIface {
221 GTypeInterface parent_iface;
222 GType (*get_g_type) (GeeIterable* self);
223 GBoxedCopyFunc (*get_g_dup_func) (GeeIterable* self);
224 GDestroyNotify (*get_g_destroy_func) (GeeIterable* self);
225 GeeIterator* (*iterator) (GeeIterable* self);
228 struct _GeeCollectionIface {
229 GTypeInterface parent_iface;
230 GType (*get_g_type) (GeeCollection* self);
231 GBoxedCopyFunc (*get_g_dup_func) (GeeCollection* self);
232 GDestroyNotify (*get_g_destroy_func) (GeeCollection* self);
233 gboolean (*contains) (GeeCollection* self, gconstpointer item);
234 gboolean (*add) (GeeCollection* self, gconstpointer item);
235 gboolean (*remove) (GeeCollection* self, gconstpointer item);
236 void (*clear) (GeeCollection* self);
237 gboolean (*add_all) (GeeCollection* self, GeeCollection* collection);
238 gboolean (*contains_all) (GeeCollection* self, GeeCollection* collection);
239 gboolean (*remove_all) (GeeCollection* self, GeeCollection* collection);
240 gboolean (*retain_all) (GeeCollection* self, GeeCollection* collection);
241 gpointer* (*to_array) (GeeCollection* self, int* result_length1);
242 gint (*get_size) (GeeCollection* self);
243 gboolean (*get_is_empty) (GeeCollection* self);
244 gboolean (*get_read_only) (GeeCollection* self);
245 GeeCollection* (*get_read_only_view) (GeeCollection* self);
248 struct _GeeListIteratorIface {
249 GTypeInterface parent_iface;
250 void (*set) (GeeListIterator* self, gconstpointer item);
251 void (*add) (GeeListIterator* self, gconstpointer item);
252 gint (*index) (GeeListIterator* self);
255 struct _GeeListIface {
256 GTypeInterface parent_iface;
257 GType (*get_g_type) (GeeList* self);
258 GBoxedCopyFunc (*get_g_dup_func) (GeeList* self);
259 GDestroyNotify (*get_g_destroy_func) (GeeList* self);
260 GeeListIterator* (*list_iterator) (GeeList* self);
261 gpointer (*get) (GeeList* self, gint index);
262 void (*set) (GeeList* self, gint index, gconstpointer item);
263 gint (*index_of) (GeeList* self, gconstpointer item);
264 void (*insert) (GeeList* self, gint index, gconstpointer item);
265 gpointer (*remove_at) (GeeList* self, gint index);
266 GeeList* (*slice) (GeeList* self, gint start, gint stop);
267 gpointer (*first) (GeeList* self);
268 gpointer (*last) (GeeList* self);
269 void (*insert_all) (GeeList* self, gint index, GeeCollection* collection);
270 void (*sort) (GeeList* self, GCompareDataFunc compare_func, void* compare_func_target, GDestroyNotify compare_func_target_destroy_notify);
271 GeeList* (*get_read_only_view) (GeeList* self);
274 struct _GeeTimSortPrivate {
276 GBoxedCopyFunc g_dup_func;
277 GDestroyNotify g_destroy_func;
278 GeeList* list_collection;
285 GeeTimSortSlice** pending;
286 gint pending_length1;
289 GCompareDataFunc compare;
290 gpointer compare_target;
291 GDestroyNotify compare_target_destroy_notify;
294 struct _GeeAbstractCollection {
295 GObject parent_instance;
296 GeeAbstractCollectionPrivate * priv;
299 struct _GeeAbstractCollectionClass {
300 GObjectClass parent_class;
301 gboolean (*contains) (GeeAbstractCollection* self, gconstpointer item);
302 gboolean (*add) (GeeAbstractCollection* self, gconstpointer item);
303 gboolean (*remove) (GeeAbstractCollection* self, gconstpointer item);
304 void (*clear) (GeeAbstractCollection* self);
305 GeeIterator* (*iterator) (GeeAbstractCollection* self);
306 gboolean (*foreach) (GeeAbstractCollection* self, GeeForallFunc f, void* f_target);
307 void (*reserved0) (GeeAbstractCollection* self);
308 void (*reserved1) (GeeAbstractCollection* self);
309 void (*reserved2) (GeeAbstractCollection* self);
310 void (*reserved3) (GeeAbstractCollection* self);
311 void (*reserved4) (GeeAbstractCollection* self);
312 void (*reserved5) (GeeAbstractCollection* self);
313 void (*reserved6) (GeeAbstractCollection* self);
314 void (*reserved7) (GeeAbstractCollection* self);
315 void (*reserved8) (GeeAbstractCollection* self);
316 void (*reserved9) (GeeAbstractCollection* self);
317 gint (*get_size) (GeeAbstractCollection* self);
318 gboolean (*get_read_only) (GeeAbstractCollection* self);
319 GeeCollection* (*get_read_only_view) (GeeAbstractCollection* self);
322 struct _GeeAbstractList {
323 GeeAbstractCollection parent_instance;
324 GeeAbstractListPrivate * priv;
327 struct _GeeAbstractListClass {
328 GeeAbstractCollectionClass parent_class;
329 GeeListIterator* (*list_iterator) (GeeAbstractList* self);
330 gpointer (*get) (GeeAbstractList* self, gint index);
331 void (*set) (GeeAbstractList* self, gint index, gconstpointer item);
332 gint (*index_of) (GeeAbstractList* self, gconstpointer item);
333 void (*insert) (GeeAbstractList* self, gint index, gconstpointer item);
334 gpointer (*remove_at) (GeeAbstractList* self, gint index);
335 GeeList* (*slice) (GeeAbstractList* self, gint start, gint stop);
336 void (*reserved0) (GeeAbstractList* self);
337 void (*reserved1) (GeeAbstractList* self);
338 void (*reserved2) (GeeAbstractList* self);
339 void (*reserved3) (GeeAbstractList* self);
340 void (*reserved4) (GeeAbstractList* self);
341 void (*reserved5) (GeeAbstractList* self);
342 void (*reserved6) (GeeAbstractList* self);
343 void (*reserved7) (GeeAbstractList* self);
344 void (*reserved8) (GeeAbstractList* self);
345 void (*reserved9) (GeeAbstractList* self);
346 GeeList* (*get_read_only_view) (GeeAbstractList* self);
349 struct _GeeBidirIteratorIface {
350 GTypeInterface parent_iface;
351 GType (*get_g_type) (GeeBidirIterator* self);
352 GBoxedCopyFunc (*get_g_dup_func) (GeeBidirIterator* self);
353 GDestroyNotify (*get_g_destroy_func) (GeeBidirIterator* self);
354 gboolean (*previous) (GeeBidirIterator* self);
355 gboolean (*has_previous) (GeeBidirIterator* self);
356 gboolean (*first) (GeeBidirIterator* self);
357 gboolean (*last) (GeeBidirIterator* self);
360 struct _GeeBidirListIteratorIface {
361 GTypeInterface parent_iface;
362 GType (*get_g_type) (GeeBidirListIterator* self);
363 GBoxedCopyFunc (*get_g_dup_func) (GeeBidirListIterator* self);
364 GDestroyNotify (*get_g_destroy_func) (GeeBidirListIterator* self);
365 void (*insert) (GeeBidirListIterator* self, gconstpointer item);
368 struct _GeeBidirListIface {
369 GTypeInterface parent_iface;
370 GType (*get_g_type) (GeeBidirList* self);
371 GBoxedCopyFunc (*get_g_dup_func) (GeeBidirList* self);
372 GDestroyNotify (*get_g_destroy_func) (GeeBidirList* self);
373 GeeBidirListIterator* (*bidir_list_iterator) (GeeBidirList* self);
374 GeeBidirList* (*get_read_only_view) (GeeBidirList* self);
377 struct _GeeAbstractBidirList {
378 GeeAbstractList parent_instance;
379 GeeAbstractBidirListPrivate * priv;
382 struct _GeeAbstractBidirListClass {
383 GeeAbstractListClass parent_class;
384 GeeBidirListIterator* (*bidir_list_iterator) (GeeAbstractBidirList* self);
385 void (*reserved0) (GeeAbstractBidirList* self);
386 void (*reserved1) (GeeAbstractBidirList* self);
387 void (*reserved2) (GeeAbstractBidirList* self);
388 void (*reserved3) (GeeAbstractBidirList* self);
389 void (*reserved4) (GeeAbstractBidirList* self);
390 void (*reserved5) (GeeAbstractBidirList* self);
391 void (*reserved6) (GeeAbstractBidirList* self);
392 void (*reserved7) (GeeAbstractBidirList* self);
393 void (*reserved8) (GeeAbstractBidirList* self);
394 void (*reserved9) (GeeAbstractBidirList* self);
395 GeeBidirList* (*get_read_only_view) (GeeAbstractBidirList* self);
398 struct _GeeArrayList {
399 GeeAbstractBidirList parent_instance;
400 GeeArrayListPrivate * priv;
407 struct _GeeArrayListClass {
408 GeeAbstractBidirListClass parent_class;
411 struct _GeeTimSortSlice {
418 typedef gboolean (*GeeTimSortLowerFunc) (gconstpointer left, gconstpointer right, void* user_data);
420 static gpointer gee_tim_sort_parent_class = NULL;
422 GType gee_tim_sort_get_type (void) G_GNUC_CONST;
423 GType gee_traversable_stream_get_type (void) G_GNUC_CONST;
424 gpointer gee_lazy_ref (gpointer instance);
425 void gee_lazy_unref (gpointer instance);
426 GParamSpec* gee_param_spec_lazy (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
427 void gee_value_set_lazy (GValue* value, gpointer v_object);
428 void gee_value_take_lazy (GValue* value, gpointer v_object);
429 gpointer gee_value_get_lazy (const GValue* value);
430 GType gee_lazy_get_type (void) G_GNUC_CONST;
431 GType gee_iterator_get_type (void) G_GNUC_CONST;
432 GType gee_traversable_get_type (void) G_GNUC_CONST;
433 GType gee_iterable_get_type (void) G_GNUC_CONST;
434 GType gee_collection_get_type (void) G_GNUC_CONST;
435 GType gee_list_iterator_get_type (void) G_GNUC_CONST;
436 GType gee_list_get_type (void) G_GNUC_CONST;
437 static void gee_tim_sort_slice_free (GeeTimSortSlice* self);
438 #define GEE_TIM_SORT_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), GEE_TYPE_TIM_SORT, GeeTimSortPrivate))
440 GEE_TIM_SORT_DUMMY_PROPERTY,
442 GEE_TIM_SORT_G_DUP_FUNC,
443 GEE_TIM_SORT_G_DESTROY_FUNC
445 #define GEE_TIM_SORT_MINIMUM_GALLOP 7
446 void gee_tim_sort_sort (GType g_type, GBoxedCopyFunc g_dup_func, GDestroyNotify g_destroy_func, GeeList* list, GCompareDataFunc compare, void* compare_target);
447 GType gee_abstract_collection_get_type (void) G_GNUC_CONST;
448 GType gee_abstract_list_get_type (void) G_GNUC_CONST;
449 GType gee_abstract_bidir_list_get_type (void) G_GNUC_CONST;
450 GType gee_array_list_get_type (void) G_GNUC_CONST;
451 static void gee_tim_sort_sort_arraylist (GType g_type, GBoxedCopyFunc g_dup_func, GDestroyNotify g_destroy_func, GeeArrayList* list, GCompareDataFunc compare, void* compare_target);
452 static void gee_tim_sort_sort_list (GType g_type, GBoxedCopyFunc g_dup_func, GDestroyNotify g_destroy_func, GeeList* list, GCompareDataFunc compare, void* compare_target);
453 GeeTimSort* gee_tim_sort_new (GType g_type, GBoxedCopyFunc g_dup_func, GDestroyNotify g_destroy_func);
454 GeeTimSort* gee_tim_sort_construct (GType object_type, GType g_type, GBoxedCopyFunc g_dup_func, GDestroyNotify g_destroy_func);
455 gpointer* gee_collection_to_array (GeeCollection* self, int* result_length1);
456 gint gee_collection_get_size (GeeCollection* self);
457 static void gee_tim_sort_do_sort (GeeTimSort* self);
458 void gee_collection_clear (GeeCollection* self);
459 gboolean gee_collection_add (GeeCollection* self, gconstpointer item);
460 GType gee_bidir_iterator_get_type (void) G_GNUC_CONST;
461 GType gee_bidir_list_iterator_get_type (void) G_GNUC_CONST;
462 GType gee_bidir_list_get_type (void) G_GNUC_CONST;
463 static GeeTimSortSlice* gee_tim_sort_slice_new (void** list, gint index, gint length);
464 static GeeTimSortSlice* gee_tim_sort_slice_new (void** list, gint index, gint length);
465 static gint gee_tim_sort_compute_minimum_run_length (GeeTimSort* self, gint length);
466 static GeeTimSortSlice* gee_tim_sort_compute_longest_run (GeeTimSort* self, GeeTimSortSlice* a, gboolean* descending);
467 static void gee_tim_sort_slice_reverse (GeeTimSortSlice* self);
468 static void gee_tim_sort_insertion_sort (GeeTimSort* self, GeeTimSortSlice* a, gint offset);
469 static inline void gee_tim_sort_slice_shorten_start (GeeTimSortSlice* self, gint n);
470 static void _vala_array_add1 (GeeTimSortSlice*** array, int* length, int* size, GeeTimSortSlice* value);
471 static void gee_tim_sort_merge_collapse (GeeTimSort* self);
472 static void gee_tim_sort_merge_force_collapse (GeeTimSort* self);
473 static inline gboolean gee_tim_sort_lower_than (GeeTimSort* self, gconstpointer left, gconstpointer right);
474 static inline gboolean gee_tim_sort_lower_than_or_equal_to (GeeTimSort* self, gconstpointer left, gconstpointer right);
475 static void gee_tim_sort_merge_at (GeeTimSort* self, gint index);
476 static gint gee_tim_sort_gallop_rightmost (GeeTimSort* self, gconstpointer key, GeeTimSortSlice* a, gint hint);
477 static inline void* gee_tim_sort_slice_peek_first (GeeTimSortSlice* self);
478 static gint gee_tim_sort_gallop_leftmost (GeeTimSort* self, gconstpointer key, GeeTimSortSlice* a, gint hint);
479 static inline void* gee_tim_sort_slice_peek_last (GeeTimSortSlice* self);
480 static void gee_tim_sort_merge_low (GeeTimSort* self, GeeTimSortSlice* a, GeeTimSortSlice* b);
481 static void gee_tim_sort_merge_high (GeeTimSort* self, GeeTimSortSlice* a, GeeTimSortSlice* b);
482 static void gee_tim_sort_slice_copy (GeeTimSortSlice* self);
483 static inline void* gee_tim_sort_slice_pop_first (GeeTimSortSlice* self);
484 static inline void gee_tim_sort_slice_merge_in (GeeTimSortSlice* self, void** dest_array, gint index, gint dest_index, gint count);
485 static inline void* gee_tim_sort_slice_pop_last (GeeTimSortSlice* self);
486 static inline void gee_tim_sort_slice_merge_in_reversed (GeeTimSortSlice* self, void** dest_array, gint index, gint dest_index, gint count);
487 static inline void gee_tim_sort_slice_shorten_end (GeeTimSortSlice* self, gint n);
488 static void gee_tim_sort_slice_instance_init (GeeTimSortSlice * self);
489 static inline void gee_tim_sort_slice_swap (GeeTimSortSlice* self, gint i, gint j);
490 static void gee_tim_sort_finalize (GObject* obj);
491 static void _vala_gee_tim_sort_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec);
492 static void _vala_gee_tim_sort_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec);
493 static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func);
494 static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);
495 static void _vala_array_move (gpointer array, gsize element_size, gint src, gint dest, gint length);
498 void gee_tim_sort_sort (GType g_type, GBoxedCopyFunc g_dup_func, GDestroyNotify g_destroy_func, GeeList* list, GCompareDataFunc compare, void* compare_target) {
500 g_return_if_fail (list != NULL);
502 if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, GEE_TYPE_ARRAY_LIST)) {
504 GCompareDataFunc _tmp2_;
508 _tmp2__target = compare_target;
509 gee_tim_sort_sort_arraylist (g_type, (GBoxedCopyFunc) g_dup_func, g_destroy_func, G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, GEE_TYPE_ARRAY_LIST, GeeArrayList), _tmp2_, _tmp2__target);
512 GCompareDataFunc _tmp4_;
516 _tmp4__target = compare_target;
517 gee_tim_sort_sort_list (g_type, (GBoxedCopyFunc) g_dup_func, g_destroy_func, _tmp3_, _tmp4_, _tmp4__target);
522 static gpointer _g_object_ref0 (gpointer self) {
523 return self ? g_object_ref (self) : NULL;
527 static void gee_tim_sort_sort_list (GType g_type, GBoxedCopyFunc g_dup_func, GDestroyNotify g_destroy_func, GeeList* list, GCompareDataFunc compare, void* compare_target) {
536 gpointer* _tmp7_ = NULL;
540 gint _tmp10__length1;
547 GCompareDataFunc _tmp17_;
548 void* _tmp17__target;
553 gint _tmp21__length1;
554 g_return_if_fail (list != NULL);
555 _tmp0_ = gee_tim_sort_new (g_type, (GBoxedCopyFunc) g_dup_func, g_destroy_func);
559 _tmp3_ = _g_object_ref0 (_tmp2_);
560 _g_object_unref0 (_tmp1_->priv->list_collection);
561 _tmp1_->priv->list_collection = _tmp3_;
564 _tmp7_ = gee_collection_to_array ((GeeCollection*) _tmp5_, &_tmp6_);
565 _tmp4_->priv->array = (_vala_array_free (_tmp4_->priv->array, _tmp4_->priv->array_length1, (GDestroyNotify) g_destroy_func), NULL);
566 _tmp4_->priv->array = _tmp7_;
567 _tmp4_->priv->array_length1 = _tmp6_;
568 _tmp4_->priv->_array_size_ = _tmp4_->priv->array_length1;
571 _tmp10_ = _tmp9_->priv->array;
572 _tmp10__length1 = _tmp9_->priv->array_length1;
573 _tmp8_->priv->list = _tmp10_;
575 _tmp11_->priv->index = 0;
578 _tmp14_ = gee_collection_get_size ((GeeCollection*) _tmp13_);
580 _tmp12_->priv->size = _tmp15_;
583 _tmp17__target = compare_target;
584 (_tmp16_->priv->compare_target_destroy_notify == NULL) ? NULL : (_tmp16_->priv->compare_target_destroy_notify (_tmp16_->priv->compare_target), NULL);
585 _tmp16_->priv->compare = NULL;
586 _tmp16_->priv->compare_target = NULL;
587 _tmp16_->priv->compare_target_destroy_notify = NULL;
588 _tmp16_->priv->compare = _tmp17_;
589 _tmp16_->priv->compare_target = _tmp17__target;
590 _tmp16_->priv->compare_target_destroy_notify = NULL;
592 gee_tim_sort_do_sort (_tmp18_);
594 gee_collection_clear ((GeeCollection*) _tmp19_);
596 _tmp21_ = _tmp20_->priv->array;
597 _tmp21__length1 = _tmp20_->priv->array_length1;
599 gpointer* item_collection = NULL;
600 gint item_collection_length1 = 0;
601 gint _item_collection_size_ = 0;
603 item_collection = _tmp21_;
604 item_collection_length1 = _tmp21__length1;
605 for (item_it = 0; item_it < _tmp21__length1; item_it = item_it + 1) {
607 gpointer item = NULL;
608 _tmp22_ = ((item_collection[item_it] != NULL) && (g_dup_func != NULL)) ? g_dup_func ((gpointer) item_collection[item_it]) : ((gpointer) item_collection[item_it]);
612 gconstpointer _tmp24_;
615 gee_collection_add ((GeeCollection*) _tmp23_, _tmp24_);
616 _g_destroy_func0 (item);
620 _g_object_unref0 (helper);
624 static void gee_tim_sort_sort_arraylist (GType g_type, GBoxedCopyFunc g_dup_func, GDestroyNotify g_destroy_func, GeeArrayList* list, GCompareDataFunc compare, void* compare_target) {
627 GeeArrayList* _tmp1_;
629 GeeArrayList* _tmp3_;
632 GeeArrayList* _tmp5_;
634 GCompareDataFunc _tmp7_;
636 g_return_if_fail (list != NULL);
637 _tmp0_ = gee_tim_sort_new (g_type, (GBoxedCopyFunc) g_dup_func, g_destroy_func);
640 _tmp2_ = _g_object_ref0 ((GeeList*) _tmp1_);
641 _g_object_unref0 (helper->priv->list_collection);
642 helper->priv->list_collection = _tmp2_;
644 _tmp4_ = _tmp3_->_items;
645 _tmp4__length1 = _tmp3_->_items_length1;
646 helper->priv->list = _tmp4_;
647 helper->priv->index = 0;
649 _tmp6_ = _tmp5_->_size;
650 helper->priv->size = _tmp6_;
652 _tmp7__target = compare_target;
653 (helper->priv->compare_target_destroy_notify == NULL) ? NULL : (helper->priv->compare_target_destroy_notify (helper->priv->compare_target), NULL);
654 helper->priv->compare = NULL;
655 helper->priv->compare_target = NULL;
656 helper->priv->compare_target_destroy_notify = NULL;
657 helper->priv->compare = _tmp7_;
658 helper->priv->compare_target = _tmp7__target;
659 helper->priv->compare_target_destroy_notify = NULL;
660 gee_tim_sort_do_sort (helper);
661 _g_object_unref0 (helper);
665 static void _vala_array_add1 (GeeTimSortSlice*** array, int* length, int* size, GeeTimSortSlice* value) {
666 if ((*length) == (*size)) {
667 *size = (*size) ? (2 * (*size)) : 4;
668 *array = g_renew (GeeTimSortSlice*, *array, (*size) + 1);
670 (*array)[(*length)++] = value;
671 (*array)[*length] = NULL;
675 static void gee_tim_sort_do_sort (GeeTimSort* self) {
677 GeeTimSortSlice** _tmp1_ = NULL;
681 GeeTimSortSlice* _tmp5_;
682 GeeTimSortSlice* remaining;
683 GeeTimSortSlice* _tmp6_;
687 GeeTimSortSlice* _tmp33_;
690 GeeTimSortSlice** _tmp36_;
691 gint _tmp36__length1;
692 GeeTimSortSlice** _tmp37_;
693 gint _tmp37__length1;
694 GeeTimSortSlice* _tmp38_;
696 GeeTimSortSlice** _tmp40_;
697 gint _tmp40__length1;
698 GeeTimSortSlice* _tmp41_;
701 g_return_if_fail (self != NULL);
702 _tmp0_ = self->priv->size;
706 _tmp1_ = g_new0 (GeeTimSortSlice*, 0 + 1);
707 self->priv->pending = (_vala_array_free (self->priv->pending, self->priv->pending_length1, (GDestroyNotify) gee_tim_sort_slice_free), NULL);
708 self->priv->pending = _tmp1_;
709 self->priv->pending_length1 = 0;
710 self->priv->_pending_size_ = self->priv->pending_length1;
711 self->priv->minimum_gallop = GEE_TIM_SORT_MINIMUM_GALLOP;
712 _tmp2_ = self->priv->list;
713 _tmp3_ = self->priv->index;
714 _tmp4_ = self->priv->size;
715 _tmp5_ = gee_tim_sort_slice_new (_tmp2_, _tmp3_, _tmp4_);
718 _tmp7_ = _tmp6_->length;
719 _tmp8_ = gee_tim_sort_compute_minimum_run_length (self, _tmp7_);
720 minimum_length = _tmp8_;
722 GeeTimSortSlice* _tmp9_;
724 gboolean descending = FALSE;
725 GeeTimSortSlice* _tmp11_;
726 gboolean _tmp12_ = FALSE;
727 GeeTimSortSlice* _tmp13_ = NULL;
728 GeeTimSortSlice* run;
730 GeeTimSortSlice* _tmp16_;
733 GeeTimSortSlice* _tmp28_;
734 GeeTimSortSlice* _tmp29_;
736 GeeTimSortSlice** _tmp31_;
737 gint _tmp31__length1;
738 GeeTimSortSlice* _tmp32_;
740 _tmp10_ = _tmp9_->length;
741 if (!(_tmp10_ > 0)) {
745 _tmp13_ = gee_tim_sort_compute_longest_run (self, _tmp11_, &_tmp12_);
746 descending = _tmp12_;
748 _tmp14_ = descending;
750 GeeTimSortSlice* _tmp15_;
752 gee_tim_sort_slice_reverse (_tmp15_);
755 _tmp17_ = _tmp16_->length;
756 _tmp18_ = minimum_length;
757 if (_tmp17_ < _tmp18_) {
758 GeeTimSortSlice* _tmp19_;
761 GeeTimSortSlice* _tmp21_;
763 GeeTimSortSlice* _tmp23_;
766 GeeTimSortSlice* _tmp26_;
769 _tmp20_ = _tmp19_->length;
770 sorted_count = _tmp20_;
772 _tmp22_ = minimum_length;
774 _tmp24_ = _tmp23_->length;
775 _tmp25_ = MIN (_tmp22_, _tmp24_);
776 _tmp21_->length = _tmp25_;
778 _tmp27_ = sorted_count;
779 gee_tim_sort_insertion_sort (self, _tmp26_, _tmp27_);
783 _tmp30_ = _tmp29_->length;
784 gee_tim_sort_slice_shorten_start (_tmp28_, _tmp30_);
785 _tmp31_ = self->priv->pending;
786 _tmp31__length1 = self->priv->pending_length1;
789 _vala_array_add1 (&self->priv->pending, &self->priv->pending_length1, &self->priv->_pending_size_, _tmp32_);
790 gee_tim_sort_merge_collapse (self);
791 _gee_tim_sort_slice_free0 (run);
794 _tmp34_ = _tmp33_->index;
795 _tmp35_ = self->priv->size;
796 _vala_assert (_tmp34_ == _tmp35_, "remaining.index == size");
797 gee_tim_sort_merge_force_collapse (self);
798 _tmp36_ = self->priv->pending;
799 _tmp36__length1 = self->priv->pending_length1;
800 _vala_assert (_tmp36__length1 == 1, "pending.length == 1");
801 _tmp37_ = self->priv->pending;
802 _tmp37__length1 = self->priv->pending_length1;
803 _tmp38_ = _tmp37_[0];
804 _tmp39_ = _tmp38_->index;
805 _vala_assert (_tmp39_ == 0, "pending[0].index == 0");
806 _tmp40_ = self->priv->pending;
807 _tmp40__length1 = self->priv->pending_length1;
808 _tmp41_ = _tmp40_[0];
809 _tmp42_ = _tmp41_->length;
810 _tmp43_ = self->priv->size;
811 _vala_assert (_tmp42_ == _tmp43_, "pending[0].length == size");
812 _gee_tim_sort_slice_free0 (remaining);
816 static inline gboolean gee_tim_sort_lower_than (GeeTimSort* self, gconstpointer left, gconstpointer right) {
817 gboolean result = FALSE;
818 GCompareDataFunc _tmp0_;
820 gconstpointer _tmp1_;
821 gconstpointer _tmp2_;
823 g_return_val_if_fail (self != NULL, FALSE);
824 _tmp0_ = self->priv->compare;
825 _tmp0__target = self->priv->compare_target;
828 _tmp3_ = _tmp0_ (_tmp1_, _tmp2_, _tmp0__target);
834 static inline gboolean gee_tim_sort_lower_than_or_equal_to (GeeTimSort* self, gconstpointer left, gconstpointer right) {
835 gboolean result = FALSE;
836 GCompareDataFunc _tmp0_;
838 gconstpointer _tmp1_;
839 gconstpointer _tmp2_;
841 g_return_val_if_fail (self != NULL, FALSE);
842 _tmp0_ = self->priv->compare;
843 _tmp0__target = self->priv->compare_target;
846 _tmp3_ = _tmp0_ (_tmp1_, _tmp2_, _tmp0__target);
847 result = _tmp3_ <= 0;
852 static gint gee_tim_sort_compute_minimum_run_length (GeeTimSort* self, gint length) {
857 g_return_val_if_fail (self != NULL, 0);
865 if (!(_tmp0_ >= 64)) {
870 run_length = _tmp1_ | (_tmp2_ & 1);
872 length = _tmp3_ >> 1;
876 result = _tmp4_ + _tmp5_;
881 static GeeTimSortSlice* gee_tim_sort_compute_longest_run (GeeTimSort* self, GeeTimSortSlice* a, gboolean* descending) {
882 gboolean _vala_descending = FALSE;
883 GeeTimSortSlice* result = NULL;
885 GeeTimSortSlice* _tmp0_;
887 GeeTimSortSlice* _tmp55_;
889 GeeTimSortSlice* _tmp57_;
892 GeeTimSortSlice* _tmp60_;
893 g_return_val_if_fail (self != NULL, NULL);
894 g_return_val_if_fail (a != NULL, NULL);
896 _tmp1_ = _tmp0_->length;
898 GeeTimSortSlice* _tmp2_;
901 _tmp3_ = _tmp2_->length;
903 _vala_descending = FALSE;
905 GeeTimSortSlice* _tmp4_;
907 GeeTimSortSlice* _tmp6_;
910 GeeTimSortSlice* _tmp9_;
912 GeeTimSortSlice* _tmp11_;
915 gboolean _tmp14_ = FALSE;
918 _tmp5_ = _tmp4_->list;
920 _tmp7_ = _tmp6_->index;
921 _tmp8_ = _tmp5_[_tmp7_ + 1];
923 _tmp10_ = _tmp9_->list;
925 _tmp12_ = _tmp11_->index;
926 _tmp13_ = _tmp10_[_tmp12_];
927 _tmp14_ = gee_tim_sort_lower_than (self, _tmp8_, _tmp13_);
929 _vala_descending = TRUE;
931 GeeTimSortSlice* _tmp15_;
935 _tmp16_ = _tmp15_->index;
943 GeeTimSortSlice* _tmp21_;
945 GeeTimSortSlice* _tmp23_;
947 GeeTimSortSlice* _tmp25_;
951 GeeTimSortSlice* _tmp29_;
955 gboolean _tmp33_ = FALSE;
965 _tmp22_ = _tmp21_->index;
967 _tmp24_ = _tmp23_->length;
968 if (!(_tmp20_ < (_tmp22_ + _tmp24_))) {
972 _tmp26_ = _tmp25_->list;
974 _tmp28_ = _tmp26_[_tmp27_];
976 _tmp30_ = _tmp29_->list;
978 _tmp32_ = _tmp30_[_tmp31_ - 1];
979 _tmp33_ = gee_tim_sort_lower_than (self, _tmp28_, _tmp32_);
982 _tmp34_ = run_length;
983 run_length = _tmp34_ + 1;
991 _vala_descending = FALSE;
993 GeeTimSortSlice* _tmp35_;
997 _tmp36_ = _tmp35_->index;
1005 GeeTimSortSlice* _tmp41_;
1007 GeeTimSortSlice* _tmp43_;
1009 GeeTimSortSlice* _tmp45_;
1013 GeeTimSortSlice* _tmp49_;
1017 gboolean _tmp53_ = FALSE;
1027 _tmp42_ = _tmp41_->index;
1029 _tmp44_ = _tmp43_->length;
1030 if (!(_tmp40_ < (_tmp42_ + _tmp44_))) {
1034 _tmp46_ = _tmp45_->list;
1036 _tmp48_ = _tmp46_[_tmp47_];
1038 _tmp50_ = _tmp49_->list;
1040 _tmp52_ = _tmp50_[_tmp51_ - 1];
1041 _tmp53_ = gee_tim_sort_lower_than (self, _tmp48_, _tmp52_);
1046 _tmp54_ = run_length;
1047 run_length = _tmp54_ + 1;
1055 _tmp56_ = _tmp55_->list;
1057 _tmp58_ = _tmp57_->index;
1058 _tmp59_ = run_length;
1059 _tmp60_ = gee_tim_sort_slice_new (_tmp56_, _tmp58_, _tmp59_);
1062 *descending = _vala_descending;
1068 static void gee_tim_sort_insertion_sort (GeeTimSort* self, GeeTimSortSlice* a, gint offset) {
1069 g_return_if_fail (self != NULL);
1070 g_return_if_fail (a != NULL);
1072 GeeTimSortSlice* _tmp0_;
1077 _tmp1_ = _tmp0_->index;
1079 start = _tmp1_ + _tmp2_;
1086 GeeTimSortSlice* _tmp7_;
1088 GeeTimSortSlice* _tmp9_;
1090 GeeTimSortSlice* _tmp11_;
1095 GeeTimSortSlice* _tmp14_;
1102 GeeTimSortSlice* _tmp33_;
1105 GeeTimSortSlice* _tmp36_;
1110 GeeTimSortSlice* _tmp41_;
1124 _tmp8_ = _tmp7_->index;
1126 _tmp10_ = _tmp9_->length;
1127 if (!(_tmp6_ < (_tmp8_ + _tmp10_))) {
1131 _tmp12_ = _tmp11_->index;
1136 _tmp15_ = _tmp14_->list;
1138 _tmp17_ = _tmp15_[_tmp16_];
1148 GeeTimSortSlice* _tmp24_;
1152 gboolean _tmp28_ = FALSE;
1155 if (!(_tmp18_ < _tmp19_)) {
1161 p = _tmp20_ + ((_tmp21_ - _tmp22_) >> 1);
1164 _tmp25_ = _tmp24_->list;
1166 _tmp27_ = _tmp25_[_tmp26_];
1167 _tmp28_ = gee_tim_sort_lower_than (self, _tmp23_, _tmp27_);
1180 _vala_assert (_tmp31_ == _tmp32_, "left == right");
1182 _tmp34_ = _tmp33_->list;
1185 _tmp37_ = _tmp36_->list;
1189 g_memmove (&_tmp34_[_tmp35_ + 1], &_tmp37_[_tmp38_], (gsize) (sizeof (gpointer) * (_tmp39_ - _tmp40_)));
1191 _tmp42_ = _tmp41_->list;
1194 _tmp42_[_tmp43_] = _tmp44_;
1195 _tmp45_ = _tmp42_[_tmp43_];
1202 static void gee_tim_sort_merge_collapse (GeeTimSort* self) {
1203 GeeTimSortSlice** _tmp0_;
1204 gint _tmp0__length1;
1206 g_return_if_fail (self != NULL);
1207 _tmp0_ = self->priv->pending;
1208 _tmp0__length1 = self->priv->pending_length1;
1209 count = _tmp0__length1;
1212 gboolean _tmp2_ = FALSE;
1215 GeeTimSortSlice** _tmp36_;
1216 gint _tmp36__length1;
1218 if (!(_tmp1_ > 1)) {
1223 GeeTimSortSlice** _tmp4_;
1224 gint _tmp4__length1;
1226 GeeTimSortSlice* _tmp6_;
1228 GeeTimSortSlice** _tmp8_;
1229 gint _tmp8__length1;
1231 GeeTimSortSlice* _tmp10_;
1233 GeeTimSortSlice** _tmp12_;
1234 gint _tmp12__length1;
1236 GeeTimSortSlice* _tmp14_;
1238 _tmp4_ = self->priv->pending;
1239 _tmp4__length1 = self->priv->pending_length1;
1241 _tmp6_ = _tmp4_[_tmp5_ - 3];
1242 _tmp7_ = _tmp6_->length;
1243 _tmp8_ = self->priv->pending;
1244 _tmp8__length1 = self->priv->pending_length1;
1246 _tmp10_ = _tmp8_[_tmp9_ - 2];
1247 _tmp11_ = _tmp10_->length;
1248 _tmp12_ = self->priv->pending;
1249 _tmp12__length1 = self->priv->pending_length1;
1251 _tmp14_ = _tmp12_[_tmp13_ - 1];
1252 _tmp15_ = _tmp14_->length;
1253 _tmp2_ = _tmp7_ <= (_tmp11_ + _tmp15_);
1259 GeeTimSortSlice** _tmp17_;
1260 gint _tmp17__length1;
1262 GeeTimSortSlice* _tmp19_;
1264 GeeTimSortSlice** _tmp21_;
1265 gint _tmp21__length1;
1267 GeeTimSortSlice* _tmp23_;
1269 _tmp17_ = self->priv->pending;
1270 _tmp17__length1 = self->priv->pending_length1;
1272 _tmp19_ = _tmp17_[_tmp18_ - 3];
1273 _tmp20_ = _tmp19_->length;
1274 _tmp21_ = self->priv->pending;
1275 _tmp21__length1 = self->priv->pending_length1;
1277 _tmp23_ = _tmp21_[_tmp22_ - 1];
1278 _tmp24_ = _tmp23_->length;
1279 if (_tmp20_ < _tmp24_) {
1282 gee_tim_sort_merge_at (self, _tmp25_ - 3);
1286 gee_tim_sort_merge_at (self, _tmp26_ - 2);
1289 GeeTimSortSlice** _tmp27_;
1290 gint _tmp27__length1;
1292 GeeTimSortSlice* _tmp29_;
1294 GeeTimSortSlice** _tmp31_;
1295 gint _tmp31__length1;
1297 GeeTimSortSlice* _tmp33_;
1299 _tmp27_ = self->priv->pending;
1300 _tmp27__length1 = self->priv->pending_length1;
1302 _tmp29_ = _tmp27_[_tmp28_ - 2];
1303 _tmp30_ = _tmp29_->length;
1304 _tmp31_ = self->priv->pending;
1305 _tmp31__length1 = self->priv->pending_length1;
1307 _tmp33_ = _tmp31_[_tmp32_ - 1];
1308 _tmp34_ = _tmp33_->length;
1309 if (_tmp30_ <= _tmp34_) {
1312 gee_tim_sort_merge_at (self, _tmp35_ - 2);
1317 _tmp36_ = self->priv->pending;
1318 _tmp36__length1 = self->priv->pending_length1;
1319 count = _tmp36__length1;
1324 static void gee_tim_sort_merge_force_collapse (GeeTimSort* self) {
1325 GeeTimSortSlice** _tmp0_;
1326 gint _tmp0__length1;
1328 g_return_if_fail (self != NULL);
1329 _tmp0_ = self->priv->pending;
1330 _tmp0__length1 = self->priv->pending_length1;
1331 count = _tmp0__length1;
1334 gboolean _tmp2_ = FALSE;
1337 GeeTimSortSlice** _tmp15_;
1338 gint _tmp15__length1;
1340 if (!(_tmp1_ > 1)) {
1345 GeeTimSortSlice** _tmp4_;
1346 gint _tmp4__length1;
1348 GeeTimSortSlice* _tmp6_;
1350 GeeTimSortSlice** _tmp8_;
1351 gint _tmp8__length1;
1353 GeeTimSortSlice* _tmp10_;
1355 _tmp4_ = self->priv->pending;
1356 _tmp4__length1 = self->priv->pending_length1;
1358 _tmp6_ = _tmp4_[_tmp5_ - 3];
1359 _tmp7_ = _tmp6_->length;
1360 _tmp8_ = self->priv->pending;
1361 _tmp8__length1 = self->priv->pending_length1;
1363 _tmp10_ = _tmp8_[_tmp9_ - 1];
1364 _tmp11_ = _tmp10_->length;
1365 _tmp2_ = _tmp7_ < _tmp11_;
1373 gee_tim_sort_merge_at (self, _tmp13_ - 3);
1377 gee_tim_sort_merge_at (self, _tmp14_ - 2);
1379 _tmp15_ = self->priv->pending;
1380 _tmp15__length1 = self->priv->pending_length1;
1381 count = _tmp15__length1;
1386 static void gee_tim_sort_merge_at (GeeTimSort* self, gint index) {
1387 GeeTimSortSlice** _tmp0_;
1388 gint _tmp0__length1;
1390 GeeTimSortSlice* _tmp2_;
1392 GeeTimSortSlice** _tmp3_;
1393 gint _tmp3__length1;
1395 GeeTimSortSlice* _tmp5_;
1397 GeeTimSortSlice* _tmp6_;
1399 GeeTimSortSlice* _tmp8_;
1401 GeeTimSortSlice* _tmp10_;
1403 GeeTimSortSlice* _tmp12_;
1405 GeeTimSortSlice* _tmp14_;
1407 GeeTimSortSlice** _tmp16_;
1408 gint _tmp16__length1;
1411 GeeTimSortSlice* _tmp19_;
1413 GeeTimSortSlice* _tmp21_;
1415 GeeTimSortSlice* _tmp23_;
1417 GeeTimSortSlice* _tmp25_;
1418 GeeTimSortSlice* _tmp26_;
1421 GeeTimSortSlice** _tmp29_;
1422 gint _tmp29__length1;
1425 GeeTimSortSlice* _tmp32_;
1426 void* _tmp33_ = NULL;
1427 GeeTimSortSlice* _tmp34_;
1430 GeeTimSortSlice* _tmp36_;
1432 GeeTimSortSlice* _tmp38_;
1434 GeeTimSortSlice* _tmp40_;
1435 GeeTimSortSlice* _tmp41_;
1436 void* _tmp42_ = NULL;
1437 GeeTimSortSlice* _tmp43_;
1438 GeeTimSortSlice* _tmp44_;
1441 GeeTimSortSlice* _tmp47_;
1443 GeeTimSortSlice* _tmp49_;
1445 GeeTimSortSlice* _tmp51_;
1447 g_return_if_fail (self != NULL);
1448 _tmp0_ = self->priv->pending;
1449 _tmp0__length1 = self->priv->pending_length1;
1451 _tmp2_ = _tmp0_[_tmp1_];
1452 _tmp0_[_tmp1_] = NULL;
1454 _tmp3_ = self->priv->pending;
1455 _tmp3__length1 = self->priv->pending_length1;
1457 _tmp5_ = _tmp3_[_tmp4_ + 1];
1458 _tmp3_[_tmp4_ + 1] = NULL;
1461 _tmp7_ = _tmp6_->length;
1462 _vala_assert (_tmp7_ > 0, "a.length > 0");
1464 _tmp9_ = _tmp8_->length;
1465 _vala_assert (_tmp9_ > 0, "b.length > 0");
1467 _tmp11_ = _tmp10_->index;
1469 _tmp13_ = _tmp12_->length;
1471 _tmp15_ = _tmp14_->index;
1472 _vala_assert ((_tmp11_ + _tmp13_) == _tmp15_, "a.index + a.length == b.index");
1473 _tmp16_ = self->priv->pending;
1474 _tmp16__length1 = self->priv->pending_length1;
1476 _tmp18_ = self->priv->list;
1478 _tmp20_ = _tmp19_->index;
1480 _tmp22_ = _tmp21_->length;
1482 _tmp24_ = _tmp23_->length;
1483 _tmp25_ = gee_tim_sort_slice_new (_tmp18_, _tmp20_, _tmp22_ + _tmp24_);
1484 _gee_tim_sort_slice_free0 (_tmp16_[_tmp17_]);
1485 _tmp16_[_tmp17_] = _tmp25_;
1486 _tmp26_ = _tmp16_[_tmp17_];
1489 _tmp29_ = self->priv->pending;
1490 _tmp29__length1 = self->priv->pending_length1;
1492 _vala_array_move (self->priv->pending, sizeof (GeeTimSortSlice*), _tmp27_ + 2, _tmp28_ + 1, (_tmp29__length1 - _tmp30_) - 2);
1493 self->priv->pending_length1 = self->priv->pending_length1 - 1;
1494 _tmp31_ = self->priv->pending_length1;
1496 _tmp33_ = gee_tim_sort_slice_peek_first (_tmp32_);
1498 _tmp35_ = gee_tim_sort_gallop_rightmost (self, _tmp33_, _tmp34_, 0);
1499 sorted_count = _tmp35_;
1501 _tmp37_ = sorted_count;
1502 gee_tim_sort_slice_shorten_start (_tmp36_, _tmp37_);
1504 _tmp39_ = _tmp38_->length;
1506 _gee_tim_sort_slice_free0 (b);
1507 _gee_tim_sort_slice_free0 (a);
1512 _tmp42_ = gee_tim_sort_slice_peek_last (_tmp41_);
1515 _tmp45_ = _tmp44_->length;
1516 _tmp46_ = gee_tim_sort_gallop_leftmost (self, _tmp42_, _tmp43_, _tmp45_ - 1);
1517 _tmp40_->length = _tmp46_;
1519 _tmp48_ = _tmp47_->length;
1521 _gee_tim_sort_slice_free0 (b);
1522 _gee_tim_sort_slice_free0 (a);
1526 _tmp50_ = _tmp49_->length;
1528 _tmp52_ = _tmp51_->length;
1529 if (_tmp50_ <= _tmp52_) {
1530 GeeTimSortSlice* _tmp53_;
1531 GeeTimSortSlice* _tmp54_;
1536 gee_tim_sort_merge_low (self, _tmp53_, _tmp54_);
1538 GeeTimSortSlice* _tmp55_;
1539 GeeTimSortSlice* _tmp56_;
1544 gee_tim_sort_merge_high (self, _tmp55_, _tmp56_);
1546 _gee_tim_sort_slice_free0 (b);
1547 _gee_tim_sort_slice_free0 (a);
1551 static gint gee_tim_sort_gallop_leftmost (GeeTimSort* self, gconstpointer key, GeeTimSortSlice* a, gint hint) {
1555 GeeTimSortSlice* _tmp2_;
1557 GeeTimSortSlice* _tmp4_;
1563 GeeTimSortSlice* _tmp7_;
1567 gconstpointer _tmp11_;
1568 gboolean _tmp12_ = FALSE;
1573 GeeTimSortSlice* _tmp61_;
1578 g_return_val_if_fail (self != NULL, 0);
1579 g_return_val_if_fail (a != NULL, 0);
1581 _vala_assert (0 <= _tmp0_, "0 <= hint");
1584 _tmp3_ = _tmp2_->length;
1585 _vala_assert (_tmp1_ < _tmp3_, "hint < a.length");
1587 _tmp5_ = _tmp4_->index;
1589 p = _tmp5_ + _tmp6_;
1593 _tmp8_ = _tmp7_->list;
1595 _tmp10_ = _tmp8_[_tmp9_];
1597 _tmp12_ = gee_tim_sort_lower_than (self, _tmp10_, _tmp11_);
1599 GeeTimSortSlice* _tmp13_;
1610 _tmp14_ = _tmp13_->length;
1612 max_offset = _tmp14_ - _tmp15_;
1616 GeeTimSortSlice* _tmp18_;
1621 gconstpointer _tmp23_;
1622 gboolean _tmp24_ = FALSE;
1624 _tmp17_ = max_offset;
1625 if (!(_tmp16_ < _tmp17_)) {
1629 _tmp19_ = _tmp18_->list;
1632 _tmp22_ = _tmp19_[_tmp20_ + _tmp21_];
1634 _tmp24_ = gee_tim_sort_lower_than (self, _tmp22_, _tmp23_);
1640 last_offset = _tmp25_;
1642 offset = _tmp26_ << 1;
1644 offset = _tmp27_ + 1;
1650 _tmp29_ = max_offset;
1651 if (_tmp28_ > _tmp29_) {
1653 _tmp30_ = max_offset;
1657 _tmp32_ = last_offset;
1658 last_offset = _tmp31_ + _tmp32_;
1661 offset = _tmp33_ + _tmp34_;
1668 gint temp_last_offset;
1676 max_offset = _tmp35_ + 1;
1680 GeeTimSortSlice* _tmp38_;
1685 gconstpointer _tmp43_;
1686 gboolean _tmp44_ = FALSE;
1688 _tmp37_ = max_offset;
1689 if (!(_tmp36_ < _tmp37_)) {
1693 _tmp39_ = _tmp38_->list;
1696 _tmp42_ = _tmp39_[_tmp40_ - _tmp41_];
1698 _tmp44_ = gee_tim_sort_lower_than (self, _tmp42_, _tmp43_);
1706 last_offset = _tmp45_;
1708 offset = _tmp46_ << 1;
1710 offset = _tmp47_ + 1;
1714 _tmp49_ = max_offset;
1715 if (_tmp48_ > _tmp49_) {
1717 _tmp50_ = max_offset;
1720 _tmp51_ = last_offset;
1721 temp_last_offset = _tmp51_;
1723 temp_offset = _tmp52_;
1725 _tmp54_ = temp_offset;
1726 last_offset = _tmp53_ - _tmp54_;
1728 _tmp56_ = temp_last_offset;
1729 offset = _tmp55_ - _tmp56_;
1731 _tmp57_ = last_offset;
1732 _vala_assert ((-1) <= _tmp57_, "-1 <= last_offset");
1733 _tmp58_ = last_offset;
1735 _vala_assert (_tmp58_ < _tmp59_, "last_offset < offset");
1738 _tmp62_ = _tmp61_->length;
1739 _vala_assert (_tmp60_ <= _tmp62_, "offset <= a.length");
1740 _tmp63_ = last_offset;
1741 last_offset = _tmp63_ + 1;
1749 GeeTimSortSlice* _tmp69_;
1751 GeeTimSortSlice* _tmp71_;
1755 gconstpointer _tmp75_;
1756 gboolean _tmp76_ = FALSE;
1757 _tmp64_ = last_offset;
1759 if (!(_tmp64_ < _tmp65_)) {
1762 _tmp66_ = last_offset;
1764 _tmp68_ = last_offset;
1765 m = _tmp66_ + ((_tmp67_ - _tmp68_) >> 1);
1767 _tmp70_ = _tmp69_->list;
1769 _tmp72_ = _tmp71_->index;
1771 _tmp74_ = _tmp70_[_tmp72_ + _tmp73_];
1773 _tmp76_ = gee_tim_sort_lower_than (self, _tmp74_, _tmp75_);
1777 last_offset = _tmp77_ + 1;
1784 _tmp79_ = last_offset;
1786 _vala_assert (_tmp79_ == _tmp80_, "last_offset == offset");
1792 static gint gee_tim_sort_gallop_rightmost (GeeTimSort* self, gconstpointer key, GeeTimSortSlice* a, gint hint) {
1796 GeeTimSortSlice* _tmp2_;
1798 GeeTimSortSlice* _tmp4_;
1804 GeeTimSortSlice* _tmp7_;
1808 gconstpointer _tmp11_;
1809 gboolean _tmp12_ = FALSE;
1814 GeeTimSortSlice* _tmp61_;
1819 g_return_val_if_fail (self != NULL, 0);
1820 g_return_val_if_fail (a != NULL, 0);
1822 _vala_assert (0 <= _tmp0_, "0 <= hint");
1825 _tmp3_ = _tmp2_->length;
1826 _vala_assert (_tmp1_ < _tmp3_, "hint < a.length");
1828 _tmp5_ = _tmp4_->index;
1830 p = _tmp5_ + _tmp6_;
1834 _tmp8_ = _tmp7_->list;
1836 _tmp10_ = _tmp8_[_tmp9_];
1838 _tmp12_ = gee_tim_sort_lower_than_or_equal_to (self, _tmp10_, _tmp11_);
1840 GeeTimSortSlice* _tmp13_;
1851 _tmp14_ = _tmp13_->length;
1853 max_offset = _tmp14_ - _tmp15_;
1857 GeeTimSortSlice* _tmp18_;
1862 gconstpointer _tmp23_;
1863 gboolean _tmp24_ = FALSE;
1865 _tmp17_ = max_offset;
1866 if (!(_tmp16_ < _tmp17_)) {
1870 _tmp19_ = _tmp18_->list;
1873 _tmp22_ = _tmp19_[_tmp20_ + _tmp21_];
1875 _tmp24_ = gee_tim_sort_lower_than_or_equal_to (self, _tmp22_, _tmp23_);
1881 last_offset = _tmp25_;
1883 offset = _tmp26_ << 1;
1885 offset = _tmp27_ + 1;
1891 _tmp29_ = max_offset;
1892 if (_tmp28_ > _tmp29_) {
1894 _tmp30_ = max_offset;
1898 _tmp32_ = last_offset;
1899 last_offset = _tmp31_ + _tmp32_;
1902 offset = _tmp33_ + _tmp34_;
1909 gint temp_last_offset;
1917 max_offset = _tmp35_ + 1;
1921 GeeTimSortSlice* _tmp38_;
1926 gconstpointer _tmp43_;
1927 gboolean _tmp44_ = FALSE;
1929 _tmp37_ = max_offset;
1930 if (!(_tmp36_ < _tmp37_)) {
1934 _tmp39_ = _tmp38_->list;
1937 _tmp42_ = _tmp39_[_tmp40_ - _tmp41_];
1939 _tmp44_ = gee_tim_sort_lower_than_or_equal_to (self, _tmp42_, _tmp43_);
1947 last_offset = _tmp45_;
1949 offset = _tmp46_ << 1;
1951 offset = _tmp47_ + 1;
1955 _tmp49_ = max_offset;
1956 if (_tmp48_ > _tmp49_) {
1958 _tmp50_ = max_offset;
1961 _tmp51_ = last_offset;
1962 temp_last_offset = _tmp51_;
1964 temp_offset = _tmp52_;
1966 _tmp54_ = temp_offset;
1967 last_offset = _tmp53_ - _tmp54_;
1969 _tmp56_ = temp_last_offset;
1970 offset = _tmp55_ - _tmp56_;
1972 _tmp57_ = last_offset;
1973 _vala_assert ((-1) <= _tmp57_, "-1 <= last_offset");
1974 _tmp58_ = last_offset;
1976 _vala_assert (_tmp58_ < _tmp59_, "last_offset < offset");
1979 _tmp62_ = _tmp61_->length;
1980 _vala_assert (_tmp60_ <= _tmp62_, "offset <= a.length");
1981 _tmp63_ = last_offset;
1982 last_offset = _tmp63_ + 1;
1990 GeeTimSortSlice* _tmp69_;
1992 GeeTimSortSlice* _tmp71_;
1996 gconstpointer _tmp75_;
1997 gboolean _tmp76_ = FALSE;
1998 _tmp64_ = last_offset;
2000 if (!(_tmp64_ < _tmp65_)) {
2003 _tmp66_ = last_offset;
2005 _tmp68_ = last_offset;
2006 m = _tmp66_ + ((_tmp67_ - _tmp68_) >> 1);
2008 _tmp70_ = _tmp69_->list;
2010 _tmp72_ = _tmp71_->index;
2012 _tmp74_ = _tmp70_[_tmp72_ + _tmp73_];
2014 _tmp76_ = gee_tim_sort_lower_than_or_equal_to (self, _tmp74_, _tmp75_);
2018 last_offset = _tmp77_ + 1;
2025 _tmp79_ = last_offset;
2027 _vala_assert (_tmp79_ == _tmp80_, "last_offset == offset");
2033 static void gee_tim_sort_merge_low (GeeTimSort* self, GeeTimSortSlice* a, GeeTimSortSlice* b) {
2034 GeeTimSortSlice* _tmp0_;
2036 GeeTimSortSlice* _tmp2_;
2038 GeeTimSortSlice* _tmp4_;
2040 GeeTimSortSlice* _tmp6_;
2042 GeeTimSortSlice* _tmp8_;
2045 gint minimum_gallop;
2046 GeeTimSortSlice* _tmp11_;
2049 GeeTimSortSlice* _tmp13_;
2050 GError * _inner_error_ = NULL;
2051 g_return_if_fail (self != NULL);
2052 g_return_if_fail (a != NULL);
2053 g_return_if_fail (b != NULL);
2055 _tmp1_ = _tmp0_->length;
2056 _vala_assert (_tmp1_ > 0, "a.length > 0");
2058 _tmp3_ = _tmp2_->length;
2059 _vala_assert (_tmp3_ > 0, "b.length > 0");
2061 _tmp5_ = _tmp4_->index;
2063 _tmp7_ = _tmp6_->length;
2065 _tmp9_ = _tmp8_->index;
2066 _vala_assert ((_tmp5_ + _tmp7_) == _tmp9_, "a.index + a.length == b.index");
2067 _tmp10_ = self->priv->minimum_gallop;
2068 minimum_gallop = _tmp10_;
2070 _tmp12_ = _tmp11_->index;
2073 gee_tim_sort_slice_copy (_tmp13_);
2077 GeeTimSortSlice* _tmp16_;
2078 void* _tmp17_ = NULL;
2080 gboolean _tmp19_ = FALSE;
2081 GeeTimSortSlice* _tmp20_;
2084 _tmp14_ = self->priv->list;
2088 _tmp17_ = gee_tim_sort_slice_pop_first (_tmp16_);
2089 _tmp14_[_tmp15_] = _tmp17_;
2090 _tmp18_ = _tmp14_[_tmp15_];
2092 _tmp21_ = _tmp20_->length;
2096 GeeTimSortSlice* _tmp22_;
2099 _tmp23_ = _tmp22_->length;
2100 _tmp19_ = _tmp23_ == 0;
2105 GeeTimSortSlice* _tmp25_;
2107 GeeTimSortSlice* _tmp27_;
2109 GeeTimSortSlice* _tmp29_;
2111 GeeTimSortSlice* _tmp31_;
2114 GeeTimSortSlice* _tmp34_;
2116 GeeTimSortSlice* _tmp36_;
2118 GeeTimSortSlice* _tmp38_;
2121 GeeTimSortSlice* _tmp41_;
2123 GeeTimSortSlice* _tmp43_;
2126 _tmp26_ = _tmp25_->length;
2127 _vala_assert (_tmp26_ >= 0, "a.length >= 0");
2129 _tmp28_ = _tmp27_->length;
2130 _vala_assert (_tmp28_ >= 0, "b.length >= 0");
2132 _tmp30_ = self->priv->list;
2134 _tmp32_ = _tmp31_->index;
2137 _tmp35_ = _tmp34_->length;
2138 gee_tim_sort_slice_merge_in (_tmp29_, _tmp30_, _tmp32_, _tmp33_, _tmp35_);
2140 _tmp37_ = self->priv->list;
2142 _tmp39_ = _tmp38_->index;
2145 _tmp42_ = _tmp41_->length;
2147 _tmp44_ = _tmp43_->length;
2148 gee_tim_sort_slice_merge_in (_tmp36_, _tmp37_, _tmp39_, _tmp40_ + _tmp42_, _tmp44_);
2150 _gee_tim_sort_slice_free0 (a);
2151 _gee_tim_sort_slice_free0 (b);
2163 GeeTimSortSlice* _tmp45_;
2164 void* _tmp46_ = NULL;
2165 GeeTimSortSlice* _tmp47_;
2166 void* _tmp48_ = NULL;
2167 gboolean _tmp49_ = FALSE;
2169 _tmp46_ = gee_tim_sort_slice_peek_first (_tmp45_);
2171 _tmp48_ = gee_tim_sort_slice_peek_first (_tmp47_);
2172 _tmp49_ = gee_tim_sort_lower_than (self, _tmp46_, _tmp48_);
2176 GeeTimSortSlice* _tmp52_;
2177 void* _tmp53_ = NULL;
2179 GeeTimSortSlice* _tmp55_;
2184 _tmp50_ = self->priv->list;
2188 _tmp53_ = gee_tim_sort_slice_pop_first (_tmp52_);
2189 _tmp50_[_tmp51_] = _tmp53_;
2190 _tmp54_ = _tmp50_[_tmp51_];
2192 _tmp56_ = _tmp55_->length;
2195 GeeTimSortSlice* _tmp57_;
2197 GeeTimSortSlice* _tmp59_;
2199 GeeTimSortSlice* _tmp61_;
2201 GeeTimSortSlice* _tmp63_;
2204 GeeTimSortSlice* _tmp66_;
2206 GeeTimSortSlice* _tmp68_;
2208 GeeTimSortSlice* _tmp70_;
2211 GeeTimSortSlice* _tmp73_;
2213 GeeTimSortSlice* _tmp75_;
2216 _tmp58_ = _tmp57_->length;
2217 _vala_assert (_tmp58_ >= 0, "a.length >= 0");
2219 _tmp60_ = _tmp59_->length;
2220 _vala_assert (_tmp60_ >= 0, "b.length >= 0");
2222 _tmp62_ = self->priv->list;
2224 _tmp64_ = _tmp63_->index;
2227 _tmp67_ = _tmp66_->length;
2228 gee_tim_sort_slice_merge_in (_tmp61_, _tmp62_, _tmp64_, _tmp65_, _tmp67_);
2230 _tmp69_ = self->priv->list;
2232 _tmp71_ = _tmp70_->index;
2235 _tmp74_ = _tmp73_->length;
2237 _tmp76_ = _tmp75_->length;
2238 gee_tim_sort_slice_merge_in (_tmp68_, _tmp69_, _tmp71_, _tmp72_ + _tmp74_, _tmp76_);
2240 _gee_tim_sort_slice_free0 (a);
2241 _gee_tim_sort_slice_free0 (b);
2245 b_count = _tmp77_ + 1;
2248 _tmp79_ = minimum_gallop;
2249 if (_tmp78_ >= _tmp79_) {
2255 GeeTimSortSlice* _tmp82_;
2256 void* _tmp83_ = NULL;
2258 GeeTimSortSlice* _tmp85_;
2263 _tmp80_ = self->priv->list;
2267 _tmp83_ = gee_tim_sort_slice_pop_first (_tmp82_);
2268 _tmp80_[_tmp81_] = _tmp83_;
2269 _tmp84_ = _tmp80_[_tmp81_];
2271 _tmp86_ = _tmp85_->length;
2274 GeeTimSortSlice* _tmp87_;
2276 GeeTimSortSlice* _tmp89_;
2278 GeeTimSortSlice* _tmp91_;
2280 GeeTimSortSlice* _tmp93_;
2283 GeeTimSortSlice* _tmp96_;
2285 GeeTimSortSlice* _tmp98_;
2287 GeeTimSortSlice* _tmp100_;
2290 GeeTimSortSlice* _tmp103_;
2292 GeeTimSortSlice* _tmp105_;
2295 _tmp88_ = _tmp87_->length;
2296 _vala_assert (_tmp88_ >= 0, "a.length >= 0");
2298 _tmp90_ = _tmp89_->length;
2299 _vala_assert (_tmp90_ >= 0, "b.length >= 0");
2301 _tmp92_ = self->priv->list;
2303 _tmp94_ = _tmp93_->index;
2306 _tmp97_ = _tmp96_->length;
2307 gee_tim_sort_slice_merge_in (_tmp91_, _tmp92_, _tmp94_, _tmp95_, _tmp97_);
2309 _tmp99_ = self->priv->list;
2311 _tmp101_ = _tmp100_->index;
2314 _tmp104_ = _tmp103_->length;
2316 _tmp106_ = _tmp105_->length;
2317 gee_tim_sort_slice_merge_in (_tmp98_, _tmp99_, _tmp101_, _tmp102_ + _tmp104_, _tmp106_);
2319 _gee_tim_sort_slice_free0 (a);
2320 _gee_tim_sort_slice_free0 (b);
2324 a_count = _tmp107_ + 1;
2327 _tmp109_ = minimum_gallop;
2328 if (_tmp108_ >= _tmp109_) {
2333 _tmp110_ = minimum_gallop;
2334 minimum_gallop = _tmp110_ + 1;
2341 GeeTimSortSlice* _tmp116_;
2342 void* _tmp117_ = NULL;
2343 GeeTimSortSlice* _tmp118_;
2345 GeeTimSortSlice* _tmp120_;
2347 GeeTimSortSlice* _tmp122_;
2353 GeeTimSortSlice* _tmp128_;
2355 GeeTimSortSlice* _tmp130_;
2359 GeeTimSortSlice* _tmp154_;
2360 void* _tmp155_ = NULL;
2362 GeeTimSortSlice* _tmp157_;
2364 GeeTimSortSlice* _tmp179_;
2365 void* _tmp180_ = NULL;
2366 GeeTimSortSlice* _tmp181_;
2368 GeeTimSortSlice* _tmp183_;
2370 GeeTimSortSlice* _tmp185_;
2376 GeeTimSortSlice* _tmp191_;
2378 GeeTimSortSlice* _tmp193_;
2382 GeeTimSortSlice* _tmp217_;
2383 void* _tmp218_ = NULL;
2385 GeeTimSortSlice* _tmp220_;
2387 gboolean _tmp242_ = FALSE;
2390 _tmp112_ = minimum_gallop;
2396 _tmp113_ = minimum_gallop;
2397 _tmp114_ = _tmp111_;
2398 minimum_gallop = _tmp113_ - _tmp114_;
2399 _tmp115_ = minimum_gallop;
2400 self->priv->minimum_gallop = _tmp115_;
2402 _tmp117_ = gee_tim_sort_slice_peek_first (_tmp116_);
2404 _tmp119_ = gee_tim_sort_gallop_rightmost (self, _tmp117_, _tmp118_, 0);
2407 _tmp121_ = self->priv->list;
2409 _tmp123_ = _tmp122_->index;
2412 gee_tim_sort_slice_merge_in (_tmp120_, _tmp121_, _tmp123_, _tmp124_, _tmp125_);
2415 dest = _tmp126_ + _tmp127_;
2418 gee_tim_sort_slice_shorten_start (_tmp128_, _tmp129_);
2420 _tmp131_ = _tmp130_->length;
2421 if (_tmp131_ <= 1) {
2423 GeeTimSortSlice* _tmp132_;
2425 GeeTimSortSlice* _tmp134_;
2427 GeeTimSortSlice* _tmp136_;
2429 GeeTimSortSlice* _tmp138_;
2432 GeeTimSortSlice* _tmp141_;
2434 GeeTimSortSlice* _tmp143_;
2436 GeeTimSortSlice* _tmp145_;
2439 GeeTimSortSlice* _tmp148_;
2441 GeeTimSortSlice* _tmp150_;
2444 _tmp133_ = _tmp132_->length;
2445 _vala_assert (_tmp133_ >= 0, "a.length >= 0");
2447 _tmp135_ = _tmp134_->length;
2448 _vala_assert (_tmp135_ >= 0, "b.length >= 0");
2450 _tmp137_ = self->priv->list;
2452 _tmp139_ = _tmp138_->index;
2455 _tmp142_ = _tmp141_->length;
2456 gee_tim_sort_slice_merge_in (_tmp136_, _tmp137_, _tmp139_, _tmp140_, _tmp142_);
2458 _tmp144_ = self->priv->list;
2460 _tmp146_ = _tmp145_->index;
2463 _tmp149_ = _tmp148_->length;
2465 _tmp151_ = _tmp150_->length;
2466 gee_tim_sort_slice_merge_in (_tmp143_, _tmp144_, _tmp146_, _tmp147_ + _tmp149_, _tmp151_);
2468 _gee_tim_sort_slice_free0 (a);
2469 _gee_tim_sort_slice_free0 (b);
2472 _tmp152_ = self->priv->list;
2474 dest = _tmp153_ + 1;
2476 _tmp155_ = gee_tim_sort_slice_pop_first (_tmp154_);
2477 _tmp152_[_tmp153_] = _tmp155_;
2478 _tmp156_ = _tmp152_[_tmp153_];
2480 _tmp158_ = _tmp157_->length;
2481 if (_tmp158_ == 0) {
2483 GeeTimSortSlice* _tmp159_;
2485 GeeTimSortSlice* _tmp161_;
2487 GeeTimSortSlice* _tmp163_;
2489 GeeTimSortSlice* _tmp165_;
2492 GeeTimSortSlice* _tmp168_;
2494 GeeTimSortSlice* _tmp170_;
2496 GeeTimSortSlice* _tmp172_;
2499 GeeTimSortSlice* _tmp175_;
2501 GeeTimSortSlice* _tmp177_;
2504 _tmp160_ = _tmp159_->length;
2505 _vala_assert (_tmp160_ >= 0, "a.length >= 0");
2507 _tmp162_ = _tmp161_->length;
2508 _vala_assert (_tmp162_ >= 0, "b.length >= 0");
2510 _tmp164_ = self->priv->list;
2512 _tmp166_ = _tmp165_->index;
2515 _tmp169_ = _tmp168_->length;
2516 gee_tim_sort_slice_merge_in (_tmp163_, _tmp164_, _tmp166_, _tmp167_, _tmp169_);
2518 _tmp171_ = self->priv->list;
2520 _tmp173_ = _tmp172_->index;
2523 _tmp176_ = _tmp175_->length;
2525 _tmp178_ = _tmp177_->length;
2526 gee_tim_sort_slice_merge_in (_tmp170_, _tmp171_, _tmp173_, _tmp174_ + _tmp176_, _tmp178_);
2528 _gee_tim_sort_slice_free0 (a);
2529 _gee_tim_sort_slice_free0 (b);
2533 _tmp180_ = gee_tim_sort_slice_peek_first (_tmp179_);
2535 _tmp182_ = gee_tim_sort_gallop_leftmost (self, _tmp180_, _tmp181_, 0);
2538 _tmp184_ = self->priv->list;
2540 _tmp186_ = _tmp185_->index;
2543 gee_tim_sort_slice_merge_in (_tmp183_, _tmp184_, _tmp186_, _tmp187_, _tmp188_);
2546 dest = _tmp189_ + _tmp190_;
2549 gee_tim_sort_slice_shorten_start (_tmp191_, _tmp192_);
2551 _tmp194_ = _tmp193_->length;
2552 if (_tmp194_ == 0) {
2554 GeeTimSortSlice* _tmp195_;
2556 GeeTimSortSlice* _tmp197_;
2558 GeeTimSortSlice* _tmp199_;
2560 GeeTimSortSlice* _tmp201_;
2563 GeeTimSortSlice* _tmp204_;
2565 GeeTimSortSlice* _tmp206_;
2567 GeeTimSortSlice* _tmp208_;
2570 GeeTimSortSlice* _tmp211_;
2572 GeeTimSortSlice* _tmp213_;
2575 _tmp196_ = _tmp195_->length;
2576 _vala_assert (_tmp196_ >= 0, "a.length >= 0");
2578 _tmp198_ = _tmp197_->length;
2579 _vala_assert (_tmp198_ >= 0, "b.length >= 0");
2581 _tmp200_ = self->priv->list;
2583 _tmp202_ = _tmp201_->index;
2586 _tmp205_ = _tmp204_->length;
2587 gee_tim_sort_slice_merge_in (_tmp199_, _tmp200_, _tmp202_, _tmp203_, _tmp205_);
2589 _tmp207_ = self->priv->list;
2591 _tmp209_ = _tmp208_->index;
2594 _tmp212_ = _tmp211_->length;
2596 _tmp214_ = _tmp213_->length;
2597 gee_tim_sort_slice_merge_in (_tmp206_, _tmp207_, _tmp209_, _tmp210_ + _tmp212_, _tmp214_);
2599 _gee_tim_sort_slice_free0 (a);
2600 _gee_tim_sort_slice_free0 (b);
2603 _tmp215_ = self->priv->list;
2605 dest = _tmp216_ + 1;
2607 _tmp218_ = gee_tim_sort_slice_pop_first (_tmp217_);
2608 _tmp215_[_tmp216_] = _tmp218_;
2609 _tmp219_ = _tmp215_[_tmp216_];
2611 _tmp221_ = _tmp220_->length;
2612 if (_tmp221_ == 1) {
2614 GeeTimSortSlice* _tmp222_;
2616 GeeTimSortSlice* _tmp224_;
2618 GeeTimSortSlice* _tmp226_;
2620 GeeTimSortSlice* _tmp228_;
2623 GeeTimSortSlice* _tmp231_;
2625 GeeTimSortSlice* _tmp233_;
2627 GeeTimSortSlice* _tmp235_;
2630 GeeTimSortSlice* _tmp238_;
2632 GeeTimSortSlice* _tmp240_;
2635 _tmp223_ = _tmp222_->length;
2636 _vala_assert (_tmp223_ >= 0, "a.length >= 0");
2638 _tmp225_ = _tmp224_->length;
2639 _vala_assert (_tmp225_ >= 0, "b.length >= 0");
2641 _tmp227_ = self->priv->list;
2643 _tmp229_ = _tmp228_->index;
2646 _tmp232_ = _tmp231_->length;
2647 gee_tim_sort_slice_merge_in (_tmp226_, _tmp227_, _tmp229_, _tmp230_, _tmp232_);
2649 _tmp234_ = self->priv->list;
2651 _tmp236_ = _tmp235_->index;
2654 _tmp239_ = _tmp238_->length;
2656 _tmp241_ = _tmp240_->length;
2657 gee_tim_sort_slice_merge_in (_tmp233_, _tmp234_, _tmp236_, _tmp237_ + _tmp239_, _tmp241_);
2659 _gee_tim_sort_slice_free0 (a);
2660 _gee_tim_sort_slice_free0 (b);
2664 if (_tmp243_ < GEE_TIM_SORT_MINIMUM_GALLOP) {
2667 _tmp242_ = _tmp244_ < GEE_TIM_SORT_MINIMUM_GALLOP;
2671 _tmp245_ = _tmp242_;
2676 _tmp246_ = minimum_gallop;
2677 minimum_gallop = _tmp246_ + 1;
2678 _tmp247_ = minimum_gallop;
2679 self->priv->minimum_gallop = _tmp247_;
2684 GeeTimSortSlice* _tmp248_;
2686 GeeTimSortSlice* _tmp250_;
2688 GeeTimSortSlice* _tmp252_;
2690 GeeTimSortSlice* _tmp254_;
2693 GeeTimSortSlice* _tmp257_;
2695 GeeTimSortSlice* _tmp259_;
2697 GeeTimSortSlice* _tmp261_;
2700 GeeTimSortSlice* _tmp264_;
2702 GeeTimSortSlice* _tmp266_;
2705 _tmp249_ = _tmp248_->length;
2706 _vala_assert (_tmp249_ >= 0, "a.length >= 0");
2708 _tmp251_ = _tmp250_->length;
2709 _vala_assert (_tmp251_ >= 0, "b.length >= 0");
2711 _tmp253_ = self->priv->list;
2713 _tmp255_ = _tmp254_->index;
2716 _tmp258_ = _tmp257_->length;
2717 gee_tim_sort_slice_merge_in (_tmp252_, _tmp253_, _tmp255_, _tmp256_, _tmp258_);
2719 _tmp260_ = self->priv->list;
2721 _tmp262_ = _tmp261_->index;
2724 _tmp265_ = _tmp264_->length;
2726 _tmp267_ = _tmp266_->length;
2727 gee_tim_sort_slice_merge_in (_tmp259_, _tmp260_, _tmp262_, _tmp263_ + _tmp265_, _tmp267_);
2729 _gee_tim_sort_slice_free0 (a);
2730 _gee_tim_sort_slice_free0 (b);
2731 g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
2732 g_clear_error (&_inner_error_);
2737 static void gee_tim_sort_merge_high (GeeTimSort* self, GeeTimSortSlice* a, GeeTimSortSlice* b) {
2738 GeeTimSortSlice* _tmp0_;
2740 GeeTimSortSlice* _tmp2_;
2742 GeeTimSortSlice* _tmp4_;
2744 GeeTimSortSlice* _tmp6_;
2746 GeeTimSortSlice* _tmp8_;
2749 gint minimum_gallop;
2750 GeeTimSortSlice* _tmp11_;
2752 GeeTimSortSlice* _tmp13_;
2755 GeeTimSortSlice* _tmp15_;
2756 GError * _inner_error_ = NULL;
2757 g_return_if_fail (self != NULL);
2758 g_return_if_fail (a != NULL);
2759 g_return_if_fail (b != NULL);
2761 _tmp1_ = _tmp0_->length;
2762 _vala_assert (_tmp1_ > 0, "a.length > 0");
2764 _tmp3_ = _tmp2_->length;
2765 _vala_assert (_tmp3_ > 0, "b.length > 0");
2767 _tmp5_ = _tmp4_->index;
2769 _tmp7_ = _tmp6_->length;
2771 _tmp9_ = _tmp8_->index;
2772 _vala_assert ((_tmp5_ + _tmp7_) == _tmp9_, "a.index + a.length == b.index");
2773 _tmp10_ = self->priv->minimum_gallop;
2774 minimum_gallop = _tmp10_;
2776 _tmp12_ = _tmp11_->index;
2778 _tmp14_ = _tmp13_->length;
2779 dest = _tmp12_ + _tmp14_;
2781 gee_tim_sort_slice_copy (_tmp15_);
2786 GeeTimSortSlice* _tmp19_;
2787 void* _tmp20_ = NULL;
2789 gboolean _tmp22_ = FALSE;
2790 GeeTimSortSlice* _tmp23_;
2793 _tmp16_ = self->priv->list;
2798 _tmp20_ = gee_tim_sort_slice_pop_last (_tmp19_);
2799 _tmp16_[_tmp18_] = _tmp20_;
2800 _tmp21_ = _tmp16_[_tmp18_];
2802 _tmp24_ = _tmp23_->length;
2806 GeeTimSortSlice* _tmp25_;
2809 _tmp26_ = _tmp25_->length;
2810 _tmp22_ = _tmp26_ == 1;
2815 GeeTimSortSlice* _tmp28_;
2817 GeeTimSortSlice* _tmp30_;
2819 GeeTimSortSlice* _tmp32_;
2821 GeeTimSortSlice* _tmp34_;
2824 GeeTimSortSlice* _tmp37_;
2826 GeeTimSortSlice* _tmp39_;
2828 GeeTimSortSlice* _tmp41_;
2830 GeeTimSortSlice* _tmp43_;
2833 GeeTimSortSlice* _tmp46_;
2835 GeeTimSortSlice* _tmp48_;
2837 GeeTimSortSlice* _tmp50_;
2840 _tmp29_ = _tmp28_->length;
2841 _vala_assert (_tmp29_ >= 0, "a.length >= 0");
2843 _tmp31_ = _tmp30_->length;
2844 _vala_assert (_tmp31_ >= 0, "b.length >= 0");
2846 _tmp33_ = self->priv->list;
2848 _tmp35_ = _tmp34_->index;
2851 _tmp38_ = _tmp37_->length;
2853 _tmp40_ = _tmp39_->length;
2854 gee_tim_sort_slice_merge_in_reversed (_tmp32_, _tmp33_, _tmp35_, _tmp36_ - _tmp38_, _tmp40_);
2856 _tmp42_ = self->priv->list;
2858 _tmp44_ = _tmp43_->index;
2861 _tmp47_ = _tmp46_->length;
2863 _tmp49_ = _tmp48_->length;
2865 _tmp51_ = _tmp50_->length;
2866 gee_tim_sort_slice_merge_in_reversed (_tmp41_, _tmp42_, _tmp44_, (_tmp45_ - _tmp47_) - _tmp49_, _tmp51_);
2868 _gee_tim_sort_slice_free0 (a);
2869 _gee_tim_sort_slice_free0 (b);
2881 GeeTimSortSlice* _tmp52_;
2882 void* _tmp53_ = NULL;
2883 GeeTimSortSlice* _tmp54_;
2884 void* _tmp55_ = NULL;
2885 gboolean _tmp56_ = FALSE;
2887 _tmp53_ = gee_tim_sort_slice_peek_last (_tmp52_);
2889 _tmp55_ = gee_tim_sort_slice_peek_last (_tmp54_);
2890 _tmp56_ = gee_tim_sort_lower_than (self, _tmp53_, _tmp55_);
2895 GeeTimSortSlice* _tmp60_;
2896 void* _tmp61_ = NULL;
2898 GeeTimSortSlice* _tmp63_;
2903 _tmp57_ = self->priv->list;
2908 _tmp61_ = gee_tim_sort_slice_pop_last (_tmp60_);
2909 _tmp57_[_tmp59_] = _tmp61_;
2910 _tmp62_ = _tmp57_[_tmp59_];
2912 _tmp64_ = _tmp63_->length;
2915 GeeTimSortSlice* _tmp65_;
2917 GeeTimSortSlice* _tmp67_;
2919 GeeTimSortSlice* _tmp69_;
2921 GeeTimSortSlice* _tmp71_;
2924 GeeTimSortSlice* _tmp74_;
2926 GeeTimSortSlice* _tmp76_;
2928 GeeTimSortSlice* _tmp78_;
2930 GeeTimSortSlice* _tmp80_;
2933 GeeTimSortSlice* _tmp83_;
2935 GeeTimSortSlice* _tmp85_;
2937 GeeTimSortSlice* _tmp87_;
2940 _tmp66_ = _tmp65_->length;
2941 _vala_assert (_tmp66_ >= 0, "a.length >= 0");
2943 _tmp68_ = _tmp67_->length;
2944 _vala_assert (_tmp68_ >= 0, "b.length >= 0");
2946 _tmp70_ = self->priv->list;
2948 _tmp72_ = _tmp71_->index;
2951 _tmp75_ = _tmp74_->length;
2953 _tmp77_ = _tmp76_->length;
2954 gee_tim_sort_slice_merge_in_reversed (_tmp69_, _tmp70_, _tmp72_, _tmp73_ - _tmp75_, _tmp77_);
2956 _tmp79_ = self->priv->list;
2958 _tmp81_ = _tmp80_->index;
2961 _tmp84_ = _tmp83_->length;
2963 _tmp86_ = _tmp85_->length;
2965 _tmp88_ = _tmp87_->length;
2966 gee_tim_sort_slice_merge_in_reversed (_tmp78_, _tmp79_, _tmp81_, (_tmp82_ - _tmp84_) - _tmp86_, _tmp88_);
2968 _gee_tim_sort_slice_free0 (a);
2969 _gee_tim_sort_slice_free0 (b);
2973 a_count = _tmp89_ + 1;
2976 _tmp91_ = minimum_gallop;
2977 if (_tmp90_ >= _tmp91_) {
2984 GeeTimSortSlice* _tmp95_;
2985 void* _tmp96_ = NULL;
2987 GeeTimSortSlice* _tmp98_;
2992 _tmp92_ = self->priv->list;
2997 _tmp96_ = gee_tim_sort_slice_pop_last (_tmp95_);
2998 _tmp92_[_tmp94_] = _tmp96_;
2999 _tmp97_ = _tmp92_[_tmp94_];
3001 _tmp99_ = _tmp98_->length;
3004 GeeTimSortSlice* _tmp100_;
3006 GeeTimSortSlice* _tmp102_;
3008 GeeTimSortSlice* _tmp104_;
3010 GeeTimSortSlice* _tmp106_;
3013 GeeTimSortSlice* _tmp109_;
3015 GeeTimSortSlice* _tmp111_;
3017 GeeTimSortSlice* _tmp113_;
3019 GeeTimSortSlice* _tmp115_;
3022 GeeTimSortSlice* _tmp118_;
3024 GeeTimSortSlice* _tmp120_;
3026 GeeTimSortSlice* _tmp122_;
3029 _tmp101_ = _tmp100_->length;
3030 _vala_assert (_tmp101_ >= 0, "a.length >= 0");
3032 _tmp103_ = _tmp102_->length;
3033 _vala_assert (_tmp103_ >= 0, "b.length >= 0");
3035 _tmp105_ = self->priv->list;
3037 _tmp107_ = _tmp106_->index;
3040 _tmp110_ = _tmp109_->length;
3042 _tmp112_ = _tmp111_->length;
3043 gee_tim_sort_slice_merge_in_reversed (_tmp104_, _tmp105_, _tmp107_, _tmp108_ - _tmp110_, _tmp112_);
3045 _tmp114_ = self->priv->list;
3047 _tmp116_ = _tmp115_->index;
3050 _tmp119_ = _tmp118_->length;
3052 _tmp121_ = _tmp120_->length;
3054 _tmp123_ = _tmp122_->length;
3055 gee_tim_sort_slice_merge_in_reversed (_tmp113_, _tmp114_, _tmp116_, (_tmp117_ - _tmp119_) - _tmp121_, _tmp123_);
3057 _gee_tim_sort_slice_free0 (a);
3058 _gee_tim_sort_slice_free0 (b);
3062 b_count = _tmp124_ + 1;
3065 _tmp126_ = minimum_gallop;
3066 if (_tmp125_ >= _tmp126_) {
3071 _tmp127_ = minimum_gallop;
3072 minimum_gallop = _tmp127_ + 1;
3079 GeeTimSortSlice* _tmp133_;
3080 void* _tmp134_ = NULL;
3081 GeeTimSortSlice* _tmp135_;
3082 GeeTimSortSlice* _tmp136_;
3086 GeeTimSortSlice* _tmp139_;
3089 GeeTimSortSlice* _tmp142_;
3091 GeeTimSortSlice* _tmp144_;
3099 GeeTimSortSlice* _tmp152_;
3101 GeeTimSortSlice* _tmp154_;
3106 GeeTimSortSlice* _tmp183_;
3107 void* _tmp184_ = NULL;
3109 GeeTimSortSlice* _tmp186_;
3111 GeeTimSortSlice* _tmp212_;
3112 void* _tmp213_ = NULL;
3113 GeeTimSortSlice* _tmp214_;
3114 GeeTimSortSlice* _tmp215_;
3117 GeeTimSortSlice* _tmp218_;
3120 GeeTimSortSlice* _tmp221_;
3122 GeeTimSortSlice* _tmp223_;
3130 GeeTimSortSlice* _tmp231_;
3132 GeeTimSortSlice* _tmp233_;
3137 GeeTimSortSlice* _tmp262_;
3138 void* _tmp263_ = NULL;
3140 GeeTimSortSlice* _tmp265_;
3142 gboolean _tmp291_ = FALSE;
3145 _tmp129_ = minimum_gallop;
3151 _tmp130_ = minimum_gallop;
3152 _tmp131_ = _tmp128_;
3153 minimum_gallop = _tmp130_ - _tmp131_;
3154 _tmp132_ = minimum_gallop;
3155 self->priv->minimum_gallop = _tmp132_;
3157 _tmp134_ = gee_tim_sort_slice_peek_last (_tmp133_);
3160 _tmp137_ = _tmp136_->length;
3161 _tmp138_ = gee_tim_sort_gallop_rightmost (self, _tmp134_, _tmp135_, _tmp137_ - 1);
3164 _tmp140_ = _tmp139_->length;
3166 a_count = _tmp140_ - _tmp141_;
3168 _tmp143_ = self->priv->list;
3170 _tmp145_ = _tmp144_->index;
3175 gee_tim_sort_slice_merge_in_reversed (_tmp142_, _tmp143_, _tmp145_ + _tmp146_, _tmp147_ - _tmp148_, _tmp149_);
3178 dest = _tmp150_ - _tmp151_;
3181 gee_tim_sort_slice_shorten_end (_tmp152_, _tmp153_);
3183 _tmp155_ = _tmp154_->length;
3184 if (_tmp155_ == 0) {
3186 GeeTimSortSlice* _tmp156_;
3188 GeeTimSortSlice* _tmp158_;
3190 GeeTimSortSlice* _tmp160_;
3192 GeeTimSortSlice* _tmp162_;
3195 GeeTimSortSlice* _tmp165_;
3197 GeeTimSortSlice* _tmp167_;
3199 GeeTimSortSlice* _tmp169_;
3201 GeeTimSortSlice* _tmp171_;
3204 GeeTimSortSlice* _tmp174_;
3206 GeeTimSortSlice* _tmp176_;
3208 GeeTimSortSlice* _tmp178_;
3211 _tmp157_ = _tmp156_->length;
3212 _vala_assert (_tmp157_ >= 0, "a.length >= 0");
3214 _tmp159_ = _tmp158_->length;
3215 _vala_assert (_tmp159_ >= 0, "b.length >= 0");
3217 _tmp161_ = self->priv->list;
3219 _tmp163_ = _tmp162_->index;
3222 _tmp166_ = _tmp165_->length;
3224 _tmp168_ = _tmp167_->length;
3225 gee_tim_sort_slice_merge_in_reversed (_tmp160_, _tmp161_, _tmp163_, _tmp164_ - _tmp166_, _tmp168_);
3227 _tmp170_ = self->priv->list;
3229 _tmp172_ = _tmp171_->index;
3232 _tmp175_ = _tmp174_->length;
3234 _tmp177_ = _tmp176_->length;
3236 _tmp179_ = _tmp178_->length;
3237 gee_tim_sort_slice_merge_in_reversed (_tmp169_, _tmp170_, _tmp172_, (_tmp173_ - _tmp175_) - _tmp177_, _tmp179_);
3239 _gee_tim_sort_slice_free0 (a);
3240 _gee_tim_sort_slice_free0 (b);
3243 _tmp180_ = self->priv->list;
3245 dest = _tmp181_ - 1;
3248 _tmp184_ = gee_tim_sort_slice_pop_last (_tmp183_);
3249 _tmp180_[_tmp182_] = _tmp184_;
3250 _tmp185_ = _tmp180_[_tmp182_];
3252 _tmp187_ = _tmp186_->length;
3253 if (_tmp187_ == 1) {
3255 GeeTimSortSlice* _tmp188_;
3257 GeeTimSortSlice* _tmp190_;
3259 GeeTimSortSlice* _tmp192_;
3261 GeeTimSortSlice* _tmp194_;
3264 GeeTimSortSlice* _tmp197_;
3266 GeeTimSortSlice* _tmp199_;
3268 GeeTimSortSlice* _tmp201_;
3270 GeeTimSortSlice* _tmp203_;
3273 GeeTimSortSlice* _tmp206_;
3275 GeeTimSortSlice* _tmp208_;
3277 GeeTimSortSlice* _tmp210_;
3280 _tmp189_ = _tmp188_->length;
3281 _vala_assert (_tmp189_ >= 0, "a.length >= 0");
3283 _tmp191_ = _tmp190_->length;
3284 _vala_assert (_tmp191_ >= 0, "b.length >= 0");
3286 _tmp193_ = self->priv->list;
3288 _tmp195_ = _tmp194_->index;
3291 _tmp198_ = _tmp197_->length;
3293 _tmp200_ = _tmp199_->length;
3294 gee_tim_sort_slice_merge_in_reversed (_tmp192_, _tmp193_, _tmp195_, _tmp196_ - _tmp198_, _tmp200_);
3296 _tmp202_ = self->priv->list;
3298 _tmp204_ = _tmp203_->index;
3301 _tmp207_ = _tmp206_->length;
3303 _tmp209_ = _tmp208_->length;
3305 _tmp211_ = _tmp210_->length;
3306 gee_tim_sort_slice_merge_in_reversed (_tmp201_, _tmp202_, _tmp204_, (_tmp205_ - _tmp207_) - _tmp209_, _tmp211_);
3308 _gee_tim_sort_slice_free0 (a);
3309 _gee_tim_sort_slice_free0 (b);
3313 _tmp213_ = gee_tim_sort_slice_peek_last (_tmp212_);
3316 _tmp216_ = _tmp215_->length;
3317 _tmp217_ = gee_tim_sort_gallop_leftmost (self, _tmp213_, _tmp214_, _tmp216_ - 1);
3320 _tmp219_ = _tmp218_->length;
3322 b_count = _tmp219_ - _tmp220_;
3324 _tmp222_ = self->priv->list;
3326 _tmp224_ = _tmp223_->index;
3331 gee_tim_sort_slice_merge_in_reversed (_tmp221_, _tmp222_, _tmp224_ + _tmp225_, _tmp226_ - _tmp227_, _tmp228_);
3334 dest = _tmp229_ - _tmp230_;
3337 gee_tim_sort_slice_shorten_end (_tmp231_, _tmp232_);
3339 _tmp234_ = _tmp233_->length;
3340 if (_tmp234_ <= 1) {
3342 GeeTimSortSlice* _tmp235_;
3344 GeeTimSortSlice* _tmp237_;
3346 GeeTimSortSlice* _tmp239_;
3348 GeeTimSortSlice* _tmp241_;
3351 GeeTimSortSlice* _tmp244_;
3353 GeeTimSortSlice* _tmp246_;
3355 GeeTimSortSlice* _tmp248_;
3357 GeeTimSortSlice* _tmp250_;
3360 GeeTimSortSlice* _tmp253_;
3362 GeeTimSortSlice* _tmp255_;
3364 GeeTimSortSlice* _tmp257_;
3367 _tmp236_ = _tmp235_->length;
3368 _vala_assert (_tmp236_ >= 0, "a.length >= 0");
3370 _tmp238_ = _tmp237_->length;
3371 _vala_assert (_tmp238_ >= 0, "b.length >= 0");
3373 _tmp240_ = self->priv->list;
3375 _tmp242_ = _tmp241_->index;
3378 _tmp245_ = _tmp244_->length;
3380 _tmp247_ = _tmp246_->length;
3381 gee_tim_sort_slice_merge_in_reversed (_tmp239_, _tmp240_, _tmp242_, _tmp243_ - _tmp245_, _tmp247_);
3383 _tmp249_ = self->priv->list;
3385 _tmp251_ = _tmp250_->index;
3388 _tmp254_ = _tmp253_->length;
3390 _tmp256_ = _tmp255_->length;
3392 _tmp258_ = _tmp257_->length;
3393 gee_tim_sort_slice_merge_in_reversed (_tmp248_, _tmp249_, _tmp251_, (_tmp252_ - _tmp254_) - _tmp256_, _tmp258_);
3395 _gee_tim_sort_slice_free0 (a);
3396 _gee_tim_sort_slice_free0 (b);
3399 _tmp259_ = self->priv->list;
3401 dest = _tmp260_ - 1;
3404 _tmp263_ = gee_tim_sort_slice_pop_last (_tmp262_);
3405 _tmp259_[_tmp261_] = _tmp263_;
3406 _tmp264_ = _tmp259_[_tmp261_];
3408 _tmp266_ = _tmp265_->length;
3409 if (_tmp266_ == 0) {
3411 GeeTimSortSlice* _tmp267_;
3413 GeeTimSortSlice* _tmp269_;
3415 GeeTimSortSlice* _tmp271_;
3417 GeeTimSortSlice* _tmp273_;
3420 GeeTimSortSlice* _tmp276_;
3422 GeeTimSortSlice* _tmp278_;
3424 GeeTimSortSlice* _tmp280_;
3426 GeeTimSortSlice* _tmp282_;
3429 GeeTimSortSlice* _tmp285_;
3431 GeeTimSortSlice* _tmp287_;
3433 GeeTimSortSlice* _tmp289_;
3436 _tmp268_ = _tmp267_->length;
3437 _vala_assert (_tmp268_ >= 0, "a.length >= 0");
3439 _tmp270_ = _tmp269_->length;
3440 _vala_assert (_tmp270_ >= 0, "b.length >= 0");
3442 _tmp272_ = self->priv->list;
3444 _tmp274_ = _tmp273_->index;
3447 _tmp277_ = _tmp276_->length;
3449 _tmp279_ = _tmp278_->length;
3450 gee_tim_sort_slice_merge_in_reversed (_tmp271_, _tmp272_, _tmp274_, _tmp275_ - _tmp277_, _tmp279_);
3452 _tmp281_ = self->priv->list;
3454 _tmp283_ = _tmp282_->index;
3457 _tmp286_ = _tmp285_->length;
3459 _tmp288_ = _tmp287_->length;
3461 _tmp290_ = _tmp289_->length;
3462 gee_tim_sort_slice_merge_in_reversed (_tmp280_, _tmp281_, _tmp283_, (_tmp284_ - _tmp286_) - _tmp288_, _tmp290_);
3464 _gee_tim_sort_slice_free0 (a);
3465 _gee_tim_sort_slice_free0 (b);
3469 if (_tmp292_ < GEE_TIM_SORT_MINIMUM_GALLOP) {
3472 _tmp291_ = _tmp293_ < GEE_TIM_SORT_MINIMUM_GALLOP;
3476 _tmp294_ = _tmp291_;
3481 _tmp295_ = minimum_gallop;
3482 minimum_gallop = _tmp295_ + 1;
3483 _tmp296_ = minimum_gallop;
3484 self->priv->minimum_gallop = _tmp296_;
3489 GeeTimSortSlice* _tmp297_;
3491 GeeTimSortSlice* _tmp299_;
3493 GeeTimSortSlice* _tmp301_;
3495 GeeTimSortSlice* _tmp303_;
3498 GeeTimSortSlice* _tmp306_;
3500 GeeTimSortSlice* _tmp308_;
3502 GeeTimSortSlice* _tmp310_;
3504 GeeTimSortSlice* _tmp312_;
3507 GeeTimSortSlice* _tmp315_;
3509 GeeTimSortSlice* _tmp317_;
3511 GeeTimSortSlice* _tmp319_;
3514 _tmp298_ = _tmp297_->length;
3515 _vala_assert (_tmp298_ >= 0, "a.length >= 0");
3517 _tmp300_ = _tmp299_->length;
3518 _vala_assert (_tmp300_ >= 0, "b.length >= 0");
3520 _tmp302_ = self->priv->list;
3522 _tmp304_ = _tmp303_->index;
3525 _tmp307_ = _tmp306_->length;
3527 _tmp309_ = _tmp308_->length;
3528 gee_tim_sort_slice_merge_in_reversed (_tmp301_, _tmp302_, _tmp304_, _tmp305_ - _tmp307_, _tmp309_);
3530 _tmp311_ = self->priv->list;
3532 _tmp313_ = _tmp312_->index;
3535 _tmp316_ = _tmp315_->length;
3537 _tmp318_ = _tmp317_->length;
3539 _tmp320_ = _tmp319_->length;
3540 gee_tim_sort_slice_merge_in_reversed (_tmp310_, _tmp311_, _tmp313_, (_tmp314_ - _tmp316_) - _tmp318_, _tmp320_);
3542 _gee_tim_sort_slice_free0 (a);
3543 _gee_tim_sort_slice_free0 (b);
3544 g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
3545 g_clear_error (&_inner_error_);
3550 GeeTimSort* gee_tim_sort_construct (GType object_type, GType g_type, GBoxedCopyFunc g_dup_func, GDestroyNotify g_destroy_func) {
3551 GeeTimSort * self = NULL;
3552 self = (GeeTimSort*) g_object_new (object_type, NULL);
3553 self->priv->g_type = g_type;
3554 self->priv->g_dup_func = g_dup_func;
3555 self->priv->g_destroy_func = g_destroy_func;
3560 GeeTimSort* gee_tim_sort_new (GType g_type, GBoxedCopyFunc g_dup_func, GDestroyNotify g_destroy_func) {
3561 return gee_tim_sort_construct (GEE_TYPE_TIM_SORT, g_type, g_dup_func, g_destroy_func);
3565 static GeeTimSortSlice* gee_tim_sort_slice_new (void** list, gint index, gint length) {
3566 GeeTimSortSlice* self;
3570 self = g_slice_new0 (GeeTimSortSlice);
3571 gee_tim_sort_slice_instance_init (self);
3573 self->list = _tmp0_;
3575 self->index = _tmp1_;
3577 self->length = _tmp2_;
3582 static void gee_tim_sort_slice_copy (GeeTimSortSlice* self) {
3586 void* _tmp3_ = NULL;
3588 g_return_if_fail (self != NULL);
3589 _tmp0_ = self->list;
3590 _tmp1_ = self->index;
3591 _tmp2_ = self->length;
3592 _tmp3_ = g_memdup (&_tmp0_[_tmp1_], ((guint) sizeof (gpointer)) * _tmp2_);
3593 self->new_list = _tmp3_;
3594 _tmp4_ = self->new_list;
3595 self->list = _tmp4_;
3600 static inline void gee_tim_sort_slice_merge_in (GeeTimSortSlice* self, void** dest_array, gint index, gint dest_index, gint count) {
3606 g_return_if_fail (self != NULL);
3607 _tmp0_ = dest_array;
3608 _tmp1_ = dest_index;
3609 _tmp2_ = self->list;
3612 g_memmove (&_tmp0_[_tmp1_], &_tmp2_[_tmp3_], (gsize) (sizeof (gpointer) * _tmp4_));
3616 static inline void gee_tim_sort_slice_merge_in_reversed (GeeTimSortSlice* self, void** dest_array, gint index, gint dest_index, gint count) {
3622 g_return_if_fail (self != NULL);
3623 _tmp0_ = dest_array;
3624 _tmp1_ = dest_index;
3625 _tmp2_ = self->list;
3628 g_memmove (&_tmp0_[_tmp1_], &_tmp2_[_tmp3_], (gsize) (sizeof (gpointer) * _tmp4_));
3632 static inline void gee_tim_sort_slice_shorten_start (GeeTimSortSlice* self, gint n) {
3637 g_return_if_fail (self != NULL);
3638 _tmp0_ = self->index;
3640 self->index = _tmp0_ + _tmp1_;
3641 _tmp2_ = self->length;
3643 self->length = _tmp2_ - _tmp3_;
3647 static inline void gee_tim_sort_slice_shorten_end (GeeTimSortSlice* self, gint n) {
3650 g_return_if_fail (self != NULL);
3651 _tmp0_ = self->length;
3653 self->length = _tmp0_ - _tmp1_;
3657 static inline void* gee_tim_sort_slice_pop_first (GeeTimSortSlice* self) {
3658 void* result = NULL;
3663 g_return_val_if_fail (self != NULL, NULL);
3664 _tmp0_ = self->length;
3665 self->length = _tmp0_ - 1;
3666 _tmp1_ = self->list;
3667 _tmp2_ = self->index;
3668 self->index = _tmp2_ + 1;
3669 _tmp3_ = _tmp1_[_tmp2_];
3675 static inline void* gee_tim_sort_slice_pop_last (GeeTimSortSlice* self) {
3676 void* result = NULL;
3682 g_return_val_if_fail (self != NULL, NULL);
3683 _tmp0_ = self->length;
3684 self->length = _tmp0_ - 1;
3685 _tmp1_ = self->list;
3686 _tmp2_ = self->index;
3687 _tmp3_ = self->length;
3688 _tmp4_ = _tmp1_[_tmp2_ + _tmp3_];
3694 static inline void* gee_tim_sort_slice_peek_first (GeeTimSortSlice* self) {
3695 void* result = NULL;
3699 g_return_val_if_fail (self != NULL, NULL);
3700 _tmp0_ = self->list;
3701 _tmp1_ = self->index;
3702 _tmp2_ = _tmp0_[_tmp1_];
3708 static inline void* gee_tim_sort_slice_peek_last (GeeTimSortSlice* self) {
3709 void* result = NULL;
3714 g_return_val_if_fail (self != NULL, NULL);
3715 _tmp0_ = self->list;
3716 _tmp1_ = self->index;
3717 _tmp2_ = self->length;
3718 _tmp3_ = _tmp0_[(_tmp1_ + _tmp2_) - 1];
3724 static void gee_tim_sort_slice_reverse (GeeTimSortSlice* self) {
3730 g_return_if_fail (self != NULL);
3731 _tmp0_ = self->index;
3733 _tmp1_ = self->index;
3734 _tmp2_ = self->length;
3735 high = (_tmp1_ + _tmp2_) - 1;
3743 if (!(_tmp3_ < _tmp4_)) {
3750 gee_tim_sort_slice_swap (self, _tmp5_, _tmp6_);
3755 static inline void gee_tim_sort_slice_swap (GeeTimSortSlice* self, gint i, gint j) {
3769 g_return_if_fail (self != NULL);
3770 _tmp0_ = self->list;
3772 _tmp2_ = _tmp0_[_tmp1_];
3774 _tmp3_ = self->list;
3776 _tmp5_ = self->list;
3778 _tmp7_ = _tmp5_[_tmp6_];
3779 _tmp3_[_tmp4_] = _tmp7_;
3780 _tmp8_ = _tmp3_[_tmp4_];
3781 _tmp9_ = self->list;
3783 _tmp9_[_tmp10_] = temp;
3784 _tmp11_ = _tmp9_[_tmp10_];
3788 static void gee_tim_sort_slice_instance_init (GeeTimSortSlice * self) {
3792 static void gee_tim_sort_slice_free (GeeTimSortSlice* self) {
3794 _tmp0_ = self->new_list;
3795 if (_tmp0_ != NULL) {
3797 _tmp1_ = self->new_list;
3800 g_slice_free (GeeTimSortSlice, self);
3804 static void gee_tim_sort_class_init (GeeTimSortClass * klass) {
3805 gee_tim_sort_parent_class = g_type_class_peek_parent (klass);
3806 g_type_class_add_private (klass, sizeof (GeeTimSortPrivate));
3807 G_OBJECT_CLASS (klass)->get_property = _vala_gee_tim_sort_get_property;
3808 G_OBJECT_CLASS (klass)->set_property = _vala_gee_tim_sort_set_property;
3809 G_OBJECT_CLASS (klass)->finalize = gee_tim_sort_finalize;
3810 g_object_class_install_property (G_OBJECT_CLASS (klass), GEE_TIM_SORT_G_TYPE, g_param_spec_gtype ("g-type", "type", "type", G_TYPE_NONE, G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
3811 g_object_class_install_property (G_OBJECT_CLASS (klass), GEE_TIM_SORT_G_DUP_FUNC, g_param_spec_pointer ("g-dup-func", "dup func", "dup func", G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
3812 g_object_class_install_property (G_OBJECT_CLASS (klass), GEE_TIM_SORT_G_DESTROY_FUNC, g_param_spec_pointer ("g-destroy-func", "destroy func", "destroy func", G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
3816 static void gee_tim_sort_instance_init (GeeTimSort * self) {
3817 self->priv = GEE_TIM_SORT_GET_PRIVATE (self);
3821 static void gee_tim_sort_finalize (GObject* obj) {
3823 self = G_TYPE_CHECK_INSTANCE_CAST (obj, GEE_TYPE_TIM_SORT, GeeTimSort);
3824 _g_object_unref0 (self->priv->list_collection);
3825 self->priv->array = (_vala_array_free (self->priv->array, self->priv->array_length1, (GDestroyNotify) self->priv->g_destroy_func), NULL);
3826 self->priv->pending = (_vala_array_free (self->priv->pending, self->priv->pending_length1, (GDestroyNotify) gee_tim_sort_slice_free), NULL);
3827 (self->priv->compare_target_destroy_notify == NULL) ? NULL : (self->priv->compare_target_destroy_notify (self->priv->compare_target), NULL);
3828 self->priv->compare = NULL;
3829 self->priv->compare_target = NULL;
3830 self->priv->compare_target_destroy_notify = NULL;
3831 G_OBJECT_CLASS (gee_tim_sort_parent_class)->finalize (obj);
3836 * A stable, adaptive, iterative mergesort that requires far fewer than n*lg(n)
3837 * comparisons when running on partially sorted arrays, while offering
3838 * performance comparable to a traditional mergesort when run on random arrays.
3839 * Like all proper mergesorts, this sort is stable and runs O(n*log(n)) time
3840 * (worst case). In the worst case, this sort requires temporary storage space
3841 * for n/2 object references; in the best case, it requires only a small
3842 * constant amount of space.
3844 * This implementation was adapted from Tim Peters's list sort for Python,
3845 * which is described in detail here:
3846 * [[http://svn.python.org/projects/python/trunk/Objects/listsort.txt]]
3848 * Tim's C code may be found here:
3849 * [[http://svn.python.org/projects/python/trunk/Objects/listobject.c]]
3851 * The underlying techniques are described in this paper (and may have even
3854 * "Optimistic Sorting and Information Theoretic Complexity"
3856 * SODA (Fourth Annual ACM-SIAM Symposium on Discrete Algorithms), pp
3857 * 467-474, Austin, Texas, 25-27 January 1993.
3859 GType gee_tim_sort_get_type (void) {
3860 static volatile gsize gee_tim_sort_type_id__volatile = 0;
3861 if (g_once_init_enter (&gee_tim_sort_type_id__volatile)) {
3862 static const GTypeInfo g_define_type_info = { sizeof (GeeTimSortClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gee_tim_sort_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GeeTimSort), 0, (GInstanceInitFunc) gee_tim_sort_instance_init, NULL };
3863 GType gee_tim_sort_type_id;
3864 gee_tim_sort_type_id = g_type_register_static (G_TYPE_OBJECT, "GeeTimSort", &g_define_type_info, 0);
3865 g_once_init_leave (&gee_tim_sort_type_id__volatile, gee_tim_sort_type_id);
3867 return gee_tim_sort_type_id__volatile;
3871 static void _vala_gee_tim_sort_get_property (GObject * object, guint property_id, GValue * value, GParamSpec * pspec) {
3873 self = G_TYPE_CHECK_INSTANCE_CAST (object, GEE_TYPE_TIM_SORT, GeeTimSort);
3874 switch (property_id) {
3876 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
3882 static void _vala_gee_tim_sort_set_property (GObject * object, guint property_id, const GValue * value, GParamSpec * pspec) {
3884 self = G_TYPE_CHECK_INSTANCE_CAST (object, GEE_TYPE_TIM_SORT, GeeTimSort);
3885 switch (property_id) {
3886 case GEE_TIM_SORT_G_TYPE:
3887 self->priv->g_type = g_value_get_gtype (value);
3889 case GEE_TIM_SORT_G_DUP_FUNC:
3890 self->priv->g_dup_func = g_value_get_pointer (value);
3892 case GEE_TIM_SORT_G_DESTROY_FUNC:
3893 self->priv->g_destroy_func = g_value_get_pointer (value);
3896 G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
3902 static void _vala_array_destroy (gpointer array, gint array_length, GDestroyNotify destroy_func) {
3903 if ((array != NULL) && (destroy_func != NULL)) {
3905 for (i = 0; i < array_length; i = i + 1) {
3906 if (((gpointer*) array)[i] != NULL) {
3907 destroy_func (((gpointer*) array)[i]);
3914 static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func) {
3915 _vala_array_destroy (array, array_length, destroy_func);
3920 static void _vala_array_move (gpointer array, gsize element_size, gint src, gint dest, gint length) {
3921 g_memmove (((char*) array) + (dest * element_size), ((char*) array) + (src * element_size), length * element_size);
3922 if ((src < dest) && ((src + length) > dest)) {
3923 memset (((char*) array) + (src * element_size), 0, (dest - src) * element_size);
3924 } else if ((src > dest) && (src < (dest + length))) {
3925 memset (((char*) array) + ((dest + length) * element_size), 0, (src - dest) * element_size);
3926 } else if (src != dest) {
3927 memset (((char*) array) + (src * element_size), 0, length * element_size);