source: appstream-generator/build/girepo/glib/Sequence.d @ 4841

Last change on this file since 4841 was 4841, checked in by Juanma, 2 years ago

Initial release

File size: 20.6 KB
Line 
1/*
2 * Licensed under the GNU Lesser General Public License Version 3
3 *
4 * This library is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU Lesser General Public License as published by
6 * the Free Software Foundation, either version 3 of the license, or
7 * (at your option) any later version.
8 *
9 * This software is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12 * GNU Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public License
15 * along with this library.  If not, see <http://www.gnu.org/licenses/>.
16 */
17
18// generated automatically - do not change
19
20
21module glib.Sequence;
22
23private import gi.glib;
24public  import gi.glibtypes;
25private import glib.ConstructionException;
26private import glib.SequenceIter;
27
28
29/**
30 * The #GSequence struct is an opaque data type representing a
31 * [sequence][glib-Sequences] data type.
32 */
33public class Sequence
34{
35        /** the main Gtk struct */
36        protected GSequence* gSequence;
37        protected bool ownedRef;
38
39        /** Get the main Gtk struct */
40        public GSequence* getSequenceStruct()
41        {
42                return gSequence;
43        }
44
45        /** the main Gtk struct as a void* */
46        protected void* getStruct()
47        {
48                return cast(void*)gSequence;
49        }
50
51        /**
52         * Sets our main struct and passes it to the parent class.
53         */
54        public this (GSequence* gSequence, bool ownedRef = false)
55        {
56                this.gSequence = gSequence;
57                this.ownedRef = ownedRef;
58        }
59
60
61        /**
62         * Adds a new item to the end of @seq.
63         *
64         * Params:
65         *     data = the data for the new item
66         *
67         * Returns: an iterator pointing to the new item
68         *
69         * Since: 2.14
70         */
71        public SequenceIter append(void* data)
72        {
73                auto p = g_sequence_append(gSequence, data);
74               
75                if(p is null)
76                {
77                        return null;
78                }
79               
80                return new SequenceIter(cast(GSequenceIter*) p);
81        }
82
83        /**
84         * Calls @func for each item in the sequence passing @user_data
85         * to the function.
86         *
87         * Params:
88         *     func = the function to call for each item in @seq
89         *     userData = user data passed to @func
90         *
91         * Since: 2.14
92         */
93        public void foreac(GFunc func, void* userData)
94        {
95                g_sequence_foreach(gSequence, func, userData);
96        }
97
98        /**
99         * Frees the memory allocated for @seq. If @seq has a data destroy
100         * function associated with it, that function is called on all items
101         * in @seq.
102         *
103         * Since: 2.14
104         */
105        public void free()
106        {
107                g_sequence_free(gSequence);
108        }
109
110        /**
111         * Returns the begin iterator for @seq.
112         *
113         * Returns: the begin iterator for @seq.
114         *
115         * Since: 2.14
116         */
117        public SequenceIter getBeginIter()
118        {
119                auto p = g_sequence_get_begin_iter(gSequence);
120               
121                if(p is null)
122                {
123                        return null;
124                }
125               
126                return new SequenceIter(cast(GSequenceIter*) p);
127        }
128
129        /**
130         * Returns the end iterator for @seg
131         *
132         * Returns: the end iterator for @seq
133         *
134         * Since: 2.14
135         */
136        public SequenceIter getEndIter()
137        {
138                auto p = g_sequence_get_end_iter(gSequence);
139               
140                if(p is null)
141                {
142                        return null;
143                }
144               
145                return new SequenceIter(cast(GSequenceIter*) p);
146        }
147
148        /**
149         * Returns the iterator at position @pos. If @pos is negative or larger
150         * than the number of items in @seq, the end iterator is returned.
151         *
152         * Params:
153         *     pos = a position in @seq, or -1 for the end
154         *
155         * Returns: The #GSequenceIter at position @pos
156         *
157         * Since: 2.14
158         */
159        public SequenceIter getIterAtPos(int pos)
160        {
161                auto p = g_sequence_get_iter_at_pos(gSequence, pos);
162               
163                if(p is null)
164                {
165                        return null;
166                }
167               
168                return new SequenceIter(cast(GSequenceIter*) p);
169        }
170
171        /**
172         * Returns the length of @seq
173         *
174         * Returns: the length of @seq
175         *
176         * Since: 2.14
177         */
178        public int getLength()
179        {
180                return g_sequence_get_length(gSequence);
181        }
182
183        /**
184         * Inserts @data into @sequence using @func to determine the new
185         * position. The sequence must already be sorted according to @cmp_func;
186         * otherwise the new position of @data is undefined.
187         *
188         * @cmp_func is called with two items of the @seq and @user_data.
189         * It should return 0 if the items are equal, a negative value
190         * if the first item comes before the second, and a positive value
191         * if the second  item comes before the first.
192         *
193         * Params:
194         *     data = the data to insert
195         *     cmpFunc = the function used to compare items in the sequence
196         *     cmpData = user data passed to @cmp_func.
197         *
198         * Returns: a #GSequenceIter pointing to the new item.
199         *
200         * Since: 2.14
201         */
202        public SequenceIter insertSorted(void* data, GCompareDataFunc cmpFunc, void* cmpData)
203        {
204                auto p = g_sequence_insert_sorted(gSequence, data, cmpFunc, cmpData);
205               
206                if(p is null)
207                {
208                        return null;
209                }
210               
211                return new SequenceIter(cast(GSequenceIter*) p);
212        }
213
214        /**
215         * Like g_sequence_insert_sorted(), but uses
216         * a #GSequenceIterCompareFunc instead of a #GCompareDataFunc as
217         * the compare function.
218         *
219         * @iter_cmp is called with two iterators pointing into @seq.
220         * It should return 0 if the iterators are equal, a negative
221         * value if the first iterator comes before the second, and a
222         * positive value if the second iterator comes before the first.
223         *
224         * It is called with two iterators pointing into @seq. It should
225         * return 0 if the iterators are equal, a negative value if the
226         * first iterator comes before the second, and a positive value
227         * if the second iterator comes before the first.
228         *
229         * Params:
230         *     data = data for the new item
231         *     iterCmp = the function used to compare iterators in the sequence
232         *     cmpData = user data passed to @cmp_func
233         *
234         * Returns: a #GSequenceIter pointing to the new item
235         *
236         * Since: 2.14
237         */
238        public SequenceIter insertSortedIter(void* data, GSequenceIterCompareFunc iterCmp, void* cmpData)
239        {
240                auto p = g_sequence_insert_sorted_iter(gSequence, data, iterCmp, cmpData);
241               
242                if(p is null)
243                {
244                        return null;
245                }
246               
247                return new SequenceIter(cast(GSequenceIter*) p);
248        }
249
250        /** */
251        public bool isEmpty()
252        {
253                return g_sequence_is_empty(gSequence) != 0;
254        }
255
256        /**
257         * Returns an iterator pointing to the position of the first item found
258         * equal to @data according to @cmp_func and @cmp_data. If more than one
259         * item is equal, it is not guaranteed that it is the first which is
260         * returned. In that case, you can use g_sequence_iter_next() and
261         * g_sequence_iter_prev() to get others.
262         *
263         * @cmp_func is called with two items of the @seq and @user_data.
264         * It should return 0 if the items are equal, a negative value if
265         * the first item comes before the second, and a positive value if
266         * the second item comes before the first.
267         *
268         * This function will fail if the data contained in the sequence is
269         * unsorted.  Use g_sequence_insert_sorted() or
270         * g_sequence_insert_sorted_iter() to add data to your sequence or, if
271         * you want to add a large amount of data, call g_sequence_sort() after
272         * doing unsorted insertions.
273         *
274         * Params:
275         *     data = data to lookup
276         *     cmpFunc = the function used to compare items in the sequence
277         *     cmpData = user data passed to @cmp_func
278         *
279         * Returns: an #GSequenceIter pointing to the position of the
280         *     first item found equal to @data according to @cmp_func and
281         *     @cmp_data, or %NULL if no such item exists
282         *
283         * Since: 2.28
284         */
285        public SequenceIter lookup(void* data, GCompareDataFunc cmpFunc, void* cmpData)
286        {
287                auto p = g_sequence_lookup(gSequence, data, cmpFunc, cmpData);
288               
289                if(p is null)
290                {
291                        return null;
292                }
293               
294                return new SequenceIter(cast(GSequenceIter*) p);
295        }
296
297        /**
298         * Like g_sequence_lookup(), but uses a #GSequenceIterCompareFunc
299         * instead of a #GCompareDataFunc as the compare function.
300         *
301         * @iter_cmp is called with two iterators pointing into @seq.
302         * It should return 0 if the iterators are equal, a negative value
303         * if the first iterator comes before the second, and a positive
304         * value if the second iterator comes before the first.
305         *
306         * This function will fail if the data contained in the sequence is
307         * unsorted.  Use g_sequence_insert_sorted() or
308         * g_sequence_insert_sorted_iter() to add data to your sequence or, if
309         * you want to add a large amount of data, call g_sequence_sort() after
310         * doing unsorted insertions.
311         *
312         * Params:
313         *     data = data to lookup
314         *     iterCmp = the function used to compare iterators in the sequence
315         *     cmpData = user data passed to @iter_cmp
316         *
317         * Returns: an #GSequenceIter pointing to the position of
318         *     the first item found equal to @data according to @cmp_func
319         *     and @cmp_data, or %NULL if no such item exists
320         *
321         * Since: 2.28
322         */
323        public SequenceIter lookupIter(void* data, GSequenceIterCompareFunc iterCmp, void* cmpData)
324        {
325                auto p = g_sequence_lookup_iter(gSequence, data, iterCmp, cmpData);
326               
327                if(p is null)
328                {
329                        return null;
330                }
331               
332                return new SequenceIter(cast(GSequenceIter*) p);
333        }
334
335        /**
336         * Adds a new item to the front of @seq
337         *
338         * Params:
339         *     data = the data for the new item
340         *
341         * Returns: an iterator pointing to the new item
342         *
343         * Since: 2.14
344         */
345        public SequenceIter prepend(void* data)
346        {
347                auto p = g_sequence_prepend(gSequence, data);
348               
349                if(p is null)
350                {
351                        return null;
352                }
353               
354                return new SequenceIter(cast(GSequenceIter*) p);
355        }
356
357        /**
358         * Returns an iterator pointing to the position where @data would
359         * be inserted according to @cmp_func and @cmp_data.
360         *
361         * @cmp_func is called with two items of the @seq and @user_data.
362         * It should return 0 if the items are equal, a negative value if
363         * the first item comes before the second, and a positive value if
364         * the second item comes before the first.
365         *
366         * If you are simply searching for an existing element of the sequence,
367         * consider using g_sequence_lookup().
368         *
369         * This function will fail if the data contained in the sequence is
370         * unsorted.  Use g_sequence_insert_sorted() or
371         * g_sequence_insert_sorted_iter() to add data to your sequence or, if
372         * you want to add a large amount of data, call g_sequence_sort() after
373         * doing unsorted insertions.
374         *
375         * Params:
376         *     data = data for the new item
377         *     cmpFunc = the function used to compare items in the sequence
378         *     cmpData = user data passed to @cmp_func
379         *
380         * Returns: an #GSequenceIter pointing to the position where @data
381         *     would have been inserted according to @cmp_func and @cmp_data
382         *
383         * Since: 2.14
384         */
385        public SequenceIter search(void* data, GCompareDataFunc cmpFunc, void* cmpData)
386        {
387                auto p = g_sequence_search(gSequence, data, cmpFunc, cmpData);
388               
389                if(p is null)
390                {
391                        return null;
392                }
393               
394                return new SequenceIter(cast(GSequenceIter*) p);
395        }
396
397        /**
398         * Like g_sequence_search(), but uses a #GSequenceIterCompareFunc
399         * instead of a #GCompareDataFunc as the compare function.
400         *
401         * @iter_cmp is called with two iterators pointing into @seq.
402         * It should return 0 if the iterators are equal, a negative value
403         * if the first iterator comes before the second, and a positive
404         * value if the second iterator comes before the first.
405         *
406         * If you are simply searching for an existing element of the sequence,
407         * consider using g_sequence_lookup_iter().
408         *
409         * This function will fail if the data contained in the sequence is
410         * unsorted.  Use g_sequence_insert_sorted() or
411         * g_sequence_insert_sorted_iter() to add data to your sequence or, if
412         * you want to add a large amount of data, call g_sequence_sort() after
413         * doing unsorted insertions.
414         *
415         * Params:
416         *     data = data for the new item
417         *     iterCmp = the function used to compare iterators in the sequence
418         *     cmpData = user data passed to @iter_cmp
419         *
420         * Returns: a #GSequenceIter pointing to the position in @seq
421         *     where @data would have been inserted according to @iter_cmp
422         *     and @cmp_data
423         *
424         * Since: 2.14
425         */
426        public SequenceIter searchIter(void* data, GSequenceIterCompareFunc iterCmp, void* cmpData)
427        {
428                auto p = g_sequence_search_iter(gSequence, data, iterCmp, cmpData);
429               
430                if(p is null)
431                {
432                        return null;
433                }
434               
435                return new SequenceIter(cast(GSequenceIter*) p);
436        }
437
438        /**
439         * Sorts @seq using @cmp_func.
440         *
441         * @cmp_func is passed two items of @seq and should
442         * return 0 if they are equal, a negative value if the
443         * first comes before the second, and a positive value
444         * if the second comes before the first.
445         *
446         * Params:
447         *     cmpFunc = the function used to sort the sequence
448         *     cmpData = user data passed to @cmp_func
449         *
450         * Since: 2.14
451         */
452        public void sort(GCompareDataFunc cmpFunc, void* cmpData)
453        {
454                g_sequence_sort(gSequence, cmpFunc, cmpData);
455        }
456
457        /**
458         * Like g_sequence_sort(), but uses a #GSequenceIterCompareFunc instead
459         * of a GCompareDataFunc as the compare function
460         *
461         * @cmp_func is called with two iterators pointing into @seq. It should
462         * return 0 if the iterators are equal, a negative value if the first
463         * iterator comes before the second, and a positive value if the second
464         * iterator comes before the first.
465         *
466         * Params:
467         *     cmpFunc = the function used to compare iterators in the sequence
468         *     cmpData = user data passed to @cmp_func
469         *
470         * Since: 2.14
471         */
472        public void sortIter(GSequenceIterCompareFunc cmpFunc, void* cmpData)
473        {
474                g_sequence_sort_iter(gSequence, cmpFunc, cmpData);
475        }
476
477        /**
478         * Calls @func for each item in the range (@begin, @end) passing
479         * @user_data to the function.
480         *
481         * Params:
482         *     begin = a #GSequenceIter
483         *     end = a #GSequenceIter
484         *     func = a #GFunc
485         *     userData = user data passed to @func
486         *
487         * Since: 2.14
488         */
489        public static void foreachRange(SequenceIter begin, SequenceIter end, GFunc func, void* userData)
490        {
491                g_sequence_foreach_range((begin is null) ? null : begin.getSequenceIterStruct(), (end is null) ? null : end.getSequenceIterStruct(), func, userData);
492        }
493
494        /**
495         * Returns the data that @iter points to.
496         *
497         * Params:
498         *     iter = a #GSequenceIter
499         *
500         * Returns: the data that @iter points to
501         *
502         * Since: 2.14
503         */
504        public static void* get(SequenceIter iter)
505        {
506                return g_sequence_get((iter is null) ? null : iter.getSequenceIterStruct());
507        }
508
509        /**
510         * Inserts a new item just before the item pointed to by @iter.
511         *
512         * Params:
513         *     iter = a #GSequenceIter
514         *     data = the data for the new item
515         *
516         * Returns: an iterator pointing to the new item
517         *
518         * Since: 2.14
519         */
520        public static SequenceIter insertBefore(SequenceIter iter, void* data)
521        {
522                auto p = g_sequence_insert_before((iter is null) ? null : iter.getSequenceIterStruct(), data);
523               
524                if(p is null)
525                {
526                        return null;
527                }
528               
529                return new SequenceIter(cast(GSequenceIter*) p);
530        }
531
532        /**
533         * Moves the item pointed to by @src to the position indicated by @dest.
534         * After calling this function @dest will point to the position immediately
535         * after @src. It is allowed for @src and @dest to point into different
536         * sequences.
537         *
538         * Params:
539         *     src = a #GSequenceIter pointing to the item to move
540         *     dest = a #GSequenceIter pointing to the position to which
541         *         the item is moved
542         *
543         * Since: 2.14
544         */
545        public static void move(SequenceIter src, SequenceIter dest)
546        {
547                g_sequence_move((src is null) ? null : src.getSequenceIterStruct(), (dest is null) ? null : dest.getSequenceIterStruct());
548        }
549
550        /**
551         * Inserts the (@begin, @end) range at the destination pointed to by ptr.
552         * The @begin and @end iters must point into the same sequence. It is
553         * allowed for @dest to point to a different sequence than the one pointed
554         * into by @begin and @end.
555         *
556         * If @dest is NULL, the range indicated by @begin and @end is
557         * removed from the sequence. If @dest iter points to a place within
558         * the (@begin, @end) range, the range does not move.
559         *
560         * Params:
561         *     dest = a #GSequenceIter
562         *     begin = a #GSequenceIter
563         *     end = a #GSequenceIter
564         *
565         * Since: 2.14
566         */
567        public static void moveRange(SequenceIter dest, SequenceIter begin, SequenceIter end)
568        {
569                g_sequence_move_range((dest is null) ? null : dest.getSequenceIterStruct(), (begin is null) ? null : begin.getSequenceIterStruct(), (end is null) ? null : end.getSequenceIterStruct());
570        }
571
572        /**
573         * Creates a new GSequence. The @data_destroy function, if non-%NULL will
574         * be called on all items when the sequence is destroyed and on items that
575         * are removed from the sequence.
576         *
577         * Params:
578         *     dataDestroy = a #GDestroyNotify function, or %NULL
579         *
580         * Returns: a new #GSequence
581         *
582         * Since: 2.14
583         *
584         * Throws: ConstructionException GTK+ fails to create the object.
585         */
586        public this(GDestroyNotify dataDestroy)
587        {
588                auto p = g_sequence_new(dataDestroy);
589               
590                if(p is null)
591                {
592                        throw new ConstructionException("null returned by new");
593                }
594               
595                this(cast(GSequence*) p);
596        }
597
598        /**
599         * Finds an iterator somewhere in the range (@begin, @end). This
600         * iterator will be close to the middle of the range, but is not
601         * guaranteed to be exactly in the middle.
602         *
603         * The @begin and @end iterators must both point to the same sequence
604         * and @begin must come before or be equal to @end in the sequence.
605         *
606         * Params:
607         *     begin = a #GSequenceIter
608         *     end = a #GSequenceIter
609         *
610         * Returns: a #GSequenceIter pointing somewhere in the
611         *     (@begin, @end) range
612         *
613         * Since: 2.14
614         */
615        public static SequenceIter rangeGetMidpoint(SequenceIter begin, SequenceIter end)
616        {
617                auto p = g_sequence_range_get_midpoint((begin is null) ? null : begin.getSequenceIterStruct(), (end is null) ? null : end.getSequenceIterStruct());
618               
619                if(p is null)
620                {
621                        return null;
622                }
623               
624                return new SequenceIter(cast(GSequenceIter*) p);
625        }
626
627        /**
628         * Removes the item pointed to by @iter. It is an error to pass the
629         * end iterator to this function.
630         *
631         * If the sequence has a data destroy function associated with it, this
632         * function is called on the data for the removed item.
633         *
634         * Params:
635         *     iter = a #GSequenceIter
636         *
637         * Since: 2.14
638         */
639        public static void remove(SequenceIter iter)
640        {
641                g_sequence_remove((iter is null) ? null : iter.getSequenceIterStruct());
642        }
643
644        /**
645         * Removes all items in the (@begin, @end) range.
646         *
647         * If the sequence has a data destroy function associated with it, this
648         * function is called on the data for the removed items.
649         *
650         * Params:
651         *     begin = a #GSequenceIter
652         *     end = a #GSequenceIter
653         *
654         * Since: 2.14
655         */
656        public static void removeRange(SequenceIter begin, SequenceIter end)
657        {
658                g_sequence_remove_range((begin is null) ? null : begin.getSequenceIterStruct(), (end is null) ? null : end.getSequenceIterStruct());
659        }
660
661        /**
662         * Changes the data for the item pointed to by @iter to be @data. If
663         * the sequence has a data destroy function associated with it, that
664         * function is called on the existing data that @iter pointed to.
665         *
666         * Params:
667         *     iter = a #GSequenceIter
668         *     data = new data for the item
669         *
670         * Since: 2.14
671         */
672        public static void set(SequenceIter iter, void* data)
673        {
674                g_sequence_set((iter is null) ? null : iter.getSequenceIterStruct(), data);
675        }
676
677        /**
678         * Moves the data pointed to a new position as indicated by @cmp_func. This
679         * function should be called for items in a sequence already sorted according
680         * to @cmp_func whenever some aspect of an item changes so that @cmp_func
681         * may return different values for that item.
682         *
683         * @cmp_func is called with two items of the @seq and @user_data.
684         * It should return 0 if the items are equal, a negative value if
685         * the first item comes before the second, and a positive value if
686         * the second item comes before the first.
687         *
688         * Params:
689         *     iter = A #GSequenceIter
690         *     cmpFunc = the function used to compare items in the sequence
691         *     cmpData = user data passed to @cmp_func.
692         *
693         * Since: 2.14
694         */
695        public static void sortChanged(SequenceIter iter, GCompareDataFunc cmpFunc, void* cmpData)
696        {
697                g_sequence_sort_changed((iter is null) ? null : iter.getSequenceIterStruct(), cmpFunc, cmpData);
698        }
699
700        /**
701         * Like g_sequence_sort_changed(), but uses
702         * a #GSequenceIterCompareFunc instead of a #GCompareDataFunc as
703         * the compare function.
704         *
705         * @iter_cmp is called with two iterators pointing into @seq. It should
706         * return 0 if the iterators are equal, a negative value if the first
707         * iterator comes before the second, and a positive value if the second
708         * iterator comes before the first.
709         *
710         * Params:
711         *     iter = a #GSequenceIter
712         *     iterCmp = the function used to compare iterators in the sequence
713         *     cmpData = user data passed to @cmp_func
714         *
715         * Since: 2.14
716         */
717        public static void sortChangedIter(SequenceIter iter, GSequenceIterCompareFunc iterCmp, void* cmpData)
718        {
719                g_sequence_sort_changed_iter((iter is null) ? null : iter.getSequenceIterStruct(), iterCmp, cmpData);
720        }
721
722        /**
723         * Swaps the items pointed to by @a and @b. It is allowed for @a and @b
724         * to point into difference sequences.
725         *
726         * Params:
727         *     a = a #GSequenceIter
728         *     b = a #GSequenceIter
729         *
730         * Since: 2.14
731         */
732        public static void swap(SequenceIter a, SequenceIter b)
733        {
734                g_sequence_swap((a is null) ? null : a.getSequenceIterStruct(), (b is null) ? null : b.getSequenceIterStruct());
735        }
736}
Note: See TracBrowser for help on using the repository browser.