/src/wrappers/glib/library/data_types/iterator_on_g_list.e
Specman e | 78 lines | 63 code | 12 blank | 3 comment | 2 complexity | b2f2e812bbbe07bdfae018183bc4e2d1 MD5 | raw file
1indexing 2 description: "." 3 copyright: "(C) 2006 Paolo Redaelli " 4 license: "LGPL v2 or later" 5 date: "$Date:$" 6 revision: "$Revision:$" 7 8class ITERATOR_ON_G_LIST [ITEM->WRAPPER] 9inherit 10 ITERATOR [ITEM] 11 WRAPPER_HANDLER 12 13insert 14 GLIST_EXTERNALS 15 GLIST_STRUCT 16 GLOBAL_CACHE 17 18creation make 19 20feature {} -- Creation 21 make (a_list: G_LIST_TRAVERSABLE[ITEM]) is 22 require 23 valid_list: a_list /= Void 24 do 25 list := a_list 26 end 27 28feature {} -- Implementation 29 list: G_LIST_TRAVERSABLE[ITEM] 30 current_element: POINTER 31 32feature -- Iterator's features 33 start is 34 do 35 current_element := list.handle 36 end 37 38 is_off: BOOLEAN is 39 do 40 Result := (current_element.is_null) 41 end 42 43 item: ITEM is 44 local 45 ptr: POINTER 46 l: WRAPPER 47 do 48 ptr := glist_struct_get_data (current_element) 49 if ptr.is_not_null then 50 l := wrappers.reference_at(ptr) 51 Result ?= l -- TODO: this tricks the compiler. Combining the line just above and this one seems to fail 52 if Result=Void 53 then Result:=list.wrapper(ptr) 54 end 55 end 56 end 57 58 next is 59 do 60 current_element := glist_struct_get_next (current_element) 61 end 62 63feature -- Bi-directional iterator features. 64 is_at_first: BOOLEAN is 65 -- Is Current iterator at the beginning of the G_LIST? 66 do 67 Result := (current_element = list.handle) 68 end 69 70 prev is 71 require past_start: not is_at_first 72 do 73 current_element := glist_struct_get_prev (current_element) 74 end 75 76 --feature dispose is do -- Note: disposing an interator is a 77 --no-operation. end 78end