PageRenderTime 34ms CodeModel.GetById 20ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/src/wrappers/glib/partially-implemented/g_reference_array.e

http://github.com/tybor/Liberty
Specman e | 827 lines | 337 code | 122 blank | 368 comment | 27 complexity | bc434f905a2d119802cf9138c1ce2091 MD5 | raw file
  1indexing
  2	description: "Arrays of non-expanded wrappers of C data structures; it grows automatically as new elements are added."
  3	copyright: "(C) 2005 Paolo Redaelli "
  4	license: "LGPL v2 or later"
  5	date: "$Date:$"
  6	revision: "$REvision:$"
  7
  8class G_REFERENCE_ARRAY [ITEM->C_STRUCT]
  9	-- Warning: this class will be soon called G_ARRAY and the "old" 
 10	-- G_ARRAY will become G_EXPANDED_ARRAY or something like this. 
 11	-- Paolo 2007-04-08
 12	
 13	-- Array of referenced C structures (i.e. non-expanded wrappers of
 14	-- C data structures); it grows automatically as new elements are
 15	-- added.
 16
 17	-- Reference arrays wraps GPtrArray, similar to GArray but are used
 18	-- only for storing pointers, i.e. reference to other objects,
 19	-- speaking in Eiffel.
 20
 21	-- Note: If you remove elements from the array, elements at the end
 22	-- of the array are moved into the space previously occupied by the
 23	-- removed element. This means that you should not rely on the
 24	-- index of particular elements remaining the same. You should also
 25	-- be careful when deleting elements while iterating over the
 26	-- array.
 27
 28	-- To create an array, use `empty' or `with_capacity'.
 29	
 30	-- To add elements to a pointer array, use `add'.
 31	
 32	-- To remove elements from a pointer array, use
 33	-- g_ptr_array_remove(), g_ptr_array_remove_index() or
 34	-- g_ptr_array_remove_index_fast().
 35	
 36	-- To access an element of a pointer array, use
 37	-- g_ptr_array_index().
 38
 39	-- To set the size of a pointer array, use g_ptr_array_set_size().
 40	
 41	-- To free a pointer array, use g_ptr_array_free().
 42	
 43	-- Example 5. Using a GPtrArray
 44	
 45	--   GPtrArray *gparray;
 46	--   gchar *string1 = "one", *string2 = "two", *string3 = "three";
 47	
 48	--   gparray = g_ptr_array_new ();
 49	--   g_ptr_array_add (gparray, (gpointer) string1);
 50	--   g_ptr_array_add (gparray, (gpointer) string2);
 51	--   g_ptr_array_add (gparray, (gpointer) string3);
 52
 53	--   if (g_ptr_array_index (gparray, 0) != (gpointer) string1)
 54	--     g_print ("ERROR: got %p instead of %p\n",
 55	--              g_ptr_array_index (gparray, 0), string1);
 56	
 57	--   g_ptr_array_free (gparray, TRUE);
 58
 59inherit 
 60	C_STRUCT 
 61		rename exists as struct_exists
 62		undefine fill_tagged_out_memory
 63		redefine copy, is_equal
 64		end
 65
 66	COLLECTION [ITEM]
 67		redefine -- features that can be implemented in a smarter way, knowing that there is an array of pointers to wrapped features.
 68			fast_first_index_of,
 69			--fast_index_of,
 70			fast_last_index_of,
 71			has,
 72			fast_has,
 73			swap
 74		end
 75	
 76insert
 77	WRAPPER_FACTORY [ITEM] -- undefine fill_tagged_out_memory end
 78	G_PTR_ARRAY_EXTERNALS undefine fill_tagged_out_memory end
 79	
 80creation empty, with_capacity, from_external_pointer
 81
 82feature 
 83	empty is
 84			-- Creates a new empty array.		
 85		do
 86			from_external_pointer(g_ptr_array_new)
 87		ensure is_empty
 88		end
 89
 90	with_capacity (a_size: INTEGER) is
 91			-- Creates a new GPtrArray with a_size preallocated. This
 92			-- avoids frequent reallocation, if you are going to add many
 93			-- pointers to the array. Note however that the size of the
 94			-- array is still 0.
 95
 96			-- Note: `a_size' should be NATURAL
 97		require natural: a_size>=0
 98		do 
 99			from_external_pointer(g_ptr_array_sized_new(a_size))
100		ensure is_empty
101		end
102
103feature -- Indexing:
104	lower: INTEGER_32 is 0 
105		-- Minimum index.  See also `upper', `valid_index', `item'.
106
107	upper: INTEGER_32 is 
108		-- Maximum index.  See also `lower', `valid_index', `item'.
109		do
110			Result:=count-1
111		end
112
113feature -- Counting:
114	count: INTEGER_32 is
115			-- Number of available indices See also `is_empty',
116			-- `lower', `upper'. 
117		do
118			Result:=get_len(handle)
119		end
120
121	is_empty: BOOLEAN is
122			-- Is collection empty ?  See also `count'.
123		do
124			Result := (count = 0)
125		end
126
127feature -- Accessing:
128	item (index: INTEGER_32): ITEM is
129			-- Item at the corresponding `index'.  See also `lower',
130			-- `upper', `valid_index'.
131		local 
132			p: POINTER; 
133			npa: NATIVE_ARRAY[POINTER]
134		do
135			npa := npa.from_pointer(get_pdata(handle))
136			p := npa.item(index)
137			if p.is_not_null then
138				if wrappers.has(p) then Result::=wrappers.item(p)
139				else print_wrapper_factory_notice
140				end
141			end
142		end
143
144	first: ITEM is
145			-- The very `first' item.
146		do		
147			Result:=item(lower)
148		end
149
150	last: ITEM is
151			-- The `last' item.
152			-- See also `first', `item'.
153		do
154			Result:=item(upper)
155		end
156
157feature   -- Other features:
158	get_new_iterator: ITERATOR[ITEM] is
159		obsolete "Currently unimplemented!"
160		do
161			-- create {G_ARRAY_ITERATOR[ITEM]} Result.from_array(Current)
162		end
163feature    -- Writing:
164	put (element: ITEM; an_index: INTEGER_32) is
165			-- Make `element' the item at `an_index'.  See also `lower',
166			-- `upper', `valid_index', `item', `swap', `force'.
167		local npa: NATIVE_ARRAY[POINTER]
168		do
169			npa:=npa.from_pointer(get_pdata(handle))
170			npa.put(null_or(element),i)
171		end
172	
173	swap (i1, i2: INTEGER_32) is
174			-- Swap item at index `i1' with item at index `i2'.  See also
175			-- `item', `put'.
176		local npa: NATIVE_ARRAY[POINTER]; tmp: POINTER
177		do
178			-- Working at C level
179			npa:=npa.from_pointer(get_pdata(handle))
180			tmp := npa.item(i1)
181			npa.put( npa.item(i2), i1)
182			npa.put( tmp, i2)
183		end
184
185	set_all_with (v: ITEM) is
186			-- Set all items with value `v'.  See also `set_slice_with'.
187		local i:INTEGER
188		do
189			from i:=lower until i>upper
190			loop put(v,i); i:=i+1
191			end
192		end
193	
194	-- set_slice_with (v: ITEM_; lower_index, upper_index: INTEGER_32) is
195	-- Set all items in range [`lower_index' .. `upper_index'] with `v'.
196	-- See also `set_all_with'.
197	-- local i:INTEGER
198	-- do
199	-- from i:=lower_index until i>upper_index
200	-- loop put(v,i); i:=i+1
201	-- end
202	-- end
203
204	clear_all is
205			-- Set every item to its default value. The `count' is not
206			-- affected.  See also `clear', `all_default'.
207		local i:INTEGER
208		do
209			from i:=lower until i>upper
210			loop put(Void,i); i:=i+1
211			end
212		end
213
214feature -- Adding:
215	add_first (element: ITEM) is
216			-- Add a new item in first position : `count' is increased by
217			-- one and all other items are shifted right.  See also
218			-- `add_last', `first', `last', `add'.
219
220			-- Note: this is an O(n) feature, with n=count. This call in 
221			-- a loop makes a feature at least O(n^2) 
222		local i: INTEGER
223		do
224			from i:=upper until i<lower loop
225				put (item(i), i+1)
226				i := i-1
227			end
228			put(element,lower)
229		end
230
231	add_last (element: ITEM) is
232			-- Add a new item at the end; `count' is increased by one.
233			-- See also `add_first', `last', `first', `add'.
234		do
235			g_ptr_array_add (handle, null_or(element))
236		end
237
238	add (element: ITEM; index: INTEGER_32) is
239			-- Add a new `element' at rank `index' : `count' is increased
240			-- by one and range [`index' .. `upper'] is shifted right by
241			-- one position.
242
243			-- See also `add_first', `add_last', `append_collection'.
244		local i,j: INTEGER
245		do
246			from i:=upper; j:=upper+1 until i=index loop
247				put(item(i),j)
248				j:=i; i:=i-1
249			end
250		end
251
252	append_collection (other: COLLECTION[ITEM]) is
253			-- Append `other' to Current.  See also `add_last',
254			-- `add_first', `add'.
255		
256			-- Complexity: O(other.count)
257		local i: ITERATOR[ITEM]
258		do
259			i := other.get_new_iterator
260			from i.start until i.is_off loop
261				add_last(i.item) i.next
262			end
263		end
264
265feature -- Modification:
266	force (element: E_; index: INTEGER_32) is
267			-- Make `element' the item at `index', enlarging the
268			-- collection if necessary (new bounds except `index' are
269			-- initialized with default values).
270		
271			-- See also `put', `item', `swap'.
272		obsolete "unimplemented!"
273		do
274		end
275
276	copy (other: like Current) is
277			-- Reinitialize by copying all the items of `other'.
278		local i: INTEGER
279		do
280			-- Looping from upper to lower, so Current array is resized
281			-- only one time.
282			from i:=other.upper until i<other.lower loop
283				force(other.item(i),i)
284				i:=i-1
285			end
286		end
287
288	from_collection (model: TRAVERSABLE[ITEM]) is
289			-- Initialize the current object with the contents of `model'.
290		local i: ITERATOR[ITEM]
291		do
292			from_external_pointer(g_ptr_array_sized_new(model.count))
293			from i:=model.get_new_iterator; i.start until i.is_off 
294			loop
295				add(i.iter)
296				i.next
297			end
298		end
299
300feature -- Removing:
301	remove_first is
302			-- Remove the `first' element of the collection.
303		local removed: POINTER
304		do
305			removed := g_ptr_array_remove_index (handle, lower)
306		end
307	
308	remove_head (n: INTEGER_32) is
309			-- Remove the `n' elements of the collection.
310
311			-- See also `remove_tail', `remove', `remove_first'.
312		do
313			g_ptr_array_remove_range(handle, lower,n)
314		end
315	
316	remove (index: INTEGER_32) is
317			-- Remove the item at position `index'. Followings items are
318			-- shifted left by one position.
319		
320			-- See also `remove_first', `remove_head', `remove_tail',
321			-- `remove_last'.
322		local removed: POINTER
323		do
324			removed := g_ptr_array_remove_index (handle, index)
325		end
326
327	remove_last is
328			-- Remove the `last' item.
329		
330			-- See also `remove_first', `remove', `remove_tail'.
331		local removed: POINTER
332		do
333			removed := g_ptr_array_remove_index (handle, upper)
334		end
335
336
337	remove_tail (n: INTEGER_32) is
338		do
339			g_ptr_array_remove_range(handle, upper-n, n)
340		end
341
342	clear_count is
343			-- Discard all items (`is_empty' is True after that call). If
344			-- possible, the actual implementation is supposed to keep
345			-- its internal storage area in order to refill `Current' in
346			-- an efficient way.
347
348			-- See also `clear_count_and_capacity'.
349		do
350			set_size(0)
351		end
352	
353	clear_count_and_capacity is
354			-- Discard all items (`is_empty' is True after that call). If
355			-- possible, the actual implementation is supposed to release
356			-- its internal storage area for this memory to be used by
357			-- other objects.
358		
359			-- See also `clear_count'.
360		local p: POINTER
361		do
362			-- Implemented freeing the old one and recreating it.
363			p := g_ptr_array_free (handle, 1)
364		end
365	
366feature -- Looking and Searching:
367	has (x: ITEM): BOOLEAN is
368			-- Look for `x' using `is_equal' for comparison.
369
370			-- See also `fast_has', `index_of', `fast_index_of'.
371		local i: INTEGER
372		do
373			from i:=upper until Result=True or else i<lower 
374			loop
375				Result := x.is_equal(item(i))
376				i:=i-1
377			end
378		end
379	
380	fast_has (x: ITEM): BOOLEAN is
381			-- Look for `x' using basic `=' for comparison.
382
383			-- See also `has', `fast_index_of', `index_of'.
384		local i: INTEGER
385		do
386			from i:=upper until Result=True or else i<lower
387			loop
388				Result := (x.handle = g_ptr_array_index(handle,i))
389				i:=i-1
390			end
391		end
392	
393--    first_index_of (element: ITEM): INTEGER_32 is
394-- 			-- Give the index of the first occurrence of `element' using
395-- 			-- `is_equal' for comparison.  Answer `upper + 1' when
396-- 			-- `element' is not inside.
397
398-- 			-- See also `fast_first_index_of', `index_of', `last_index_of', 
399-- 			-- `reverse_index_of'.
400-- 		local i: INTEGER_32; found: BOOLEAN
401-- 		do
402-- 			from i:=lower until found or else i>upper
403-- 			loop
404-- 				if element.is_equal(item(i)) then
405-- 					Result:=i; found := True
406-- 				end
407-- 				i := i+1
408-- 			end
409-- 		end
410
411--    index_of (element: ITEM; start_index: INTEGER_32): INTEGER_32 is
412-- 			-- Using `is_equal' for comparison, gives the index of the
413-- 			-- first occurrence of `element' at or after
414-- 			-- `start_index'. Answer `upper + 1' when `element' when the
415-- 			-- search fail.
416
417-- 			-- See also `fast_index_of', `reverse_index_of',
418-- 			-- `first_index_of'.
419-- 		local i: INTEGER_32; found: BOOLEAN
420-- 		do
421-- 			from i:=start_index until found or else i>upper
422-- 			loop
423-- 				if element.is_equal(item(i)) then
424-- 					Result:=i; found := True
425-- 				end
426-- 				i := i+1
427-- 			end
428-- 		end
429			
430-- 	reverse_index_of (element: ITEM; start_index: INTEGER_32): INTEGER_32 is
431-- 			-- Using `is_equal' for comparison, gives the index of the
432-- 			-- first occurrence of `element' at or before
433-- 			-- `start_index'. Search is done in reverse direction, which
434-- 			-- means from the `start_index' down to the `lower' index
435-- 			-- . Answer `lower -1' when the search fail.
436		
437-- 			-- See also `fast_reverse_index_of', `last_index_of', 
438-- 			-- `index_of'.
439-- 		local i: INTEGER_32; found: BOOLEAN
440-- 		do
441-- 			from i:=start_index until found or else i<lower
442-- 			loop
443-- 				if element.is_equal(item(i)) then
444-- 					Result:=i; found := True
445-- 				end
446-- 				i := i-1
447-- 			end
448-- 		end
449
450--    last_index_of (element: ITEM): INTEGER_32 is
451-- 			-- Using `is_equal' for comparison, gives the index of the
452-- 			-- last occurrence of `element' at or before `upper'. Search
453-- 			-- is done in reverse direction, which means from the `upper'
454-- 			-- down to the `lower' index . Answer `lower -1' when the
455-- 			-- search fail.
456		
457-- 			-- See also `fast_last_index_of', `reverse_index_of', `index_of'.
458-- 		local i: INTEGER_32; found: BOOLEAN
459-- 		do
460-- 			from i:=upper until found or else i<lower
461-- 			loop
462-- 				if element.is_equal(item(i)) then
463-- 					Result:=i; found := True
464-- 				end
465-- 				i := i-1
466-- 			end
467-- 		end
468
469	fast_first_index_of (element: ITEM): INTEGER_32 is
470			-- Give the index of the first occurrence of `element' using
471			-- basic `=' for comparison.  Answer `upper + 1' when
472			-- `element' is not inside.
473		
474			-- See also `first_index_of', `last_index_of', `fast_last_index_of'.
475		local i: INTEGER_32; found: BOOLEAN
476		do
477			from i:=lower until found or else i>upper
478			loop
479				if element.handle = g_ptr_array_index(handle,i) then
480					Result:=i; found:=True
481				end
482				i := i-1
483			end
484		end
485		
486	fast_index_of (element: ITEM; start_index: INTEGER_32): INTEGER_32 is
487			-- Using basic `=' for comparison, gives the index of the
488			-- first occurrence of `element' at or after
489			-- `start_index'. Answer `upper + 1' when `element' when the
490			-- search fail.
491			
492			-- See also `index_of', `fast_reverse_index_of',
493			-- `fast_first_index_of'.
494		local i: INTEGER_32; found: BOOLEAN
495		do
496			from i:=start_index until found or else i>upper
497			loop
498				if element.handle = g_ptr_array_index(handle,i) then
499					Result:=i; found:=True
500				end
501				i := i+1
502			end
503		end
504
505	fast_reverse_index_of (element: ITEM; start_index: INTEGER_32): INTEGER_32 is
506			-- Using basic `=' comparison, gives the index of the first
507			-- occurrence of `element' at or before `start_index'. Search
508			-- is done in reverse direction, which means from the
509			-- `start_index' down to the `lower' index . Answer `lower
510			-- -1' when the search fail.
511		
512			-- See also `reverse_index_of', `fast_index_of', `fast_last_index_of'.
513		local i: INTEGER_32; found: BOOLEAN
514		do
515			from i:=start_index until found or else i<lower
516			loop
517				if element.handle = g_ptr_array_index(handle,i) then
518					Result:=i; found:=True
519				end
520				i := i-1
521			end
522		end
523
524	fast_last_index_of (element: ITEM): INTEGER_32 is
525			-- Using basic `=' for comparison, gives the index of the
526			-- last occurrence of `element' at or before `upper'. Search
527			-- is done in reverse direction, which means from the `upper'
528			-- down to the `lower' index . Answer `lower -1' when the
529			-- search fail.
530		local i: INTEGER_32; found: BOOLEAN
531		do
532			from i:=upper until found or else i<lower
533			loop
534				if element.handle = g_ptr_array_index(handle,i) then
535					Result:=i; found:=True
536				end
537				i := i-1
538			end
539		end
540
541feature -- Looking and comparison:
542	is_equal (other: like Current): BOOLEAN is
543			-- Do both collections have the same `lower', `upper', and items?
544			-- The basic `=' is used for comparison of items.
545
546			-- See also `is_equal_map', `same_items'.
547		local i: INTEGER_32
548		do
549			if     lower/=other.lower then Result:=False -- this shouldn't be strictly necessary
550			elseif upper/=other.upper then Result:=False -- this shouldn't be strictly necessary
551			else
552				from Result:=True; i:=upper until Result=False or else i<lower
553				loop
554					if element.handle /= g_ptr_array_index(handle,i) then
555						Result:=False
556					end
557					i := i-1
558				end
559			end
560		end
561
562	is_equal_map (other: like Current): BOOLEAN is
563			-- Do both collections have the same `lower', `upper', and
564			-- items?  Feature `is_equal' is used for comparison of
565			-- items.
566
567			-- See also `is_equal', `same_items'.
568		local i: INTEGER_32
569		do
570			if     lower/=other.lower then Result:=False -- this shouldn't be strictly necessary
571			elseif upper/=other.upper then Result:=False -- this shouldn't be strictly necessary
572			else
573				from Result:=True; i:=upper until Result=False or else i<lower
574				loop
575					if not element.is_equal(item(i)) then Result:=False end
576					i := i-1
577				end
578			end
579		end
580
581	all_default: BOOLEAN is
582			-- Are all items Void?
583		local i: INTEGER_32
584		do
585			from Result:=True; i:=upper until Result=False or else i<lower
586			loop
587				if g_ptr_array_index(handle,i).is_not_null then Result:=False end
588				i := i-1
589			end
590		end
591
592	same_items (other: COLLECTION[ITEM]): BOOLEAN is
593			-- Do both collections have the same items? The basic `=' is used
594			-- for comparison of items and indices are not considered (for
595			-- example this routine may yeld True with `Current' indexed in
596			-- range [1..2] and `other' indexed in range [2..3]).
597
598			-- See also `is_equal_map', `is_equal'.
599		local i, oi: ITERATOR[ITEM]
600		do
601			if count = other.count then
602				from
603					i  := get_new_iterator; i.start
604					oi := get_new_iterator; oi.start
605				until Result=False or else (i.is_off or oi.is_off)
606				loop
607					if i.item/=oi.item then Result:=False end
608					i.next; oi.next
609				end
610			else Result:=False
611			end
612		end
613		
614	occurrences (element: ITEM): INTEGER_32 is
615			-- Number of occurrences of `element' using `is_equal' for comparison.
616		
617			-- See also `fast_occurrences', `index_of'.
618		local i: INTEGER_32
619		do
620			from i:=upper until i<lower
621			loop
622				if element.is_equal(item(i)) then Result:=Result+1 end
623				i:=i-1
624			end
625		end
626	
627	fast_occurrences (element: ITEM): INTEGER_32 is
628			-- Number of occurrences of `element' using basic `=' for comparison.
629		
630			-- See also `occurrences', `index_of'.
631		local i: INTEGER_32
632		do
633			from i:=upper until i<lower
634			loop
635				if (element.handle=g_ptr_array_index(handle,i)) then Result:=Result+1 end
636				i:=i-1
637			end
638		end
639	
640
641feature -- Agents based features:
642	--    do_all (action: ROUTINE[TUPLE[ANY]]) is
643	-- 			-- Apply `action' to every item of `Current'.
644		
645	-- 			-- See also `for_all', `exists'.
646	--       require
647	--          action /= Void
648	--    for_all (test: FUNCTION[TUPLE[ANY], BOOLEAN]): BOOLEAN
649	--       -- Do all items satisfy `test'?
650	--       --
651	--       -- See also `do_all', `exists'.
652	--       require
653	--          test /= Void
654	--    exists (test: FUNCTION[TUPLE[ANY], BOOLEAN]): BOOLEAN
655	--       -- Does at least one item satisfy `test'?
656	--       --
657	--       -- See also `do_all', `for_all'.
658	--       require
659	--          test /= Void
660	-- feature(s) from COLLECTION
661	--    -- Other features:
662	--    replace_all (old_value, new_value: ITEM)
663	--       -- Replace all occurrences of the element `old_value' by `new_value' using `is_equal' for comparison.
664	--       --
665	--       -- See also `fast_replace_all', `move'.
666	--       ensure
667	--          count = old count;
668	--          not (create {SAFE_EQUAL[ITEM]}default_create).test(old_value, new_value) implies occurrences(old_value) = 0
669	--    fast_replace_all (old_value, new_value: ITEM)
670	--       -- Replace all occurrences of the element `old_value' by `new_value' using basic `=' for comparison.
671	--       --
672	--       -- See also `replace_all', `move'.
673	--       ensure
674	--          count = old count;
675	--          old_value /= new_value implies fast_occurrences(old_value) = 0
676	--    move (lower_index, upper_index, distance: INTEGER_32)
677	--       -- Move range `lower_index' .. `upper_index' by `distance' positions.
678	--       --	Negative distance moves towards lower indices.
679	--       -- Free places get default values.
680	--       --
681	--       -- See also `slice', `replace_all'.
682	--       require
683	--          lower_index <= upper_index;
684	--          valid_index(lower_index);
685	--          valid_index(lower_index + distance);
686	--          valid_index(upper_index);
687	--          valid_index(upper_index + distance)
688	--       ensure
689	--          count = old count
690	--    slice (min, max: INTEGER_32): like Current
691	--       -- New collection consisting of items at indexes in [`min'..`max'].
692	--       -- Result has the same dynamic type as `Current'.
693	--       -- The `lower' index of the `Result' is the same as `lower'.
694	--       --
695	--       -- See also `from_collection', `move', `replace_all'.
696	--       require
697	--          lower <= min;
698	--          max <= upper;
699	--          min <= max + 1
700	--       ensure
701	--          same_dynamic_type(Result);
702	--          Result.count = max - min + 1;
703	--          Result.lower = lower
704	--    reverse
705	--       -- Reverse the order of the elements.
706	--       ensure
707	--          count = old count
708
709	set_count (a_length: INTEGER) is
710			-- Sets the size of the array, expanding it if necessary. New
711			-- elements are set to Void.
712			require natural: a_length >= 0
713		do
714			g_ptr_array_set_size(handle, a_length)
715		ensure set: count=a_length
716		end
717
718feature -- Unwrapped code
719
720-- g_ptr_array_remove ()
721
722-- gboolean    g_ptr_array_remove              (GPtrArray *array,
723--                                              gpointer data);
724
725-- Removes the first occurrence of the given pointer from the pointer array. The following elements are moved down one place.
726
727-- It returns TRUE if the pointer was removed, or FALSE if the pointer was not found.
728-- array : 	a GPtrArray.
729-- data : 	the pointer to remove.
730-- Returns : 	TRUE if the pointer is removed. FALSE if the pointer is not found in the array.
731-- g_ptr_array_remove_index ()
732
733-- gpointer    g_ptr_array_remove_index        (GPtrArray *array,
734--                                              guint index_);
735
736-- Removes the pointer at the given index from the pointer array. The following elements are moved down one place.
737-- array : 	a GPtrArray.
738-- index_ : 	the index of the pointer to remove.
739-- Returns : 	the pointer which was removed.
740-- g_ptr_array_remove_fast ()
741
742-- gboolean    g_ptr_array_remove_fast         (GPtrArray *array,
743--                                              gpointer data);
744
745-- Removes the first occurrence of the given pointer from the pointer array. The last element in the array is used to fill in the space, so this function does not preserve the order of the array. But it is faster than g_ptr_array_remove().
746
747-- It returns TRUE if the pointer was removed, or FALSE if the pointer was not found.
748-- array : 	a GPtrArray.
749-- data : 	the pointer to remove.
750-- Returns : 	TRUE if the pointer was found in the array.
751-- g_ptr_array_remove_index_fast ()
752
753-- gpointer    g_ptr_array_remove_index_fast   (GPtrArray *array,
754--                                              guint index_);
755
756-- Removes the pointer at the given index from the pointer array. The last element in the array is used to fill in the space, so this function does not preserve the order of the array. But it is faster than g_ptr_array_remove_index().
757-- array : 	a GPtrArray.
758-- index_ : 	the index of the pointer to remove.
759-- Returns : 	the pointer which was removed.
760-- g_ptr_array_remove_range ()
761
762-- void        g_ptr_array_remove_range        (GPtrArray *array,
763--                                              guint index_,
764--                                              guint length);
765
766-- Removes the given number of pointers starting at the given index from a GPtrArray. The following elements are moved to close the gap.
767-- array : 	a GPtrArray.
768-- index_ : 	the index of the first pointer to remove.
769-- length : 	the number of pointers to remove.
770
771-- Since 2.4
772-- g_ptr_array_sort ()
773
774-- void        g_ptr_array_sort                (GPtrArray *array,
775--                                              GCompareFunc compare_func);
776
777-- Sorts the array, using compare_func which should be a qsort()-style comparison function (returns -1 for first arg is less than second arg, 0 for equal, 1 if first arg is greater than second arg).
778-- Note
779
780-- The comparison function for g_ptr_array_sort() doesn't take the pointers from the array as arguments, it takes pointers to the pointers in the array.
781-- array : 	a GPtrArray.
782-- compare_func : 	comparison function.
783-- g_ptr_array_sort_with_data ()
784
785-- void        g_ptr_array_sort_with_data      (GPtrArray *array,
786--                                              GCompareDataFunc compare_func,
787--                                              gpointer user_data);
788
789-- Like g_ptr_array_sort(), but the comparison function has a user data argument.
790-- Note
791
792-- The comparison function for g_ptr_array_sort_with_data() doesn't take the pointers from the array as arguments, it takes pointers to the pointers in the array.
793-- array : 	a GPtrArray.
794-- compare_func : 	comparison function.
795-- user_data : 	data to pass to compare_func.
796
797-- g_ptr_array_index()
798
799-- #define     g_ptr_array_index(array,index_)
800
801-- Returns the pointer at the given index of the pointer array.
802-- array : 	a GPtrArray.
803-- index_ : 	the index of the pointer to return.
804-- Returns : 	the pointer at the given index.
805-- g_ptr_array_free ()
806
807-- gpointer*   g_ptr_array_free                (GPtrArray *array,
808--                                              gboolean free_seg);
809
810-- Frees all of the memory allocated for the pointer array.
811-- array : 	a GPtrArray.
812-- free_seg : 	if TRUE the array of pointers (pdata) is freed.
813-- Returns : 	NULL if free_seg is TRUE, otherwise the array of pointers (pdata) is returned.
814-- g_ptr_array_foreach ()
815
816-- void        g_ptr_array_foreach             (GPtrArray *array,
817--                                              GFunc func,
818--                                              gpointer user_data);
819
820-- Calls a function for each element of a GPtrArray.
821
822-- array : 	a GPtrArray
823-- func : 	the function to call for each array element
824-- user_data : 	user data to pass to the function
825
826-- Since 2.4
827end