• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/ap/gpl/timemachine/gettext-0.17/gettext-tools/gnulib-lib/

Lines Matching refs:list

1 /* Sequential list data type implemented by an array.
61 struct gl_list_impl *list = XMALLOC (struct gl_list_impl);
63 list->base.vtable = implementation;
64 list->base.equals_fn = equals_fn;
65 list->base.hashcode_fn = hashcode_fn;
66 list->base.dispose_fn = dispose_fn;
67 list->base.allow_duplicates = allow_duplicates;
68 list->elements = NULL;
69 list->count = 0;
70 list->allocated = 0;
72 return list;
83 struct gl_list_impl *list = XMALLOC (struct gl_list_impl);
85 list->base.vtable = implementation;
86 list->base.equals_fn = equals_fn;
87 list->base.hashcode_fn = hashcode_fn;
88 list->base.dispose_fn = dispose_fn;
89 list->base.allow_duplicates = allow_duplicates;
92 list->elements = XNMALLOC (count, const void *);
93 memcpy (list->elements, contents, count * sizeof (const void *));
96 list->elements = NULL;
97 list->count = count;
98 list->allocated = count;
100 return list;
104 gl_array_size (gl_list_t list)
106 return list->count;
110 gl_array_node_value (gl_list_t list, gl_list_node_t node)
113 if (!(index < list->count))
116 return list->elements[index];
120 gl_array_next_node (gl_list_t list, gl_list_node_t node)
123 if (!(index < list->count))
127 if (index < list->count)
134 gl_array_previous_node (gl_list_t list, gl_list_node_t node)
137 if (!(index < list->count))
147 gl_array_get_at (gl_list_t list, size_t position)
149 size_t count = list->count;
154 return list->elements[position];
158 gl_array_set_at (gl_list_t list, size_t position, const void *elt)
160 size_t count = list->count;
165 list->elements[position] = elt;
170 gl_array_indexof_from_to (gl_list_t list, size_t start_index, size_t end_index,
173 size_t count = list->count;
181 gl_listelement_equals_fn equals = list->base.equals_fn;
188 if (equals (elt, list->elements[i]))
201 if (elt == list->elements[i])
213 gl_array_search_from_to (gl_list_t list, size_t start_index, size_t end_index,
216 size_t index = gl_array_indexof_from_to (list, start_index, end_index, elt);
220 /* Ensure that list->allocated > list->count. */
222 grow (gl_list_t list)
228 new_allocated = xtimes (list->allocated, 2);
234 memory = (const void **) xrealloc (list->elements, memory_size);
238 list->elements = memory;
239 list->allocated = new_allocated;
243 gl_array_add_first (gl_list_t list, const void *elt)
245 size_t count = list->count;
249 if (count == list->allocated)
250 grow (list);
251 elements = list->elements;
255 list->count = count + 1;
260 gl_array_add_last (gl_list_t list, const void *elt)
262 size_t count = list->count;
264 if (count == list->allocated)
265 grow (list);
266 list->elements[count] = elt;
267 list->count = count + 1;
272 gl_array_add_before (gl_list_t list, gl_list_node_t node, const void *elt)
274 size_t count = list->count;
284 if (count == list->allocated)
285 grow (list);
286 elements = list->elements;
290 list->count = count + 1;
295 gl_array_add_after (gl_list_t list, gl_list_node_t node, const void *elt)
297 size_t count = list->count;
307 if (count == list->allocated)
308 grow (list);
309 elements = list->elements;
313 list->count = count + 1;
318 gl_array_add_at (gl_list_t list, size_t position, const void *elt)
320 size_t count = list->count;
327 if (count == list->allocated)
328 grow (list);
329 elements = list->elements;
333 list->count = count + 1;
338 gl_array_remove_node (gl_list_t list, gl_list_node_t node)
340 size_t count = list->count;
350 elements = list->elements;
351 if (list->base.dispose_fn != NULL)
352 list->base.dispose_fn (elements[position]);
355 list->count = count - 1;
360 gl_array_remove_at (gl_list_t list, size_t position)
362 size_t count = list->count;
369 elements = list->elements;
370 if (list->base.dispose_fn != NULL)
371 list->base.dispose_fn (elements[position]);
374 list->count = count - 1;
379 gl_array_remove (gl_list_t list, const void *elt)
381 size_t position = gl_array_indexof_from_to (list, 0, list->count, elt);
385 return gl_array_remove_at (list, position);
389 gl_array_list_free (gl_list_t list)
391 if (list->elements != NULL)
393 if (list->base.dispose_fn != NULL)
395 size_t count = list->count;
399 gl_listelement_dispose_fn dispose = list->base.dispose_fn;
400 const void **elements = list->elements;
407 free (list->elements);
409 free (list);
415 gl_array_iterator (gl_list_t list)
419 result.vtable = list->base.vtable;
420 result.list = list;
421 result.count = list->count;
422 result.p = list->elements + 0;
423 result.q = list->elements + list->count;
433 gl_array_iterator_from_to (gl_list_t list, size_t start_index, size_t end_index)
437 if (!(start_index <= end_index && end_index <= list->count))
440 result.vtable = list->base.vtable;
441 result.list = list;
442 result.count = list->count;
443 result.p = list->elements + start_index;
444 result.q = list->elements + end_index;
457 gl_list_t list = iterator->list;
458 if (iterator->count != list->count)
460 if (iterator->count != list->count + 1)
461 /* Concurrent modifications were done on the list. */
473 *nodep = INDEX_TO_NODE (p - list->elements);
489 gl_array_sortedlist_indexof_from_to (gl_list_t list,
494 if (!(low <= high && high <= list->count))
501 than ELT. So, if the element occurs in the list, it is at
506 int cmp = compar (list->elements[mid], elt);
518 compar (list->elements[high], elt) == 0,
524 int cmp2 = compar (list->elements[mid2], elt);
529 /* The list was not sorted. */
548 gl_array_sortedlist_indexof (gl_list_t list, gl_listelement_compar_fn compar,
551 return gl_array_sortedlist_indexof_from_to (list, compar, 0, list->count,
556 gl_array_sortedlist_search_from_to (gl_list_t list,
562 gl_array_sortedlist_indexof_from_to (list, compar, low, high, elt);
567 gl_array_sortedlist_search (gl_list_t list, gl_listelement_compar_fn compar,
571 gl_array_sortedlist_indexof_from_to (list, compar, 0, list->count, elt);
576 gl_array_sortedlist_add (gl_list_t list, gl_listelement_compar_fn compar,
579 size_t count = list->count;
588 int cmp = compar (list->elements[mid], elt);
600 return gl_array_add_at (list, low, elt);
604 gl_array_sortedlist_remove (gl_list_t list, gl_listelement_compar_fn compar,
607 size_t index = gl_array_sortedlist_indexof (list, compar, elt);
611 return gl_array_remove_at (list, index);