2003-07-26 Matthias Clasen <maclas@gmx.de>
+ * glib/garray.h:
+ * glib/garray.c (g_{,byte,pointer}_remove_range): New functions to remove a range of elements
+ from an array. (#94879, Nalin Dahyabhai)
+
* glib/gmessages.c (g_logv): Remove the 1024 char limit in the common (non-recursive)
case.
2003-07-26 Matthias Clasen <maclas@gmx.de>
+ * glib/garray.h:
+ * glib/garray.c (g_{,byte,pointer}_remove_range): New functions to remove a range of elements
+ from an array. (#94879, Nalin Dahyabhai)
+
* glib/gmessages.c (g_logv): Remove the 1024 char limit in the common (non-recursive)
case.
2003-07-26 Matthias Clasen <maclas@gmx.de>
+ * glib/garray.h:
+ * glib/garray.c (g_{,byte,pointer}_remove_range): New functions to remove a range of elements
+ from an array. (#94879, Nalin Dahyabhai)
+
* glib/gmessages.c (g_logv): Remove the 1024 char limit in the common (non-recursive)
case.
2003-07-26 Matthias Clasen <maclas@gmx.de>
+ * glib/garray.h:
+ * glib/garray.c (g_{,byte,pointer}_remove_range): New functions to remove a range of elements
+ from an array. (#94879, Nalin Dahyabhai)
+
* glib/gmessages.c (g_logv): Remove the 1024 char limit in the common (non-recursive)
case.
2003-07-26 Matthias Clasen <maclas@gmx.de>
+ * glib/garray.h:
+ * glib/garray.c (g_{,byte,pointer}_remove_range): New functions to remove a range of elements
+ from an array. (#94879, Nalin Dahyabhai)
+
* glib/gmessages.c (g_logv): Remove the 1024 char limit in the common (non-recursive)
case.
2003-07-26 Matthias Clasen <maclas@gmx.de>
+ * glib/garray.h:
+ * glib/garray.c (g_{,byte,pointer}_remove_range): New functions to remove a range of elements
+ from an array. (#94879, Nalin Dahyabhai)
+
* glib/gmessages.c (g_logv): Remove the 1024 char limit in the common (non-recursive)
case.
2003-07-26 Matthias Clasen <maclas@gmx.de>
+ * glib/tmpl/arrays.sgml:
+ * glib/tmpl/arrays_byte.sgml:
+ * glib/tmpl/arrays_pointer.sgml:
+ * glib/glib-sections.txt: Add g_{,byte,pointer}_array_remove_range. (#94879, Nalin Dahyabhai)
+
* glib/tmpl/messages.sgml: Remove the note about the message length restriction.
2003-07-24 Matthias Clasen <maclas@gmx.de>
g_array_insert_vals
g_array_remove_index
g_array_remove_index_fast
+g_array_remove_range
g_array_sort
g_array_sort_with_data
g_array_index
g_ptr_array_remove_index
g_ptr_array_remove_fast
g_ptr_array_remove_index_fast
+g_ptr_array_remove_range
g_ptr_array_sort
g_ptr_array_sort_with_data
g_ptr_array_set_size
g_byte_array_prepend
g_byte_array_remove_index
g_byte_array_remove_index_fast
+g_byte_array_remove_range
g_byte_array_sort
g_byte_array_sort_with_data
g_byte_array_set_size
@Returns: the #GArray.
+<!-- ##### FUNCTION g_array_remove_range ##### -->
+<para>
+Removes the given number of elements starting at the given index from a
+#GArray. The following elements are moved to close the gap.
+</para>
+
+@array: a @GArray.
+@index_: the index of the first element to remove.
+@length: the number of elements to remove.
+@Returns: the #GArray.
+@Since: 2.4
+
+
<!-- ##### FUNCTION g_array_sort ##### -->
<para>
-Sorts a #GArray using @compare_func which should be a <function>qsort()</function>-style comparison
+Sorts a #GArray 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).
</para>
@Returns: the #GByteArray.
+<!-- ##### FUNCTION g_byte_array_remove_range ##### -->
+<para>
+Removes the given number of bytes starting at the given index from a
+#GByteArray. The following elements are moved to close the gap.
+</para>
+
+@array: a @GByteArray.
+@index_: the index of the first byte to remove.
+@length: the number of bytes to remove.
+@Returns: the #GByteArray.
+@Since: 2.4
+
+
<!-- ##### FUNCTION g_byte_array_sort ##### -->
<para>
-Sorts a byte array, using @compare_func which should be a <function>qsort()</function>-style
+Sorts a byte 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).
</para>
@Returns: the pointer which was removed.
+<!-- ##### FUNCTION g_ptr_array_remove_range ##### -->
+<para>
+Removes the given number of bytes starting at the given index from a
+#GPtrArray. The following elements are moved to close the gap.
+</para>
+
+@array: a @GPtrArray.
+@index_: the index of the first pointer to remove.
+@length: the number of pointers to remove.
+@Since: 2.4
+
+
<!-- ##### FUNCTION g_ptr_array_sort ##### -->
<para>
-Sorts the array, using @compare_func which should be a <function>qsort()</function>-style comparison
+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).
</para>
return farray;
}
+GArray*
+g_array_remove_range (GArray *farray,
+ guint index_,
+ guint length)
+{
+ GRealArray *array = (GRealArray*) farray;
+
+ g_return_val_if_fail (array, NULL);
+ g_return_val_if_fail (index_ < array->len, NULL);
+ g_return_val_if_fail (index_ + length <= array->len, NULL);
+
+ if (index_ + length != array->len)
+ g_memmove (g_array_elt_pos (array, index_),
+ g_array_elt_pos (array, index_ + length),
+ (array->len - (index_ + length)) * array->elt_size);
+
+ array->len -= length;
+#ifdef ENABLE_GC_FRIENDLY
+ g_array_elt_zero (array, array->len, length);
+#else /* !ENABLE_GC_FRIENDLY */
+ g_array_zero_terminate (array);
+#endif /* ENABLE_GC_FRIENDLY */
+
+ return farray;
+}
+
void
g_array_sort (GArray *farray,
GCompareFunc compare_func)
#endif /* ENABLE_GC_FRIENDLY */
array->alloc = g_nearest_pow (array->len + len);
array->alloc = MAX (array->alloc, MIN_ARRAY_SIZE);
- array->pdata = g_realloc (array->pdata, sizeof(gpointer) * array->alloc);
+ array->pdata = g_realloc (array->pdata, sizeof (gpointer) * array->alloc);
#ifdef ENABLE_GC_FRIENDLY
for ( ; old_alloc < array->alloc; old_alloc++)
array->pdata [old_alloc] = NULL;
return result;
}
+void
+g_ptr_array_remove_range (GPtrArray* farray,
+ guint index_,
+ guint length)
+{
+ GRealPtrArray* array = (GRealPtrArray*) farray;
+
+ g_return_if_fail (array);
+ g_return_if_fail (index_ < array->len);
+ g_return_if_fail (index_ + length <= array->len);
+
+ if (index_ + length != array->len)
+ g_memmove (&array->pdata[index_],
+ &array->pdata[index_ + length],
+ (array->len - (index_ + length)) * sizeof (gpointer));
+
+ array->len -= length;
+#ifdef ENABLE_GC_FRIENDLY
+ g_array_elt_zero (array->pdata, array->len, length);
+#endif /* ENABLE_GC_FRIENDLY */
+}
+
gboolean
g_ptr_array_remove (GPtrArray* farray,
gpointer data)
return array;
}
+GByteArray*
+g_byte_array_remove_range (GByteArray *array,
+ guint index_,
+ guint length)
+{
+ g_return_val_if_fail (array, FALSE);
+ g_return_val_if_fail (index_ < array->len, FALSE);
+ g_return_val_if_fail (index_ + length <= array->len, FALSE);
+
+ return g_array_remove_range ((GArray*) array, index_, length);
+}
+
void
g_byte_array_sort (GByteArray *array,
GCompareFunc compare_func)
guint index_);
GArray* g_array_remove_index_fast (GArray *array,
guint index_);
+GArray* g_array_remove_range (GArray *array,
+ guint index_,
+ guint length);
void g_array_sort (GArray *array,
GCompareFunc compare_func);
void g_array_sort_with_data (GArray *array,
gpointer data);
gboolean g_ptr_array_remove_fast (GPtrArray *array,
gpointer data);
+void g_ptr_array_remove_range (GPtrArray *array,
+ guint index_,
+ guint length);
void g_ptr_array_add (GPtrArray *array,
gpointer data);
void g_ptr_array_sort (GPtrArray *array,
guint index_);
GByteArray* g_byte_array_remove_index_fast (GByteArray *array,
guint index_);
+GByteArray* g_byte_array_remove_range (GByteArray *array,
+ guint index_,
+ guint length);
void g_byte_array_sort (GByteArray *array,
GCompareFunc compare_func);
void g_byte_array_sort_with_data (GByteArray *array,