1 /*
2  * This file is part of gtkD.
3  *
4  * gtkD is free software; you can redistribute it and/or modify
5  * it under the terms of the GNU Lesser General Public License
6  * as published by the Free Software Foundation; either version 3
7  * of the License, or (at your option) any later version, with
8  * some exceptions, please read the COPYING file.
9  *
10  * gtkD is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public License
16  * along with gtkD; if not, write to the Free Software
17  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
18  */
19  
20 // generated automatically - do not change
21 // find conversion definition on APILookup.txt
22 // implement new conversion functionalities on the wrap.utils pakage
23 
24 /*
25  * Conversion parameters:
26  * inFile  = 
27  * outPack = glib
28  * outFile = SequenceIter
29  * strct   = GSequenceIter
30  * realStrct=
31  * ctorStrct=
32  * clss    = SequenceIter
33  * interf  = 
34  * class Code: No
35  * interface Code: No
36  * template for:
37  * extend  = 
38  * implements:
39  * prefixes:
40  * 	- g_sequence_iter_
41  * omit structs:
42  * omit prefixes:
43  * omit code:
44  * omit signals:
45  * imports:
46  * 	- glib.Sequence
47  * structWrap:
48  * 	- GSequence* -> Sequence
49  * 	- GSequenceIter* -> SequenceIter
50  * module aliases:
51  * local aliases:
52  * overrides:
53  */
54 
55 module glib.SequenceIter;
56 
57 public  import gtkc.glibtypes;
58 
59 private import gtkc.glib;
60 private import glib.ConstructionException;
61 
62 
63 private import glib.Sequence;
64 
65 
66 
67 
68 /**
69  * Description
70  * The GSequence data structure has the API of a list, but is
71  * implemented internally with a balanced binary tree. This means that
72  * it is possible to maintain a sorted list of n elements in time O(n
73  * log n). The data contained in each element can be either integer
74  * values, by using of the Type Conversion Macros,
75  * or simply pointers to any type of data.
76  * A GSequence is accessed through iterators,
77  * represented by a GSequenceIter. An iterator represents a position
78  * between two elements of the sequence. For example, the
79  * begin iterator represents the gap immediately
80  * before the first element of the sequence, and the
81  * end iterator represents the gap immediately
82  * after the last element. In an empty sequence, the begin and end
83  * iterators are the same.
84  * Some methods on GSequence operate on ranges of items. For example
85  * g_sequence_foreach_range() will call a user-specified function on
86  * each element with the given range. The range is delimited by the
87  * gaps represented by the passed-in iterators, so if you pass in the
88  * begin and end iterators, the range in question is the entire
89  * sequence.
90  * The function g_sequence_get() is used with an iterator to access the
91  * element immediately following the gap that the iterator represents.
92  * The iterator is said to point to that element.
93  * Iterators are stable across most operations on a GSequence. For
94  * example an iterator pointing to some element of a sequence will
95  * continue to point to that element even after the sequence is sorted.
96  * Even moving an element to another sequence using for example
97  * g_sequence_move_range() will not invalidate the iterators pointing
98  * to it. The only operation that will invalidate an iterator is when
99  * the element it points to is removed from any sequence.
100  */
101 public class SequenceIter
102 {
103 	
104 	/** the main Gtk struct */
105 	protected GSequenceIter* gSequenceIter;
106 	
107 	
108 	public GSequenceIter* getSequenceIterStruct()
109 	{
110 		return gSequenceIter;
111 	}
112 	
113 	
114 	/** the main Gtk struct as a void* */
115 	protected void* getStruct()
116 	{
117 		return cast(void*)gSequenceIter;
118 	}
119 	
120 	/**
121 	 * Sets our main struct and passes it to the parent class
122 	 */
123 	public this (GSequenceIter* gSequenceIter)
124 	{
125 		this.gSequenceIter = gSequenceIter;
126 	}
127 	
128 	/**
129 	 */
130 	
131 	/**
132 	 * Returns whether iter is the begin iterator
133 	 * Since 2.14
134 	 * Returns: whether iter is the begin iterator
135 	 */
136 	public int isBegin()
137 	{
138 		// gboolean g_sequence_iter_is_begin (GSequenceIter *iter);
139 		return g_sequence_iter_is_begin(gSequenceIter);
140 	}
141 	
142 	/**
143 	 * Returns whether iter is the end iterator
144 	 * Since 2.14
145 	 * Returns: Whether iter is the end iterator.
146 	 */
147 	public int isEnd()
148 	{
149 		// gboolean g_sequence_iter_is_end (GSequenceIter *iter);
150 		return g_sequence_iter_is_end(gSequenceIter);
151 	}
152 	
153 	/**
154 	 * Returns an iterator pointing to the next position after iter. If
155 	 * iter is the end iterator, the end iterator is returned.
156 	 * Since 2.14
157 	 * Returns: a GSequenceIter pointing to the next position after iter.
158 	 */
159 	public SequenceIter next()
160 	{
161 		// GSequenceIter * g_sequence_iter_next (GSequenceIter *iter);
162 		auto p = g_sequence_iter_next(gSequenceIter);
163 		
164 		if(p is null)
165 		{
166 			return null;
167 		}
168 		
169 		return new SequenceIter(cast(GSequenceIter*) p);
170 	}
171 	
172 	/**
173 	 * Returns an iterator pointing to the previous position before iter. If
174 	 * iter is the begin iterator, the begin iterator is returned.
175 	 * Since 2.14
176 	 * Returns: a GSequenceIter pointing to the previous position before iter.
177 	 */
178 	public SequenceIter prev()
179 	{
180 		// GSequenceIter * g_sequence_iter_prev (GSequenceIter *iter);
181 		auto p = g_sequence_iter_prev(gSequenceIter);
182 		
183 		if(p is null)
184 		{
185 			return null;
186 		}
187 		
188 		return new SequenceIter(cast(GSequenceIter*) p);
189 	}
190 	
191 	/**
192 	 * Returns the position of iter
193 	 * Since 2.14
194 	 * Returns: the position of iter
195 	 */
196 	public int getPosition()
197 	{
198 		// gint g_sequence_iter_get_position (GSequenceIter *iter);
199 		return g_sequence_iter_get_position(gSequenceIter);
200 	}
201 	
202 	/**
203 	 * Returns the GSequenceIter which is delta positions away from iter.
204 	 * If iter is closer than -delta positions to the beginning of the sequence,
205 	 * the begin iterator is returned. If iter is closer than delta positions
206 	 * to the end of the sequence, the end iterator is returned.
207 	 * Since 2.14
208 	 * Params:
209 	 * delta = A positive or negative number indicating how many positions away
210 	 * from iter the returned GSequenceIter will be.
211 	 * Returns: a GSequenceIter which is delta positions away from iter.
212 	 */
213 	public SequenceIter move(int delta)
214 	{
215 		// GSequenceIter * g_sequence_iter_move (GSequenceIter *iter,  gint delta);
216 		auto p = g_sequence_iter_move(gSequenceIter, delta);
217 		
218 		if(p is null)
219 		{
220 			return null;
221 		}
222 		
223 		return new SequenceIter(cast(GSequenceIter*) p);
224 	}
225 	
226 	/**
227 	 * Returns the GSequence that iter points into.
228 	 * Since 2.14
229 	 * Returns: the GSequence that iter points into.
230 	 */
231 	public Sequence getSequence()
232 	{
233 		// GSequence * g_sequence_iter_get_sequence (GSequenceIter *iter);
234 		auto p = g_sequence_iter_get_sequence(gSequenceIter);
235 		
236 		if(p is null)
237 		{
238 			return null;
239 		}
240 		
241 		return new Sequence(cast(GSequence*) p);
242 	}
243 	
244 	/**
245 	 * Returns a negative number if a comes before b, 0 if they are equal,
246 	 * and a positive number if a comes after b.
247 	 * The a and b iterators must point into the same sequence.
248 	 * Since 2.14
249 	 * Params:
250 	 * a = a GSequenceIter
251 	 * b = a GSequenceIter
252 	 * Returns: A negative number if a comes before b, 0 if they are equal, and a positive number if a comes after b.
253 	 */
254 	public int compare(SequenceIter b)
255 	{
256 		// gint g_sequence_iter_compare (GSequenceIter *a,  GSequenceIter *b);
257 		return g_sequence_iter_compare(gSequenceIter, (b is null) ? null : b.getSequenceIterStruct());
258 	}
259 }