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 * The GSequence data structure has the API of a list, but is 70 * implemented internally with a balanced binary tree. This means that 71 * it is possible to maintain a sorted list of n elements in time O(n 72 * log n). The data contained in each element can be either integer 73 * values, by using of the Type Conversion Macros, 74 * or simply pointers to any type of data. 75 * 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 * 85 * Some methods on GSequence operate on ranges of items. For example 86 * g_sequence_foreach_range() will call a user-specified function on 87 * each element with the given range. The range is delimited by the 88 * gaps represented by the passed-in iterators, so if you pass in the 89 * begin and end iterators, the range in question is the entire 90 * sequence. 91 * 92 * The function g_sequence_get() is used with an iterator to access the 93 * element immediately following the gap that the iterator represents. 94 * The iterator is said to point to that element. 95 * 96 * Iterators are stable across most operations on a GSequence. For 97 * example an iterator pointing to some element of a sequence will 98 * continue to point to that element even after the sequence is sorted. 99 * Even moving an element to another sequence using for example 100 * g_sequence_move_range() will not invalidate the iterators pointing 101 * to it. The only operation that will invalidate an iterator is when 102 * the element it points to is removed from any sequence. 103 */ 104 public class SequenceIter 105 { 106 107 /** the main Gtk struct */ 108 protected GSequenceIter* gSequenceIter; 109 110 111 public GSequenceIter* getSequenceIterStruct() 112 { 113 return gSequenceIter; 114 } 115 116 117 /** the main Gtk struct as a void* */ 118 protected void* getStruct() 119 { 120 return cast(void*)gSequenceIter; 121 } 122 123 /** 124 * Sets our main struct and passes it to the parent class 125 */ 126 public this (GSequenceIter* gSequenceIter) 127 { 128 this.gSequenceIter = gSequenceIter; 129 } 130 131 /** 132 */ 133 134 /** 135 * Returns whether iter is the begin iterator 136 * Since 2.14 137 * Returns: whether iter is the begin iterator 138 */ 139 public int isBegin() 140 { 141 // gboolean g_sequence_iter_is_begin (GSequenceIter *iter); 142 return g_sequence_iter_is_begin(gSequenceIter); 143 } 144 145 /** 146 * Returns whether iter is the end iterator 147 * Since 2.14 148 * Returns: Whether iter is the end iterator. 149 */ 150 public int isEnd() 151 { 152 // gboolean g_sequence_iter_is_end (GSequenceIter *iter); 153 return g_sequence_iter_is_end(gSequenceIter); 154 } 155 156 /** 157 * Returns an iterator pointing to the next position after iter. If 158 * iter is the end iterator, the end iterator is returned. 159 * Since 2.14 160 * Returns: a GSequenceIter pointing to the next position after iter. 161 */ 162 public SequenceIter next() 163 { 164 // GSequenceIter * g_sequence_iter_next (GSequenceIter *iter); 165 auto p = g_sequence_iter_next(gSequenceIter); 166 167 if(p is null) 168 { 169 return null; 170 } 171 172 return new SequenceIter(cast(GSequenceIter*) p); 173 } 174 175 /** 176 * Returns an iterator pointing to the previous position before iter. If 177 * iter is the begin iterator, the begin iterator is returned. 178 * Since 2.14 179 * Returns: a GSequenceIter pointing to the previous position before iter. 180 */ 181 public SequenceIter prev() 182 { 183 // GSequenceIter * g_sequence_iter_prev (GSequenceIter *iter); 184 auto p = g_sequence_iter_prev(gSequenceIter); 185 186 if(p is null) 187 { 188 return null; 189 } 190 191 return new SequenceIter(cast(GSequenceIter*) p); 192 } 193 194 /** 195 * Returns the position of iter 196 * Since 2.14 197 * Returns: the position of iter 198 */ 199 public int getPosition() 200 { 201 // gint g_sequence_iter_get_position (GSequenceIter *iter); 202 return g_sequence_iter_get_position(gSequenceIter); 203 } 204 205 /** 206 * Returns the GSequenceIter which is delta positions away from iter. 207 * If iter is closer than -delta positions to the beginning of the sequence, 208 * the begin iterator is returned. If iter is closer than delta positions 209 * to the end of the sequence, the end iterator is returned. 210 * Since 2.14 211 * Params: 212 * delta = A positive or negative number indicating how many positions away 213 * from iter the returned GSequenceIter will be. 214 * Returns: a GSequenceIter which is delta positions away from iter. 215 */ 216 public SequenceIter move(int delta) 217 { 218 // GSequenceIter * g_sequence_iter_move (GSequenceIter *iter, gint delta); 219 auto p = g_sequence_iter_move(gSequenceIter, delta); 220 221 if(p is null) 222 { 223 return null; 224 } 225 226 return new SequenceIter(cast(GSequenceIter*) p); 227 } 228 229 /** 230 * Returns the GSequence that iter points into. 231 * Since 2.14 232 * Returns: the GSequence that iter points into. 233 */ 234 public Sequence getSequence() 235 { 236 // GSequence * g_sequence_iter_get_sequence (GSequenceIter *iter); 237 auto p = g_sequence_iter_get_sequence(gSequenceIter); 238 239 if(p is null) 240 { 241 return null; 242 } 243 244 return new Sequence(cast(GSequence*) p); 245 } 246 247 /** 248 * Returns a negative number if a comes before b, 0 if they are equal, 249 * and a positive number if a comes after b. 250 * The a and b iterators must point into the same sequence. 251 * Since 2.14 252 * Params: 253 * a = a GSequenceIter 254 * b = a GSequenceIter 255 * Returns: A negative number if a comes before b, 0 if they are equal, and a positive number if a comes after b. 256 */ 257 public int compare(SequenceIter b) 258 { 259 // gint g_sequence_iter_compare (GSequenceIter *a, GSequenceIter *b); 260 return g_sequence_iter_compare(gSequenceIter, (b is null) ? null : b.getSequenceIterStruct()); 261 } 262 }